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

Function createRun

pkg/cmd/runbook/snapshot/create/create.go:125–269  ·  view source on GitHub ↗
(opts *CreateOptions, outputFormat string)

Source from the content-addressed store, hash-verified

123}
124
125func createRun(opts *CreateOptions, outputFormat string) error {
126 if opts.SnapshotNotes.Value != "" && opts.SnapshotNotesFile.Value != "" {
127 return errors.New("cannot specify both --snapshot-notes and --snapshot-notes-file at the same time")
128 }
129
130 if !opts.NoPrompt {
131 if err := PromptMissing(opts); err != nil {
132 return err
133 }
134 }
135
136 if opts.SnapshotNotesFile.Value != "" {
137 fileContents, err := os.ReadFile(opts.SnapshotNotesFile.Value)
138 if err != nil {
139 return err
140 }
141 opts.SnapshotNotes.Value = string(fileContents)
142 }
143
144 project, err := selectors.FindProject(opts.Client, opts.Project.Value)
145 if err != nil {
146 return err
147 }
148 if project == nil {
149 return errors.New("unable to find project")
150 }
151
152 runbooksInGit := shared.AreRunbooksInGit(project)
153 if runbooksInGit {
154 return errors.New("creating independent Runbook snapshots is not supported for Runbooks stored in Git")
155 }
156
157 runbook, err := selectors.FindRunbook(opts.Client, project, opts.Runbook.Value)
158
159 if err != nil {
160 return err
161 }
162 if runbook == nil {
163 return errors.New("unable to find runbook")
164 }
165
166 runbookTemplate, err := opts.Client.Runbooks.GetRunbookSnapshotTemplate(runbook)
167 if err != nil {
168 return err
169 }
170
171 snapshotName := getSnapshotName(opts, runbookTemplate)
172 if err != nil {
173 return err
174 }
175
176 packageVersionOverrides := make([]*packages.PackageVersionOverride, 0)
177 packageVersionBaseline := buildPackageVersionBaseline(opts, runbookTemplate)
178 for _, s := range opts.PackageVersionSpec.Value {
179 ambOverride, err := packages.ParsePackageOverrideString(s)
180 if err != nil {
181 continue // silently ignore anything that wasn't parseable (should we emit a warning?)
182 }

Callers 1

NewCmdCreateFunction · 0.70

Calls 12

FindProjectFunction · 0.92
AreRunbooksInGitFunction · 0.92
FindRunbookFunction · 0.92
SliceTransformFunction · 0.92
BluefFunction · 0.92
getSnapshotNameFunction · 0.85
PromptMissingFunction · 0.70

Tested by

no test coverage detected