github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/buildinfo/builddiscard.go (about) 1 package buildinfo 2 3 import ( 4 "github.com/jfrog/jfrog-cli-go/artifactory/utils" 5 "github.com/jfrog/jfrog-cli-go/utils/config" 6 "github.com/jfrog/jfrog-client-go/artifactory/services" 7 ) 8 9 type BuildDiscardCommand struct { 10 rtDetails *config.ArtifactoryDetails 11 services.DiscardBuildsParams 12 } 13 14 func NewBuildDiscardCommand() *BuildDiscardCommand { 15 return &BuildDiscardCommand{} 16 } 17 18 func (buildDiscard *BuildDiscardCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *BuildDiscardCommand { 19 buildDiscard.rtDetails = rtDetails 20 return buildDiscard 21 } 22 23 func (buildDiscard *BuildDiscardCommand) SetDiscardBuildsParams(params services.DiscardBuildsParams) *BuildDiscardCommand { 24 buildDiscard.DiscardBuildsParams = params 25 return buildDiscard 26 } 27 28 func (buildDiscard *BuildDiscardCommand) Run() error { 29 servicesManager, err := utils.CreateServiceManager(buildDiscard.rtDetails, false) 30 if err != nil { 31 return err 32 } 33 return servicesManager.DiscardBuilds(buildDiscard.DiscardBuildsParams) 34 } 35 36 func (buildDiscard *BuildDiscardCommand) RtDetails() (*config.ArtifactoryDetails, error) { 37 return buildDiscard.rtDetails, nil 38 } 39 40 func (buildDiscard *BuildDiscardCommand) CommandName() string { 41 return "rt_build_discard" 42 }