github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/distribution/distributebundle.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 ) 9 10 type DistributeReleaseBundleCommand struct { 11 rtDetails *config.ArtifactoryDetails 12 distributeBundlesParams services.DistributionParams 13 distributionRules *spec.DistributionRules 14 dryRun bool 15 } 16 17 func NewReleaseBundleDistributeCommand() *DistributeReleaseBundleCommand { 18 return &DistributeReleaseBundleCommand{} 19 } 20 21 func (db *DistributeReleaseBundleCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *DistributeReleaseBundleCommand { 22 db.rtDetails = rtDetails 23 return db 24 } 25 26 func (db *DistributeReleaseBundleCommand) SetDistributeBundleParams(params services.DistributionParams) *DistributeReleaseBundleCommand { 27 db.distributeBundlesParams = params 28 return db 29 } 30 31 func (db *DistributeReleaseBundleCommand) SetDistributionRules(distributionRules *spec.DistributionRules) *DistributeReleaseBundleCommand { 32 db.distributionRules = distributionRules 33 return db 34 } 35 36 func (db *DistributeReleaseBundleCommand) SetDryRun(dryRun bool) *DistributeReleaseBundleCommand { 37 db.dryRun = dryRun 38 return db 39 } 40 41 func (db *DistributeReleaseBundleCommand) Run() error { 42 servicesManager, err := utils.CreateDistributionServiceManager(db.rtDetails, db.dryRun) 43 if err != nil { 44 return err 45 } 46 47 for _, rule := range db.distributionRules.DistributionRules { 48 db.distributeBundlesParams.DistributionRules = append(db.distributeBundlesParams.DistributionRules, rule.ToDistributionCommonParams()) 49 } 50 51 return servicesManager.DistributeReleaseBundle(db.distributeBundlesParams) 52 } 53 54 func (db *DistributeReleaseBundleCommand) RtDetails() (*config.ArtifactoryDetails, error) { 55 return db.rtDetails, nil 56 } 57 58 func (db *DistributeReleaseBundleCommand) CommandName() string { 59 return "rt_distribute_bundle" 60 }