github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/commands/distribution/updatebundle.go (about) 1 package distribution 2 3 import ( 4 "github.com/jfrog/jfrog-cli-core/artifactory/spec" 5 "github.com/jfrog/jfrog-cli-core/artifactory/utils" 6 "github.com/jfrog/jfrog-cli-core/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.ToArtifactoryCommonParams() 53 if err != nil { 54 return err 55 } 56 cb.releaseBundlesParams.SpecFiles = append(cb.releaseBundlesParams.SpecFiles, params) 57 } 58 59 params := services.UpdateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams} 60 summary, err := servicesManager.UpdateReleaseBundle(params) 61 if cb.detailedSummary { 62 cb.summary = summary 63 } 64 return err 65 } 66 67 func (cb *UpdateBundleCommand) ServerDetails() (*config.ServerDetails, error) { 68 return cb.serverDetails, nil 69 } 70 71 func (cb *UpdateBundleCommand) CommandName() string { 72 return "rt_bundle_update" 73 } 74 75 func (cb *UpdateBundleCommand) SetSummary(summary *clientutils.Sha256Summary) *UpdateBundleCommand { 76 cb.summary = summary 77 return cb 78 } 79 80 func (cb *UpdateBundleCommand) GetSummary() *clientutils.Sha256Summary { 81 return cb.summary 82 } 83 84 func (cb *UpdateBundleCommand) SetDetailedSummary(detailedSummary bool) *UpdateBundleCommand { 85 cb.detailedSummary = detailedSummary 86 return cb 87 } 88 89 func (cb *UpdateBundleCommand) IsDetailedSummary() bool { 90 return cb.detailedSummary 91 } 92 93 func (cb *UpdateBundleCommand) IsSignImmediately() bool { 94 return cb.releaseBundlesParams.SignImmediately 95 }