(f factory.Factory)
| 59 | } |
| 60 | |
| 61 | func NewCmdUpload(f factory.Factory) *cobra.Command { |
| 62 | uploadFlags := NewUploadFlags() |
| 63 | cmd := &cobra.Command{ |
| 64 | Use: "upload", |
| 65 | Short: "upload build information for one or more packages to Octopus Deploy", |
| 66 | Long: "upload build information one or more packages to Octopus Deploy.", |
| 67 | Aliases: []string{"push"}, |
| 68 | Example: heredoc.Docf(` |
| 69 | %[1]s build-information upload --package-id SomePackage --version 1.0.0 --file buildinfo.octopus |
| 70 | %[1]s build-information upload SomePackage --version 1.0.0 --file buildinfo.octopus --overwrite-mode overwrite |
| 71 | %[1]s build-information push SomePackage --version 1.0.0 --file buildinfo.octopus |
| 72 | %[1]s build-information upload PkgA PkgB PkgC --version 1.0.0 --file buildinfo.octopus |
| 73 | `, constants.ExecutableName), |
| 74 | Annotations: map[string]string{annotations.IsCore: "true"}, |
| 75 | RunE: func(c *cobra.Command, args []string) error { |
| 76 | // any bare args are assumed to be package ids to upload build information for |
| 77 | uploadFlags.PackageId.Value = append(uploadFlags.PackageId.Value, args...) |
| 78 | |
| 79 | opts := NewUploadOptions(uploadFlags, cmd.NewDependencies(f, c)) |
| 80 | return uploadRun(opts) |
| 81 | }, |
| 82 | } |
| 83 | |
| 84 | flags := cmd.Flags() |
| 85 | flags.StringArrayVarP(&uploadFlags.PackageId.Value, uploadFlags.PackageId.Name, "p", nil, "The ID of the package, may be specified multiple times. Any arguments without flags will be treated as package IDs") |
| 86 | flags.StringVarP(&uploadFlags.Version.Value, uploadFlags.Version.Name, "", "", "The version of the package") |
| 87 | flags.StringVarP(&uploadFlags.File.Value, uploadFlags.File.Name, "", "", "Path to Octopus Build Information Json file") |
| 88 | flags.StringVarP(&uploadFlags.OverwriteMode.Value, uploadFlags.OverwriteMode.Name, "", "", "Action when a build information already exists. Valid values are 'fail', 'overwrite', 'ignore'. Default is 'fail'") |
| 89 | flags.SortFlags = false |
| 90 | |
| 91 | flagAliases := make(map[string][]string, 1) |
| 92 | util.AddFlagAliasesString(flags, FlagOverwriteMode, flagAliases, FlagAliasOverwrite, FlagAliasOverwriteMode) |
| 93 | |
| 94 | cmd.PreRunE = func(cmd *cobra.Command, args []string) error { |
| 95 | util.ApplyFlagAliases(cmd.Flags(), flagAliases) |
| 96 | return nil |
| 97 | } |
| 98 | return cmd |
| 99 | } |
| 100 | |
| 101 | func uploadRun(opts *UploadOptions) error { |
| 102 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected