github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/distribution/updatebundle.go (about) 1 package distribution 2 3 import ( 4 "github.com/jfrog/jfrog-cli-go/artifactory/spec" 5 "github.com/jfrog/jfrog-cli-go/artifactory/utils" 6 "github.com/jfrog/jfrog-cli-go/utils/config" 7 "github.com/jfrog/jfrog-client-go/distribution/services" 8 distributionServicesUtils "github.com/jfrog/jfrog-client-go/distribution/services/utils" 9 ) 10 11 type UpdateBundleCommand struct { 12 rtDetails *config.ArtifactoryDetails 13 releaseBundlesParams distributionServicesUtils.ReleaseBundleParams 14 spec *spec.SpecFiles 15 dryRun bool 16 } 17 18 func NewReleaseBundleUpdateCommand() *UpdateBundleCommand { 19 return &UpdateBundleCommand{} 20 } 21 22 func (cb *UpdateBundleCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *UpdateBundleCommand { 23 cb.rtDetails = rtDetails 24 return cb 25 } 26 27 func (cb *UpdateBundleCommand) SetReleaseBundleUpdateParams(params distributionServicesUtils.ReleaseBundleParams) *UpdateBundleCommand { 28 cb.releaseBundlesParams = params 29 return cb 30 } 31 32 func (cb *UpdateBundleCommand) SetSpec(spec *spec.SpecFiles) *UpdateBundleCommand { 33 cb.spec = spec 34 return cb 35 } 36 37 func (cb *UpdateBundleCommand) SetDryRun(dryRun bool) *UpdateBundleCommand { 38 cb.dryRun = dryRun 39 return cb 40 } 41 42 func (cb *UpdateBundleCommand) Run() error { 43 servicesManager, err := utils.CreateDistributionServiceManager(cb.rtDetails, cb.dryRun) 44 if err != nil { 45 return err 46 } 47 48 for _, spec := range cb.spec.Files { 49 cb.releaseBundlesParams.SpecFiles = append(cb.releaseBundlesParams.SpecFiles, spec.ToArtifactoryCommonParams()) 50 } 51 52 params := services.UpdateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams} 53 return servicesManager.UpdateReleaseBundle(params) 54 } 55 56 func (cb *UpdateBundleCommand) RtDetails() (*config.ArtifactoryDetails, error) { 57 return cb.rtDetails, nil 58 } 59 60 func (cb *UpdateBundleCommand) CommandName() string { 61 return "rt_bundle_update" 62 }