github.com/cobalt77/jfrog-client-go@v0.14.5/bintray/services/utils/bintrayutils.go (about) 1 package utils 2 3 import ( 4 "encoding/json" 5 "errors" 6 "github.com/cobalt77/jfrog-client-go/utils/errorutils" 7 "strings" 8 ) 9 10 const ( 11 BintrayDownloadRetries = 3 12 BintrayUploadRetries = 3 13 ) 14 15 func ReadBintrayMessage(resp []byte) string { 16 var response bintrayResponse 17 err := json.Unmarshal(resp, &response) 18 if err != nil { 19 return string(resp) 20 } 21 return response.Message 22 } 23 24 func CreatePathDetails(str string) (*PathDetails, error) { 25 parts := strings.Split(str, "/") 26 size := len(parts) 27 if size < 3 { 28 err := errorutils.CheckError(errors.New("Expecting an argument in the form of subject/repository/file-path")) 29 if err != nil { 30 return nil, err 31 } 32 } 33 path := strings.Join(parts[2:], "/") 34 35 return &PathDetails{ 36 Subject: parts[0], 37 Repo: parts[1], 38 Path: path}, nil 39 } 40 41 type bintrayResponse struct { 42 Message string 43 } 44 45 type FileDetails struct { 46 Sha1 string 47 Size int64 48 } 49 50 type PathDetails struct { 51 Subject string 52 Repo string 53 Path string 54 }