(f factory.Factory)
| 55 | } |
| 56 | |
| 57 | func NewCmdUpload(f factory.Factory) *cobra.Command { |
| 58 | uploadFlags := NewUploadFlags() |
| 59 | cmd := &cobra.Command{ |
| 60 | Use: "upload", |
| 61 | Short: "Upload one or more packages to Octopus Deploy", |
| 62 | Long: "Upload one or more packages to Octopus Deploy. Glob patterns are supported. Delta compression is off by default.", |
| 63 | Aliases: []string{"push"}, |
| 64 | Example: heredoc.Docf(` |
| 65 | %[1]s package upload --package SomePackage.1.0.0.zip |
| 66 | %[1]s package upload SomePackage.1.0.0.tar.gz --overwrite-mode overwrite |
| 67 | %[1]s package push SomePackage.1.0.0.zip |
| 68 | %[1]s package upload bin/**/*.zip --continue-on-error |
| 69 | %[1]s package upload PkgA.1.0.0.zip PkgB.2.0.0.tar.gz PkgC.1.0.0.nupkg |
| 70 | %[1]s package upload --package SomePackage.2.0.0.zip --use-delta-compression |
| 71 | %[1]s package upload SomePackage.2.0.0.zip --delta # alias for --use-delta-compression |
| 72 | `, constants.ExecutableName), |
| 73 | Annotations: map[string]string{annotations.IsCore: "true"}, |
| 74 | RunE: func(cmd *cobra.Command, args []string) error { |
| 75 | // any bare args are assumed to be packages to upload |
| 76 | for _, arg := range args { |
| 77 | uploadFlags.Package.Value = append(uploadFlags.Package.Value, arg) |
| 78 | } |
| 79 | return uploadRun(cmd, f, uploadFlags) |
| 80 | }, |
| 81 | } |
| 82 | |
| 83 | flags := cmd.Flags() |
| 84 | flags.StringArrayVarP(&uploadFlags.Package.Value, uploadFlags.Package.Name, "p", nil, "Package to upload, may be specified multiple times. Any arguments without flags will be treated as packages") |
| 85 | flags.StringVarP(&uploadFlags.OverwriteMode.Value, uploadFlags.OverwriteMode.Name, "", "", "Action when a package already exists. Valid values are 'fail', 'overwrite', 'ignore'. Default is 'fail'") |
| 86 | flags.BoolVarP(&uploadFlags.ContinueOnError.Value, uploadFlags.ContinueOnError.Name, "", false, "When uploading multiple packages, controls whether the CLI continues after a failed upload. Default is to abort") |
| 87 | // note to future developers: Added in July 2024; We can remove the beta disclaimer on delta compression at the end of 2024 if customers haven't reported any issues. |
| 88 | // when removing the beta disclaimer, please leave delta compression off by default. It can help on slow networks, but can be slower over fast ones due to the additional work of diffing/patching. |
| 89 | // it's also useless for tar.gz's or zips with single files in them (e.g. someone puts a .MSI file in a .zip just so octopus will accept it) |
| 90 | flags.BoolVarP(&uploadFlags.UseDeltaCompression.Value, uploadFlags.UseDeltaCompression.Name, "d", false, "Attempt to use delta compression when uploading. Off by default. As a recent addition to the CLI, it should be considered in beta.") |
| 91 | flags.SortFlags = false |
| 92 | |
| 93 | flagAliases := make(map[string][]string, 1) |
| 94 | util.AddFlagAliasesString(flags, FlagOverwriteMode, flagAliases, FlagAliasOverwrite, FlagAliasOverwriteMode) |
| 95 | util.AddFlagAliasesBool(flags, FlagUseDeltaCompression, flagAliases, FlagAliasDelta) |
| 96 | |
| 97 | cmd.PreRunE = func(cmd *cobra.Command, args []string) error { |
| 98 | util.ApplyFlagAliases(cmd.Flags(), flagAliases) |
| 99 | return nil |
| 100 | } |
| 101 | return cmd |
| 102 | } |
| 103 | |
| 104 | type uploadSucceededViewModel struct { |
| 105 | PackagePath string `json:"package,omitempty"` |
nothing calls this directly
no test coverage detected