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

Function createRun

pkg/cmd/ephemeralenvironment/create/create.go:106–140  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

104}
105
106func createRun(opts *CreateOptions) error {
107
108 if !opts.NoPrompt {
109 err := PromptMissing(opts)
110 if err != nil {
111 return err
112 }
113 }
114
115 projectResource, err := projects.GetByName(opts.Client, opts.Space.ID, opts.Project.Value)
116 if err != nil {
117 return fmt.Errorf("failed to find project '%s': %w", opts.Project.Value, err)
118 }
119 projectId := projectResource.GetID()
120
121 createEnv, err := ephemeralenvironments.Add(opts.Client, opts.Space.ID, projectId, opts.Name.Value)
122 if err != nil {
123 return err
124 }
125
126 _, err = fmt.Fprintf(opts.Out, "\nSuccessfully created ephemeral environment '%s' with id '%s'.\n", opts.Name.Value, createEnv.Id)
127 if err != nil {
128 return err
129 }
130
131 link := output.Bluef("%s/app#/%s/projects/%s/ephemeral-environments", opts.Host, opts.Space.GetID(), projectId)
132 fmt.Fprintf(opts.Out, "View this ephemeral environment for project `%s` on Octopus Deploy: %s\n", opts.Project.Value, link)
133
134 if !opts.NoPrompt {
135 autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.Project)
136 fmt.Fprintf(opts.Out, "%s\n", autoCmd)
137 }
138
139 return nil
140}
141
142func PromptMissing(opts *CreateOptions) error {
143

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