Skip to content

Commit

Permalink
fix: skip prompt if only a single channel (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 authored Dec 13, 2022
1 parent 9183324 commit 01e3cbb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/release/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ func AskQuestions(octopus *octopusApiClient.Client, stdout io.Writer, asker ques

var selectedChannel *channels.Channel
if options.ChannelName == "" {
selectedChannel, err = selectors.Channel(octopus, asker, "Select the channel in which the release will be created", selectedProject)
selectedChannel, err = selectors.Channel(octopus, asker, stdout, "Select the channel in which the release will be created", selectedProject)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/release/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func AskQuestions(octopus *octopusApiClient.Client, stdout io.Writer, asker ques
var selectedRelease *releases.Release
if options.ReleaseVersion == "" {
// first we want to ask them to pick a channel just to narrow down the search space for releases (not sent to server)
selectedChannel, err := selectors.Channel(octopus, asker, "Select channel", selectedProject)
selectedChannel, err := selectors.Channel(octopus, asker, stdout, "Select channel", selectedProject)
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/question/selectors/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ package selectors

import (
"fmt"
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/cli/pkg/question"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels"
octopusApiClient "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects"
"io"
"strings"
)

func Channel(octopus *octopusApiClient.Client, ask question.Asker, questionText string, project *projects.Project) (*channels.Channel, error) {
func Channel(octopus *octopusApiClient.Client, ask question.Asker, io io.Writer, questionText string, project *projects.Project) (*channels.Channel, error) {
existingChannels, err := octopus.Projects.GetChannels(project)
if len(existingChannels) == 1 {
fmt.Fprintf(io, "Selecting only available channel '%s'.\n", output.Cyan(existingChannels[0].Name))
return existingChannels[0], nil
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 01e3cbb

Please sign in to comment.