github.com/jenkins-x/jx/v2@v2.1.155/pkg/cmd/step/update/release/step_update_release.go (about) 1 package release 2 3 import ( 4 "github.com/jenkins-x/jx/v2/pkg/cmd/helper" 5 "github.com/jenkins-x/jx/v2/pkg/cmd/opts" 6 "github.com/jenkins-x/jx/v2/pkg/cmd/opts/step" 7 "github.com/jenkins-x/jx/v2/pkg/util" 8 "github.com/spf13/cobra" 9 ) 10 11 //StepUpdateReleaseOptions are the common options for all update steps 12 type StepUpdateReleaseOptions struct { 13 step.StepUpdateOptions 14 Owner string 15 Repository string 16 Version string 17 } 18 19 // NewCmdStepUpdateRelease Steps a command object for the "step" command 20 func NewCmdStepUpdateRelease(commonOpts *opts.CommonOptions) *cobra.Command { 21 options := &StepUpdateReleaseOptions{ 22 StepUpdateOptions: step.StepUpdateOptions{ 23 StepOptions: step.StepOptions{ 24 CommonOptions: commonOpts, 25 }, 26 }, 27 } 28 29 cmd := &cobra.Command{ 30 Use: "release-status", 31 Aliases: []string{""}, 32 Short: "update release-status [command]", 33 Run: func(cmd *cobra.Command, args []string) { 34 options.Cmd = cmd 35 options.Args = args 36 err := options.Run() 37 helper.CheckErr(err) 38 }, 39 } 40 cmd.AddCommand(NewCmdStepUpdateReleaseGitHub(commonOpts)) 41 return cmd 42 } 43 44 // Run implements this command 45 func (o *StepUpdateReleaseOptions) Run() error { 46 return o.Cmd.Help() 47 } 48 49 //AddStepUpdateReleaseFlags adds the common flags for all update release steps to the cmd and stores them in o 50 func AddStepUpdateReleaseFlags(cmd *cobra.Command, o *StepUpdateReleaseOptions) { 51 cmd.Flags().StringVarP(&o.Owner, "owner", "", "o", "The owner of the git repository") 52 cmd.Flags().StringVarP(&o.Repository, "repository", "r", "", "The git repository") 53 cmd.Flags().StringVarP(&o.Version, "version", "v", "", "The version to udpate. If no version is found an error is returned") 54 } 55 56 // ValidateOptions validates the common options for all PR creation steps 57 func (o *StepUpdateReleaseOptions) ValidateOptions() error { 58 if o.Owner == "" { 59 return util.MissingOption("owner") 60 } 61 if o.Repository == "" { 62 return util.MissingOption("repository") 63 } 64 if o.Version == "" { 65 return util.MissingOption("version") 66 } 67 return nil 68 }