github.com/jfrog/jfrog-client-go@v1.40.2/distribution/auth/dsdetails.go (about) 1 package auth 2 3 import ( 4 "github.com/jfrog/jfrog-client-go/auth" 5 "github.com/jfrog/jfrog-client-go/config" 6 "github.com/jfrog/jfrog-client-go/distribution" 7 "github.com/jfrog/jfrog-client-go/utils/log" 8 ) 9 10 func NewDistributionDetails() *distributionDetails { 11 return &distributionDetails{} 12 } 13 14 type distributionDetails struct { 15 auth.CommonConfigFields 16 } 17 18 func (ds *distributionDetails) GetVersion() (string, error) { 19 var err error 20 if ds.Version == "" { 21 ds.Version, err = ds.getDistributionVersion() 22 if err != nil { 23 return "", err 24 } 25 log.Debug("JFrog Distribution version is:", ds.Version) 26 } 27 return ds.Version, nil 28 } 29 30 func (ds *distributionDetails) getDistributionVersion() (string, error) { 31 cd := auth.ServiceDetails(ds) 32 serviceConfig, err := config.NewConfigBuilder(). 33 SetServiceDetails(cd). 34 SetCertificatesPath(cd.GetClientCertPath()). 35 Build() 36 if err != nil { 37 return "", err 38 } 39 sm, err := distribution.New(serviceConfig) 40 if err != nil { 41 return "", err 42 } 43 return sm.GetDistributionVersion() 44 }