github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/distribution/createbundle.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 CreateBundleCommand struct { 12 rtDetails *config.ArtifactoryDetails 13 releaseBundlesParams distributionServicesUtils.ReleaseBundleParams 14 spec *spec.SpecFiles 15 dryRun bool 16 } 17 18 func NewReleaseBundleCreateCommand() *CreateBundleCommand { 19 return &CreateBundleCommand{} 20 } 21 22 func (cb *CreateBundleCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *CreateBundleCommand { 23 cb.rtDetails = rtDetails 24 return cb 25 } 26 27 func (cb *CreateBundleCommand) SetReleaseBundleCreateParams(params distributionServicesUtils.ReleaseBundleParams) *CreateBundleCommand { 28 cb.releaseBundlesParams = params 29 return cb 30 } 31 32 func (cb *CreateBundleCommand) SetSpec(spec *spec.SpecFiles) *CreateBundleCommand { 33 cb.spec = spec 34 return cb 35 } 36 37 func (cb *CreateBundleCommand) SetDryRun(dryRun bool) *CreateBundleCommand { 38 cb.dryRun = dryRun 39 return cb 40 } 41 42 func (cb *CreateBundleCommand) 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.CreateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams} 53 return servicesManager.CreateReleaseBundle(params) 54 } 55 56 func (cb *CreateBundleCommand) RtDetails() (*config.ArtifactoryDetails, error) { 57 return cb.rtDetails, nil 58 } 59 60 func (cb *CreateBundleCommand) CommandName() string { 61 return "rt_bundle_create" 62 }