github.com/jfrog/jfrog-cli-core/v2@v2.52.0/pipelines/commands/sync.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/jfrog/jfrog-cli-core/v2/pipelines/manager"
     5  	"github.com/jfrog/jfrog-cli-core/v2/utils/config"
     6  )
     7  
     8  type SyncCommand struct {
     9  	serverDetails      *config.ServerDetails
    10  	branch             string
    11  	repositoryFullName string
    12  }
    13  
    14  func NewSyncCommand() *SyncCommand {
    15  	return &SyncCommand{}
    16  }
    17  
    18  func (sc *SyncCommand) ServerDetails() (*config.ServerDetails, error) {
    19  	return sc.serverDetails, nil
    20  }
    21  
    22  func (sc *SyncCommand) SetServerDetails(serverDetails *config.ServerDetails) *SyncCommand {
    23  	sc.serverDetails = serverDetails
    24  	return sc
    25  }
    26  
    27  func (sc *SyncCommand) CommandName() string {
    28  	return "pl_sync"
    29  }
    30  
    31  func (sc *SyncCommand) SetBranch(br string) *SyncCommand {
    32  	sc.branch = br
    33  	return sc
    34  }
    35  
    36  func (sc *SyncCommand) SetRepositoryFullName(rfn string) *SyncCommand {
    37  	sc.repositoryFullName = rfn
    38  	return sc
    39  }
    40  
    41  func (sc *SyncCommand) Run() error {
    42  	serviceManager, err := manager.CreateServiceManager(sc.serverDetails)
    43  	if err != nil {
    44  		return err
    45  	}
    46  	return serviceManager.SyncPipelineResource(sc.branch, sc.repositoryFullName)
    47  }