Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no prompt if only a single channel #172

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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