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