github.com/openshift/installer@v1.4.17/cmd/openshift-install/version.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "strings" 7 8 "github.com/spf13/cobra" 9 10 "github.com/openshift/installer/pkg/asset/releaseimage" 11 "github.com/openshift/installer/pkg/version" 12 ) 13 14 func newVersionCmd() *cobra.Command { 15 return &cobra.Command{ 16 Use: "version", 17 Short: "Print version information", 18 Long: "", 19 Args: cobra.ExactArgs(0), 20 RunE: runVersionCmd, 21 } 22 } 23 24 func runVersionCmd(cmd *cobra.Command, args []string) error { 25 versionString, err := version.Version() 26 if err != nil { 27 return err 28 } 29 30 fmt.Printf("%s %s\n", os.Args[0], versionString) 31 if version.Commit != "" { 32 fmt.Printf("built from commit %s\n", version.Commit) 33 } 34 if image, err := releaseimage.Default(); err == nil { 35 fmt.Printf("release image %s\n", image) 36 } 37 releaseArch, err := version.ReleaseArchitecture() 38 if err != nil { 39 return err 40 } 41 fmt.Printf("release architecture %s\n", releaseArch) 42 if strings.Contains(releaseArch, "multi") || strings.Contains(releaseArch, "unknown") { 43 fmt.Printf("default architecture %s\n", version.DefaultArch()) 44 } 45 46 return nil 47 }