generated from konveyor-ecosystem/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add version command Adding tool version to CLI that should return version number and commit hash. Usage: `kantra version`. Fixes: https://issues.redhat.com/browse/MTA-2201 Signed-off-by: Marek Aufart <maufart@redhat.com> * Update build flags Signed-off-by: Marek Aufart <maufart@redhat.com> * Update build scripts Signed-off-by: Marek Aufart <maufart@redhat.com> * Try fix buildah cmd Signed-off-by: Marek Aufart <maufart@redhat.com> * Set buildcommit before Signed-off-by: Marek Aufart <maufart@redhat.com> * Update cmd/version.go Co-authored-by: David Zager <dzager@redhat.com> Signed-off-by: Marek Aufart <aufi.cz@gmail.com> --------- Signed-off-by: Marek Aufart <maufart@redhat.com> Signed-off-by: Marek Aufart <aufi.cz@gmail.com> Co-authored-by: David Zager <dzager@redhat.com>
- Loading branch information
Showing
4 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
BuildCommit = "" | ||
Version = "v99.0.0" | ||
) | ||
|
||
// Use build flags to set correct Version and BuildCommit | ||
// e.g.: | ||
// --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=1.2.3' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$(git rev-parse HEAD)'" | ||
func NewVersionCommand() *cobra.Command { | ||
versionCmd := &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the tool version", | ||
Long: "Print this tool version number", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf("version: %s\n", Version) | ||
fmt.Printf("SHA: %s\n", BuildCommit) | ||
}, | ||
} | ||
return versionCmd | ||
} |