feat(version): Print binary version when given --version flag
This commit is contained in:
parent
ce80934897
commit
20df7b6a19
@ -1,17 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/coreos/coreos-cloudinit/cloudinit"
|
"github.com/coreos/coreos-cloudinit/cloudinit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const version = "0.1.0+git"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var userdata []byte
|
var userdata []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
var printVersion bool
|
||||||
|
flag.BoolVar(&printVersion, "version", false, "Print the version and exit")
|
||||||
|
|
||||||
var file string
|
var file string
|
||||||
flag.StringVar(&file, "from-file", "", "Read user-data from file rather than metadata service")
|
flag.StringVar(&file, "from-file", "", "Read user-data from file rather than metadata service")
|
||||||
|
|
||||||
@ -20,6 +27,11 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if printVersion == true {
|
||||||
|
fmt.Printf("coreos-cloudinit version %s\n", version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if file != "" {
|
if file != "" {
|
||||||
log.Printf("Reading user-data from file: %s", file)
|
log.Printf("Reading user-data from file: %s", file)
|
||||||
userdata, err = ioutil.ReadFile(file)
|
userdata, err = ioutil.ReadFile(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user