Skip to content

Commit

Permalink
cmd/bootc-image-builder/main: Change version output parser friendly
Browse files Browse the repository at this point in the history
Changes the version output to be more parser friendly
for simple split or yaml parsers.
  • Loading branch information
schuellerf committed Jan 7, 2025
1 parent 54ae0d7 commit 0e75c2c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bib/cmd/bootc-image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,18 +591,22 @@ func cmdVersion() (string, error) {
}
}
if gitRev != "" {
ret = append(ret, fmt.Sprintf("revision: %s", gitRev[:7]))
ret = append(ret, fmt.Sprintf("build_revision: %s", gitRev[:7]))
} else {
ret = append(ret, "revision: unknown")
ret = append(ret, "build_revision: unknown")
}
if buildTime != "" {
ret = append(ret, fmt.Sprintf("build time: %s", buildTime))
ret = append(ret, fmt.Sprintf("build_time: %s", buildTime))
}
if buildTainted {
ret = append(ret, "build status: tainted")
ret = append(ret, "build_status: tainted")
} else {
ret = append(ret, "build status: ok")
ret = append(ret, "build_status: ok")
}

// append final newline
ret = append(ret, "")

return strings.Join(ret, "\n"), nil
}

Expand All @@ -619,6 +623,7 @@ func buildCobraCmdline() (*cobra.Command, error) {
SilenceErrors: true,
Version: version,
}
rootCmd.SetVersionTemplate(version)

rootCmd.PersistentFlags().StringVar(&rootLogLevel, "log-level", "", "logging level (debug, info, error); default error")

Expand All @@ -636,6 +641,8 @@ func buildCobraCmdline() (*cobra.Command, error) {
rootCmd.Use + " quay.io/centos-bootc/centos-bootc:stream9\n",
Version: rootCmd.Version,
}
buildCmd.SetVersionTemplate(version)

rootCmd.AddCommand(buildCmd)
manifestCmd := &cobra.Command{
Use: "manifest",
Expand All @@ -646,6 +653,8 @@ func buildCobraCmdline() (*cobra.Command, error) {
SilenceUsage: true,
Version: rootCmd.Version,
}
manifestCmd.SetVersionTemplate(version)

versionCmd := &cobra.Command{
Use: "version",
Short: "Show the version and quit",
Expand Down

0 comments on commit 0e75c2c

Please sign in to comment.