-
Notifications
You must be signed in to change notification settings - Fork 58
/
delete.go
51 lines (42 loc) · 1.38 KB
/
delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package replication
import (
rtUtils "github.com/jfrog/jfrog-cli-core/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/utils/config"
"github.com/jfrog/jfrog-cli-core/utils/coreutils"
)
type ReplicationDeleteCommand struct {
serverDetails *config.ServerDetails
repoKey string
quiet bool
}
func NewReplicationDeleteCommand() *ReplicationDeleteCommand {
return &ReplicationDeleteCommand{}
}
func (rdc *ReplicationDeleteCommand) SetRepoKey(repoKey string) *ReplicationDeleteCommand {
rdc.repoKey = repoKey
return rdc
}
func (rdc *ReplicationDeleteCommand) SetQuiet(quiet bool) *ReplicationDeleteCommand {
rdc.quiet = quiet
return rdc
}
func (rdc *ReplicationDeleteCommand) SetServerDetails(serverDetails *config.ServerDetails) *ReplicationDeleteCommand {
rdc.serverDetails = serverDetails
return rdc
}
func (rdc *ReplicationDeleteCommand) ServerDetails() (*config.ServerDetails, error) {
return rdc.serverDetails, nil
}
func (rdc *ReplicationDeleteCommand) CommandName() string {
return "rt_replication_delete"
}
func (rdc *ReplicationDeleteCommand) Run() (err error) {
if !rdc.quiet && !coreutils.AskYesNo("Are you sure you want to delete the replication for "+rdc.repoKey+" ?", false) {
return nil
}
servicesManager, err := rtUtils.CreateServiceManager(rdc.serverDetails, -1, false)
if err != nil {
return err
}
return servicesManager.DeleteReplication(rdc.repoKey)
}