github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/buildinfo/promote.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 BuildPromotionCommand struct {
    10  	services.PromotionParams
    11  	rtDetails *config.ArtifactoryDetails
    12  	dryRun    bool
    13  }
    14  
    15  func NewBuildPromotionCommand() *BuildPromotionCommand {
    16  	return &BuildPromotionCommand{}
    17  }
    18  
    19  func (bpc *BuildPromotionCommand) SetDryRun(dryRun bool) *BuildPromotionCommand {
    20  	bpc.dryRun = dryRun
    21  	return bpc
    22  }
    23  
    24  func (bpc *BuildPromotionCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *BuildPromotionCommand {
    25  	bpc.rtDetails = rtDetails
    26  	return bpc
    27  }
    28  
    29  func (bpc *BuildPromotionCommand) SetPromotionParams(params services.PromotionParams) *BuildPromotionCommand {
    30  	bpc.PromotionParams = params
    31  	return bpc
    32  }
    33  
    34  func (bpc *BuildPromotionCommand) Run() error {
    35  	servicesManager, err := utils.CreateServiceManager(bpc.rtDetails, bpc.dryRun)
    36  	if err != nil {
    37  		return err
    38  	}
    39  	return servicesManager.PromoteBuild(bpc.PromotionParams)
    40  }
    41  
    42  func (bpc *BuildPromotionCommand) RtDetails() (*config.ArtifactoryDetails, error) {
    43  	return bpc.rtDetails, nil
    44  }
    45  
    46  func (bpc *BuildPromotionCommand) CommandName() string {
    47  	return "rt_build_promote"
    48  }