github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/commands/buildinfo/promote.go (about)

     1  package buildinfo
     2  
     3  import (
     4  	"github.com/jfrog/jfrog-cli-core/artifactory/utils"
     5  	"github.com/jfrog/jfrog-cli-core/utils/config"
     6  	"github.com/jfrog/jfrog-client-go/artifactory/services"
     7  )
     8  
     9  type BuildPromotionCommand struct {
    10  	services.PromotionParams
    11  	serverDetails *config.ServerDetails
    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) SetServerDetails(serverDetails *config.ServerDetails) *BuildPromotionCommand {
    25  	bpc.serverDetails = serverDetails
    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.serverDetails, -1, bpc.dryRun)
    36  	if err != nil {
    37  		return err
    38  	}
    39  	return servicesManager.PromoteBuild(bpc.PromotionParams)
    40  }
    41  
    42  func (bpc *BuildPromotionCommand) ServerDetails() (*config.ServerDetails, error) {
    43  	return bpc.serverDetails, nil
    44  }
    45  
    46  func (bpc *BuildPromotionCommand) CommandName() string {
    47  	return "rt_build_promote"
    48  }