MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / createRun

Function createRun

pkg/cmd/channel/create/create.go:86–131  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

84}
85
86func createRun(opts *CreateOptions) error {
87 if !opts.NoPrompt {
88 err := PromptMissing(opts)
89 if err != nil {
90 return err
91 }
92 }
93
94 project, err := opts.Client.Projects.GetByIdentifier(opts.Project.Value)
95 if err != nil {
96 return err
97 }
98
99 channel := channels.NewChannel(opts.Name.Value, project.GetID())
100 channel.Description = opts.Description.Value
101 channel.IsDefault = opts.Default.Value
102
103 if opts.Lifecycle.Value != "" {
104 lifecycle, err := opts.Client.Lifecycles.GetByIDOrName(opts.Lifecycle.Value)
105 if err != nil {
106 return err
107 }
108
109 channel.LifecycleID = lifecycle.GetID()
110 }
111
112 createChannel, err := channels.Add(opts.Client, channel)
113 if err != nil {
114 return err
115 }
116
117 _, err = fmt.Fprintf(opts.Out, "\nSuccessfully created channel '%s', (%s).\n", createChannel.Name, createChannel.GetID())
118 if err != nil {
119 return err
120 }
121
122 link := output.Bluef("%s/app#/%s/projects/%s/deployments/channels/edit/%s", opts.Host, opts.Space.GetID(), project.Slug, createChannel.GetID())
123 fmt.Fprintf(opts.Out, "View this channel on Octopus Deploy: %s\n", link)
124
125 if !opts.NoPrompt {
126 autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.Project, opts.Description, opts.Default, opts.Lifecycle)
127 fmt.Fprintf(opts.Out, "%s\n", autoCmd)
128 }
129
130 return nil
131}
132
133func PromptMissing(opts *CreateOptions) error {
134 err := question.AskName(opts.Ask, "", "channel", &opts.Name.Value)

Callers 1

NewCmdCreateFunction · 0.70

Calls 4

BluefFunction · 0.92
GenerateAutomationCmdFunction · 0.92
GetSpaceNameOrEmptyMethod · 0.80
PromptMissingFunction · 0.70

Tested by

no test coverage detected