github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/generic/ping.go (about) 1 package generic 2 3 import ( 4 "github.com/jfrog/jfrog-cli-go/artifactory/utils" 5 "github.com/jfrog/jfrog-cli-go/utils/config" 6 ) 7 8 type PingCommand struct { 9 rtDetails *config.ArtifactoryDetails 10 response []byte 11 } 12 13 func NewPingCommand() *PingCommand { 14 return &PingCommand{} 15 } 16 17 func (pc *PingCommand) Response() []byte { 18 return pc.response 19 } 20 21 func (pc *PingCommand) RtDetails() (*config.ArtifactoryDetails, error) { 22 return pc.rtDetails, nil 23 } 24 25 func (pc *PingCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *PingCommand { 26 pc.rtDetails = rtDetails 27 return pc 28 } 29 30 func (pc *PingCommand) CommandName() string { 31 return "rt_ping" 32 } 33 34 func (pc *PingCommand) Run() error { 35 var err error 36 pc.response, err = pc.Ping() 37 if err != nil { 38 return err 39 } 40 return nil 41 } 42 43 func (pc *PingCommand) Ping() ([]byte, error) { 44 servicesManager, err := utils.CreateServiceManager(pc.rtDetails, false) 45 if err != nil { 46 return nil, err 47 } 48 return servicesManager.Ping() 49 }