Skip to content

Commit

Permalink
Remove flag pipeline name from registerPipelineFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Dec 22, 2023
1 parent 8594ce2 commit 9625129
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 26 deletions.
14 changes: 6 additions & 8 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ var (
jsonQuery string
)

const (
defaultRetryCount = 30
defaultDelay = 5 * time.Second
defaultInstanceCount = 0
)

func registerGlobalFlags(cmd *cobra.Command) {
cmd.PersistentFlags().StringVarP(&cliCfg.URL, "server-url", "", "http://localhost:8153/go",
"GoCD server URL base path")
Expand Down Expand Up @@ -80,12 +86,6 @@ func commonPluginFlags(cmd *cobra.Command) {
"setting this would set 'plugin-id' to 'yaml.config.plugin'")
}

const (
defaultRetryCount = 30
defaultDelay = 5 * time.Second
defaultInstanceCount = 0
)

func registerBackupFlags(cmd *cobra.Command) {
cmd.PersistentFlags().IntVarP(&backupRetry, "retry", "", defaultRetryCount,
"number of times to retry to get backup stats when backup status is not ready")
Expand All @@ -96,8 +96,6 @@ func registerBackupFlags(cmd *cobra.Command) {
func registerPipelineFlags(cmd *cobra.Command) {
cmd.PersistentFlags().IntVarP(&goCDPipelineInstance, "instance", "i", defaultInstanceCount,
"instance number of a pipeline")
cmd.PersistentFlags().StringVarP(&goCDPipelineName, "name", "n", "",
"name of the pipeline present in GoCD")
cmd.PersistentFlags().StringVarP(&goCDPipelineETAG, "etag", "", "",
"etag used to identify the pipeline config. If you don't have one get it by using pipeline get command")
cmd.PersistentFlags().StringVarP(&goCDPipelineMessage, "message", "m", "",
Expand Down
19 changes: 9 additions & 10 deletions cmd/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var (
toCSV string
rawOutput bool
goCDPipelineInstance int
goCDPipelineName string
goCDPipelineMessage string
goCDPipelineETAG string
goCDPipelineTemplateName string
Expand Down Expand Up @@ -80,7 +79,7 @@ GET/PAUSE/UNPAUSE/UNLOCK/SCHEDULE and comment on a GoCD pipeline`,
pipelineCommand.AddCommand(exportPipelineToConfigRepoFormatCommand())
pipelineCommand.AddCommand(getPipelineVSMCommand())
pipelineCommand.AddCommand(getPipelineMapping())
pipelineCommand.AddCommand(getPipelineFilesCommand())
pipelineCommand.AddCommand(findPipelineFilesCommand())
pipelineCommand.AddCommand(showPipelineCommand())

for _, command := range pipelineCommand.Commands() {
Expand Down Expand Up @@ -700,9 +699,9 @@ func schedulePipelineCommand() *cobra.Command {
schedulePipelineCmd := &cobra.Command{
Use: "schedule",
Short: "Command to SCHEDULE a specific pipeline present in GoCD [https://api.gocd.org/current/#scheduling-pipelines]",
Args: cobra.NoArgs,
Args: cobra.RangeArgs(1, 1),
PreRunE: setCLIClient,
Example: `gocd-cli pipeline schedule --name sample --from-file schedule-config.yaml`,
Example: `gocd-cli pipeline schedule sample --from-file schedule-config.yaml`,
RunE: func(cmd *cobra.Command, args []string) error {
var schedule gocd.Schedule
object, err := readObject(cmd)
Expand All @@ -723,11 +722,11 @@ func schedulePipelineCommand() *cobra.Command {
return &errors.UnknownObjectTypeError{Name: objType}
}

if err = client.SchedulePipeline(goCDPipelineName, schedule); err != nil {
if err = client.SchedulePipeline(args[0], schedule); err != nil {
return err
}

return cliRenderer.Render(fmt.Sprintf("pipeline '%s' scheduled successfully", goCDPipelineName))
return cliRenderer.Render(fmt.Sprintf("pipeline '%s' scheduled successfully", args[0]))
},
}

Expand All @@ -740,12 +739,12 @@ func commentPipelineCommand() *cobra.Command {
commentOnPipelineCmd := &cobra.Command{
Use: "comment",
Short: "Command to COMMENT on a specific pipeline instance present in GoCD [https://api.gocd.org/current/#comment-on-pipeline-instance]",
Args: cobra.NoArgs,
Args: cobra.RangeArgs(1, 1),
PreRunE: setCLIClient,
Example: `gocd-cli pipeline comment --message "message to be commented"`,
RunE: func(cmd *cobra.Command, args []string) error {
pipelineObject := gocd.PipelineObject{
Name: goCDPipelineName,
Name: args[0],
Counter: goCDPipelineInstance,
Message: goCDPipelineMessage,
}
Expand All @@ -754,7 +753,7 @@ func commentPipelineCommand() *cobra.Command {
return err
}

return cliRenderer.Render(fmt.Sprintf("commented on pipeline '%s' successfully", goCDPipelineName))
return cliRenderer.Render(fmt.Sprintf("commented on pipeline '%s' successfully", args[0]))
},
}

Expand Down Expand Up @@ -1064,7 +1063,7 @@ func getPipelineMapping() *cobra.Command {
return getPipelineMappingCmd
}

func getPipelineFilesCommand() *cobra.Command {
func findPipelineFilesCommand() *cobra.Command {
var (
goCDPipelinesPath string
goCDPipelinesPatterns []string
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gocd-cli pipeline action sample-pipeline --pause/--un-pause
-h, --help help for action
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gocd-cli pipeline comment --message "message to be commented"
-h, --help help for comment
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gocd-cli pipeline create sample-pipeline --from-file sample-pipeline.yaml --log-
-h, --help help for create
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gocd-cli pipeline instance sample-pipeline --instance 10
-h, --help help for instance
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
3 changes: 1 addition & 2 deletions docs/doc/gocd-cli_pipeline_schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gocd-cli pipeline schedule [flags]
### Examples

```
gocd-cli pipeline schedule --name sample --from-file schedule-config.yaml
gocd-cli pipeline schedule sample --from-file schedule-config.yaml
```

### Options
Expand All @@ -19,7 +19,6 @@ gocd-cli pipeline schedule --name sample --from-file schedule-config.yaml
-h, --help help for schedule
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gocd-cli pipeline template --name sample-pipeline --template-name sample-templat
-h, --help help for template
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down
1 change: 0 additions & 1 deletion docs/doc/gocd-cli_pipeline_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gocd-cli pipeline update sample-movies --from-file sample-movies.yaml --log-leve
-h, --help help for update
-i, --instance int instance number of a pipeline
-m, --message string message to be passed while pausing/unpausing or commenting on pipeline present in GoCD
-n, --name string name of the pipeline present in GoCD
--pause enable to pause a pipeline
--pause-at-start enabling this will create the pipeline in the paused state
--template-name string name of the template to which the pipeline has to be extracted
Expand Down

0 comments on commit 9625129

Please sign in to comment.