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