github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/buildinfo/distribute.go (about)

     1  package buildinfo
     2  
     3  import (
     4  	"github.com/jfrog/jfrog-cli-go/artifactory/utils"
     5  	"github.com/jfrog/jfrog-cli-go/utils/config"
     6  	"github.com/jfrog/jfrog-client-go/artifactory/services"
     7  )
     8  
     9  type BuildDistributeCommnad struct {
    10  	rtDetails *config.ArtifactoryDetails
    11  	services.BuildDistributionParams
    12  	dryRun bool
    13  }
    14  
    15  func NewBuildDistributeCommnad() *BuildDistributeCommnad {
    16  	return &BuildDistributeCommnad{}
    17  }
    18  
    19  func (bdc *BuildDistributeCommnad) SetRtDetails(rtDetails *config.ArtifactoryDetails) *BuildDistributeCommnad {
    20  	bdc.rtDetails = rtDetails
    21  	return bdc
    22  }
    23  
    24  func (bdc *BuildDistributeCommnad) SetDryRun(dryRun bool) *BuildDistributeCommnad {
    25  	bdc.dryRun = dryRun
    26  	return bdc
    27  }
    28  
    29  func (bdc *BuildDistributeCommnad) SetBuildDistributionParams(buildDistributeParams services.BuildDistributionParams) *BuildDistributeCommnad {
    30  	bdc.BuildDistributionParams = buildDistributeParams
    31  	return bdc
    32  }
    33  
    34  func (bdc *BuildDistributeCommnad) Run() error {
    35  	servicesManager, err := utils.CreateServiceManager(bdc.rtDetails, bdc.dryRun)
    36  	if err != nil {
    37  		return err
    38  	}
    39  	return servicesManager.DistributeBuild(bdc.BuildDistributionParams)
    40  }
    41  
    42  func (bdc *BuildDistributeCommnad) RtDetails() (*config.ArtifactoryDetails, error) {
    43  	return bdc.rtDetails, nil
    44  }
    45  
    46  func (bdc *BuildDistributeCommnad) CommandName() string {
    47  	return "rt_build_distribute"
    48  }