(cmd *cobra.Command, f factory.Factory, flags *CreateFlags)
| 202 | } |
| 203 | |
| 204 | func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error { |
| 205 | outputFormat, err := cmd.Flags().GetString(constants.FlagOutputFormat) |
| 206 | if err != nil { // should never happen, but fallback if it does |
| 207 | outputFormat = constants.OutputFormatTable |
| 208 | } |
| 209 | |
| 210 | if flags.ReleaseNotes.Value != "" && flags.ReleaseNotesFile.Value != "" { |
| 211 | return errors.New("cannot specify both --release-notes and --release-notes-file at the same time") |
| 212 | } |
| 213 | |
| 214 | // ignore errors when fetching flags |
| 215 | options := &executor.TaskOptionsCreateRelease{ |
| 216 | ProjectName: flags.Project.Value, |
| 217 | DefaultPackageVersion: flags.PackageVersion.Value, |
| 218 | PackageVersionOverrides: flags.PackageVersionSpec.Value, |
| 219 | ChannelName: flags.Channel.Value, |
| 220 | GitReference: flags.GitRef.Value, |
| 221 | GitCommit: flags.GitCommit.Value, |
| 222 | Version: flags.Version.Value, |
| 223 | ReleaseNotes: flags.ReleaseNotes.Value, |
| 224 | IgnoreIfAlreadyExists: flags.IgnoreExisting.Value, |
| 225 | IgnoreChannelRules: flags.IgnoreChannelRules.Value, |
| 226 | GitResourceRefs: flags.GitResourceRefsSpec.Value, |
| 227 | } |
| 228 | |
| 229 | if len(flags.CustomFields.Value) > 0 { |
| 230 | customFields := make(map[string]string) |
| 231 | for _, raw := range flags.CustomFields.Value { |
| 232 | // expect first ':' to split name and value; allow value to contain additional ':' characters |
| 233 | parts := strings.SplitN(raw, ":", 2) |
| 234 | if len(parts) != 2 { |
| 235 | return fmt.Errorf("invalid custom-field value '%s'; expected format name:value", raw) |
| 236 | } |
| 237 | name := strings.TrimSpace(parts[0]) |
| 238 | value := strings.TrimSpace(parts[1]) |
| 239 | if name == "" { |
| 240 | return fmt.Errorf("invalid custom-field value '%s'; field name cannot be empty", raw) |
| 241 | } |
| 242 | customFields[name] = value |
| 243 | } |
| 244 | options.CustomFields = customFields |
| 245 | } |
| 246 | |
| 247 | if flags.ReleaseNotesFile.Value != "" { |
| 248 | fileContents, err := os.ReadFile(flags.ReleaseNotesFile.Value) |
| 249 | if err != nil { |
| 250 | return err |
| 251 | } |
| 252 | options.ReleaseNotes = string(fileContents) |
| 253 | } |
| 254 | |
| 255 | octopus, err := f.GetSpacedClient(apiclient.NewRequester(cmd)) |
| 256 | if err != nil { |
| 257 | return err |
| 258 | } |
| 259 | |
| 260 | if f.IsPromptEnabled() { |
| 261 | err = AskQuestions(octopus, cmd.OutOrStdout(), f.Ask, options) |
no test coverage detected