Skip to content
Snippets Groups Projects
Commit de01ed7a authored by Andy Cobaugh's avatar Andy Cobaugh
Browse files

ci: display version in ci subcommand, make image-tag required only in ci build command

parent 0650e70f
No related branches found
No related tags found
No related merge requests found
......@@ -15,10 +15,12 @@
package cmd
import (
"fmt"
"os"
"git.psu.edu/k8s/devtool/config"
"git.psu.edu/k8s/devtool/environment"
"git.psu.edu/swe-golang/buildversion"
"github.com/fatih/color"
"github.com/spf13/cobra"
......@@ -34,6 +36,13 @@ var ciCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
fmt.Printf("devtool version: %s, commit: %s, builddate: %s\n\n",
buildversion.Get().Version,
buildversion.Get().Commit,
buildversion.Get().BuildDate,
)
},
}
func init() {
......@@ -44,14 +53,8 @@ func init() {
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// configCmd.PersistentFlags().String("foo", "", "A help for foo")
ciCmd.PersistentFlags().StringVarP(&imageTag, "image-tag", "i", "", "image tag for docker")
ciCmd.PersistentFlags().StringVarP(&environmentSuffix, "environment", "e", "", "environment suffix to append to helm release name")
err := ciCmd.MarkPersistentFlagRequired("image-tag")
if err != nil {
panic("invalid arg")
}
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// configCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
......
......@@ -82,6 +82,11 @@ func init() {
panic("invalid arg")
}
ciBuildCmd.PersistentFlags().StringVarP(&imageTag, "image-tag", "i", "", "image tag for docker")
err = ciBuildCmd.MarkPersistentFlagRequired("image-tag")
if err != nil {
panic("invalid arg")
}
}
func buildCiDocker(config config.Config) error {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment