github.com/cobalt77/jfrog-client-go@v0.14.5/artifactory/services/go/go.go (about) 1 package _go 2 3 import ( 4 "errors" 5 "fmt" 6 7 rthttpclient "github.com/cobalt77/jfrog-client-go/artifactory/httpclient" 8 "github.com/cobalt77/jfrog-client-go/auth" 9 "github.com/cobalt77/jfrog-client-go/utils/errorutils" 10 ) 11 12 type GoService struct { 13 client *rthttpclient.ArtifactoryHttpClient 14 ArtDetails auth.ServiceDetails 15 } 16 17 func NewGoService(client *rthttpclient.ArtifactoryHttpClient) *GoService { 18 return &GoService{client: client} 19 } 20 21 func (gs *GoService) GetJfrogHttpClient() *rthttpclient.ArtifactoryHttpClient { 22 return gs.client 23 } 24 25 func (gs *GoService) SetServiceDetails(artDetails auth.ServiceDetails) { 26 gs.ArtDetails = artDetails 27 } 28 29 func (gs *GoService) PublishPackage(params GoParams) error { 30 artifactoryVersion, err := gs.ArtDetails.GetVersion() 31 if err != nil { 32 return err 33 } 34 publisher := GetCompatiblePublisher(artifactoryVersion) 35 if publisher == nil { 36 return errorutils.CheckError(errors.New(fmt.Sprintf("Unsupported version of Artifactory: %s", artifactoryVersion))) 37 } 38 39 return publisher.PublishPackage(params, gs.client, gs.ArtDetails) 40 } 41 42 type GoParams struct { 43 ZipPath string 44 ModPath string 45 InfoPath string 46 ModContent []byte 47 Version string 48 Props string 49 TargetRepo string 50 ModuleId string 51 } 52 53 func (gp *GoParams) GetZipPath() string { 54 return gp.ZipPath 55 } 56 57 func (gp *GoParams) GetModContent() []byte { 58 return gp.ModContent 59 } 60 61 func (gp *GoParams) GetVersion() string { 62 return gp.Version 63 } 64 65 func (gp *GoParams) GetProps() string { 66 return gp.Props 67 } 68 69 func (gp *GoParams) GetTargetRepo() string { 70 return gp.TargetRepo 71 } 72 73 func (gp *GoParams) GetModuleId() string { 74 return gp.ModuleId 75 } 76 77 func (gp *GoParams) GetModPath() string { 78 return gp.ModPath 79 } 80 81 func (gp *GoParams) GetInfoPath() string { 82 return gp.InfoPath 83 } 84 85 func NewGoParams() GoParams { 86 return GoParams{} 87 }