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

     1  package distribution
     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/distribution/services"
     7  	clientutils "github.com/jfrog/jfrog-client-go/utils"
     8  )
     9  
    10  type SignBundleCommand struct {
    11  	serverDetails     *config.ServerDetails
    12  	signBundlesParams services.SignBundleParams
    13  	detailedSummary   bool
    14  	summary           *clientutils.Sha256Summary
    15  }
    16  
    17  func NewReleaseBundleSignCommand() *SignBundleCommand {
    18  	return &SignBundleCommand{}
    19  }
    20  
    21  func (sb *SignBundleCommand) SetServerDetails(serverDetails *config.ServerDetails) *SignBundleCommand {
    22  	sb.serverDetails = serverDetails
    23  	return sb
    24  }
    25  
    26  func (sb *SignBundleCommand) SetReleaseBundleSignParams(params services.SignBundleParams) *SignBundleCommand {
    27  	sb.signBundlesParams = params
    28  	return sb
    29  }
    30  
    31  func (sb *SignBundleCommand) Run() error {
    32  	servicesManager, err := utils.CreateDistributionServiceManager(sb.serverDetails, false)
    33  	if err != nil {
    34  		return err
    35  	}
    36  
    37  	summary, err := servicesManager.SignReleaseBundle(sb.signBundlesParams)
    38  	if sb.detailedSummary {
    39  		sb.summary = summary
    40  	}
    41  	return err
    42  }
    43  
    44  func (sb *SignBundleCommand) ServerDetails() (*config.ServerDetails, error) {
    45  	return sb.serverDetails, nil
    46  }
    47  
    48  func (sb *SignBundleCommand) CommandName() string {
    49  	return "rt_sign_bundle"
    50  }
    51  
    52  func (sb *SignBundleCommand) SetSummary(summary *clientutils.Sha256Summary) *SignBundleCommand {
    53  	sb.summary = summary
    54  	return sb
    55  }
    56  
    57  func (sb *SignBundleCommand) GetSummary() *clientutils.Sha256Summary {
    58  	return sb.summary
    59  }
    60  
    61  func (sb *SignBundleCommand) SetDetailedSummary(detailedSummary bool) *SignBundleCommand {
    62  	sb.detailedSummary = detailedSummary
    63  	return sb
    64  }
    65  
    66  func (sb *SignBundleCommand) IsDetailedSummary() bool {
    67  	return sb.detailedSummary
    68  }