(octopus *octopusApiClient.Client, ask question.Asker, io io.Writer, questionText string, project *projects.Project)
| 12 | ) |
| 13 | |
| 14 | func Channel(octopus *octopusApiClient.Client, ask question.Asker, io io.Writer, questionText string, project *projects.Project) (*channels.Channel, error) { |
| 15 | existingChannels, err := octopus.Projects.GetChannels(project) |
| 16 | if len(existingChannels) == 1 { |
| 17 | fmt.Fprintf(io, "Selecting only available channel '%s'.\n", output.Cyan(existingChannels[0].Name)) |
| 18 | return existingChannels[0], nil |
| 19 | } |
| 20 | if err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | |
| 24 | return question.SelectMap(ask, questionText, existingChannels, func(p *channels.Channel) string { |
| 25 | return p.Name |
| 26 | }) |
| 27 | } |
| 28 | |
| 29 | func FindChannel(octopus *octopusApiClient.Client, project *projects.Project, channelName string) (*channels.Channel, error) { |
| 30 | foundChannels, err := octopus.Projects.GetChannels(project) // TODO change this to channel partial name search on server; will require go client update |
no test coverage detected