github.com/jfrog/jfrog-cli-core/v2@v2.51.0/artifactory/commands/replication/delete.go (about) 1 package replication 2 3 import ( 4 rtUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" 5 "github.com/jfrog/jfrog-cli-core/v2/utils/config" 6 "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" 7 ) 8 9 type ReplicationDeleteCommand struct { 10 serverDetails *config.ServerDetails 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) SetServerDetails(serverDetails *config.ServerDetails) *ReplicationDeleteCommand { 30 rdc.serverDetails = serverDetails 31 return rdc 32 } 33 34 func (rdc *ReplicationDeleteCommand) ServerDetails() (*config.ServerDetails, error) { 35 return rdc.serverDetails, 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 && !coreutils.AskYesNo("Are you sure you want to delete the replication for "+rdc.repoKey+" ?", false) { 44 return nil 45 } 46 servicesManager, err := rtUtils.CreateServiceManager(rdc.serverDetails, -1, 0, false) 47 if err != nil { 48 return err 49 } 50 return servicesManager.DeleteReplication(rdc.repoKey) 51 }