github.com/jfrog/jfrog-cli-core/v2@v2.52.0/distribution/commands/updatebundle.go (about) 1 package commands 2 3 import ( 4 "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" 5 "github.com/jfrog/jfrog-cli-core/v2/common/spec" 6 "github.com/jfrog/jfrog-cli-core/v2/utils/config" 7 "github.com/jfrog/jfrog-client-go/distribution/services" 8 distributionServicesUtils "github.com/jfrog/jfrog-client-go/distribution/services/utils" 9 clientutils "github.com/jfrog/jfrog-client-go/utils" 10 ) 11 12 type UpdateBundleCommand struct { 13 serverDetails *config.ServerDetails 14 releaseBundlesParams distributionServicesUtils.ReleaseBundleParams 15 spec *spec.SpecFiles 16 dryRun bool 17 detailedSummary bool 18 summary *clientutils.Sha256Summary 19 } 20 21 func NewReleaseBundleUpdateCommand() *UpdateBundleCommand { 22 return &UpdateBundleCommand{} 23 } 24 25 func (cb *UpdateBundleCommand) SetServerDetails(serverDetails *config.ServerDetails) *UpdateBundleCommand { 26 cb.serverDetails = serverDetails 27 return cb 28 } 29 30 func (cb *UpdateBundleCommand) SetReleaseBundleUpdateParams(params distributionServicesUtils.ReleaseBundleParams) *UpdateBundleCommand { 31 cb.releaseBundlesParams = params 32 return cb 33 } 34 35 func (cb *UpdateBundleCommand) SetSpec(spec *spec.SpecFiles) *UpdateBundleCommand { 36 cb.spec = spec 37 return cb 38 } 39 40 func (cb *UpdateBundleCommand) SetDryRun(dryRun bool) *UpdateBundleCommand { 41 cb.dryRun = dryRun 42 return cb 43 } 44 45 func (cb *UpdateBundleCommand) Run() error { 46 servicesManager, err := utils.CreateDistributionServiceManager(cb.serverDetails, cb.dryRun) 47 if err != nil { 48 return err 49 } 50 51 for _, spec := range cb.spec.Files { 52 params, err := spec.ToCommonParams() 53 if err != nil { 54 return err 55 } 56 recursive, err := spec.IsRecursive(true) 57 if err != nil { 58 return err 59 } 60 params.Recursive = recursive 61 cb.releaseBundlesParams.SpecFiles = append(cb.releaseBundlesParams.SpecFiles, params) 62 } 63 64 params := services.UpdateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams} 65 summary, err := servicesManager.UpdateReleaseBundle(params) 66 if cb.detailedSummary { 67 cb.summary = summary 68 } 69 return err 70 } 71 72 func (cb *UpdateBundleCommand) ServerDetails() (*config.ServerDetails, error) { 73 return cb.serverDetails, nil 74 } 75 76 func (cb *UpdateBundleCommand) CommandName() string { 77 return "rt_bundle_update" 78 } 79 80 func (cb *UpdateBundleCommand) SetSummary(summary *clientutils.Sha256Summary) *UpdateBundleCommand { 81 cb.summary = summary 82 return cb 83 } 84 85 func (cb *UpdateBundleCommand) GetSummary() *clientutils.Sha256Summary { 86 return cb.summary 87 } 88 89 func (cb *UpdateBundleCommand) SetDetailedSummary(detailedSummary bool) *UpdateBundleCommand { 90 cb.detailedSummary = detailedSummary 91 return cb 92 } 93 94 func (cb *UpdateBundleCommand) IsDetailedSummary() bool { 95 return cb.detailedSummary 96 } 97 98 func (cb *UpdateBundleCommand) IsSignImmediately() bool { 99 return cb.releaseBundlesParams.SignImmediately 100 }