diff --git a/cmd/openshift-install/log.go b/cmd/openshift-install/log.go index 526a8560ed..0c76500177 100644 --- a/cmd/openshift-install/log.go +++ b/cmd/openshift-install/log.go @@ -68,6 +68,9 @@ func setupFileHook(baseDir string) func() { })) logrus.Debugf(version.String) + if version.Commit != "" { + logrus.Debugf("Built from commit %s", version.Commit) + } return func() { logfile.Close() diff --git a/cmd/openshift-install/version.go b/cmd/openshift-install/version.go index 30d09b9299..504ea591e7 100644 --- a/cmd/openshift-install/version.go +++ b/cmd/openshift-install/version.go @@ -21,5 +21,8 @@ func newVersionCmd() *cobra.Command { func runVersionCmd(cmd *cobra.Command, args []string) error { fmt.Printf("%s %s\n", os.Args[0], version.Raw) + if version.Commit != "" { + fmt.Printf("built from commit %s\n", version.Commit) + } return nil } diff --git a/hack/build.sh b/hack/build.sh index 8b79ed465e..ad9063dc9b 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -31,7 +31,7 @@ then fi MODE="${MODE:-release}" -LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/version.Raw=$(git describe --always --abbrev=40 --dirty)" +LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/version.Raw=$(git describe --always --abbrev=40 --dirty) -X github.com/openshift/installer/pkg/version.Commit=$(git rev-parse --verify 'HEAD^{commit}')" TAGS="${TAGS:-}" OUTPUT="${OUTPUT:-bin/openshift-install}" export CGO_ENABLED=0 diff --git a/pkg/version/version.go b/pkg/version/version.go index 625009a477..867ea108f5 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -11,4 +11,8 @@ var ( // String is the human-friendly representation of the version. String = fmt.Sprintf("OpenShift Installer %s", Raw) + + // Commit is the commit hash from which the installer was built. + // Set in hack/build.sh. + Commit = "" )