Skip to content

Commit

Permalink
Fix lint errors on unchecked return values
Browse files Browse the repository at this point in the history
  • Loading branch information
lizrabuya authored and jradtilbrook committed Jun 11, 2024
1 parent 8919441 commit 974bc03
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions pkg/cmd/pipeline/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import (
)

func NewCmdPipelineCreate(f *factory.Factory) *cobra.Command {
var pipelineName string
var description string
var repoURL string

cmd := cobra.Command{
DisableFlagsInUseLine: true,
Expand All @@ -30,23 +27,46 @@ func NewCmdPipelineCreate(f *factory.Factory) *cobra.Command {
If the pipeline argument is omitted, the user will be prompted for a name and description.
`),
RunE: func(cmd *cobra.Command, args []string) error {
var repoURL string

qs := []*survey.Question{
{
Name: "pipeline",
Prompt: &survey.Input{Message: "Name:"},
Validate: survey.Required,
},
{
Name: "description",
Prompt: &survey.Input{Message: "Description:"},
Validate: survey.Required,
},
}
answers := struct{ Pipeline, Description string }{}
err := survey.Ask(qs, &answers)
if err != nil {
return err
}

survey.AskOne(&survey.Input{Message: "Name:"}, &pipelineName, survey.WithValidator(survey.Required))
survey.AskOne(&survey.Input{Message: "Description:"}, &description, survey.WithValidator(survey.Required))
repoURLS := getRepoURLS(f)
if len(repoURLS) > 0 {
prompt := &survey.Select{
Message: "Choose a repository:",
Options: repoURLS,
}
survey.AskOne(prompt, &repoURL, survey.WithValidator(survey.Required))
err := survey.AskOne(prompt, &repoURL, survey.WithValidator(survey.Required))
if err != nil {
return err
}
} else {
survey.AskOne(&survey.Input{Message: "Repository URL:"}, &repoURL, survey.WithValidator(survey.Required))
err := survey.AskOne(&survey.Input{Message: "Repository URL:"}, &repoURL, survey.WithValidator(survey.Required))
if err != nil {
return err
}
}

fmt.Printf("Creating pipeline %s with description %s, repo %s\n", pipelineName, description, repoURL)
fmt.Printf("Creating pipeline %s with description %s, repo %s\n", answers.Pipeline, answers.Description, repoURL)

return createPipeline(f.RestAPIClient, f.Config.OrganizationSlug(), pipelineName, description, repoURL)
return createPipeline(f.RestAPIClient, f.Config.OrganizationSlug(), answers.Pipeline, answers.Description, repoURL)
},
}

Expand Down

0 comments on commit 974bc03

Please sign in to comment.