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

     1  package replication
     2  
     3  import (
     4  	rtUtils "github.com/jfrog/jfrog-cli-go/artifactory/utils"
     5  	"github.com/jfrog/jfrog-cli-go/utils/cliutils"
     6  	"github.com/jfrog/jfrog-cli-go/utils/config"
     7  )
     8  
     9  type ReplicationDeleteCommand struct {
    10  	rtDetails *config.ArtifactoryDetails
    11  	repoKey   string
    12  	quiet     bool
    13  }
    14  
    15  func NewReplicationDeleteCommand() *ReplicationDeleteCommand {
    16  	return &ReplicationDeleteCommand{}
    17  }
    18  
    19  func (rdc *ReplicationDeleteCommand) SetRepoKey(repoKey string) *ReplicationDeleteCommand {
    20  	rdc.repoKey = repoKey
    21  	return rdc
    22  }
    23  
    24  func (rdc *ReplicationDeleteCommand) SetQuiet(quiet bool) *ReplicationDeleteCommand {
    25  	rdc.quiet = quiet
    26  	return rdc
    27  }
    28  
    29  func (rdc *ReplicationDeleteCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *ReplicationDeleteCommand {
    30  	rdc.rtDetails = rtDetails
    31  	return rdc
    32  }
    33  
    34  func (rdc *ReplicationDeleteCommand) RtDetails() (*config.ArtifactoryDetails, error) {
    35  	return rdc.rtDetails, nil
    36  }
    37  
    38  func (rdc *ReplicationDeleteCommand) CommandName() string {
    39  	return "rt_replication_delete"
    40  }
    41  
    42  func (rdc *ReplicationDeleteCommand) Run() (err error) {
    43  	if !rdc.quiet && !cliutils.InteractiveConfirm("Are you sure you want to delete the replication for  "+rdc.repoKey+" ?") {
    44  		return nil
    45  	}
    46  	servicesManager, err := rtUtils.CreateServiceManager(rdc.rtDetails, false)
    47  	return servicesManager.DeleteReplication(rdc.repoKey)
    48  }