77 clientutils "github.com/jfrog/jfrog-client-go/utils"
88 "github.com/jfrog/jfrog-client-go/utils/errorutils"
99 "github.com/jfrog/jfrog-client-go/utils/io/fileutils"
10+ "strings"
1011)
1112
1213type SpecFiles struct {
@@ -43,7 +44,10 @@ func CreateSpecFromBuildNameNumberAndProject(buildName, buildNumber, projectKey
4344 return nil , errorutils .CheckErrorf ("build name and build number must be provided" )
4445 }
4546
46- buildString := buildName + "/" + buildNumber
47+ escapedBuildName := strings .ReplaceAll (buildName , "/" , "\\ /" )
48+ escapedBuildNumber := strings .ReplaceAll (buildNumber , "/" , "\\ /" )
49+
50+ buildString := escapedBuildName + "/" + escapedBuildNumber
4751 specFile := & SpecFiles {
4852 Files : []File {
4953 {
@@ -89,6 +93,10 @@ type File struct {
8993 Transitive string
9094 TargetPathInArchive string
9195 include []string
96+ Package string `json:"package,omitempty"`
97+ Version string `json:"version,omitempty"`
98+ Type string `json:"type,omitempty"`
99+ RepoKey string `json:"repoKey,omitempty"`
92100}
93101
94102func (f File ) GetInclude () []string {
@@ -213,6 +221,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
213221 isExplode , _ := file .IsExplode (false )
214222 isBypassArchiveInspection , _ := file .IsBypassArchiveInspection (false )
215223 isTransitive , _ := file .IsTransitive (false )
224+ isPackage := len (file .Package ) > 0
225+ isVersion := len (file .Version ) > 0
226+ isType := len (file .Type ) > 0
227+ isRepoKey := len (file .RepoKey ) > 0
228+
216229 if isPathMapping {
217230 if ! isAql {
218231 return errorutils .CheckErrorf ("pathMapping is supported only with aql" )
@@ -230,11 +243,9 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
230243 if ! isSearchBasedSpec && ! isPattern {
231244 return errorutils .CheckErrorf ("spec must include a pattern" )
232245 }
233- if isBuild && isBundle {
234- return fileSpecValidationError ("build" , "bundle" )
235- }
236- if isSearchBasedSpec && ! isAql && ! isPattern && ! isBuild && ! isBundle {
237- return errorutils .CheckErrorf ("spec must include either aql, pattern, build or bundle" )
246+
247+ if isSearchBasedSpec && ! isAql && ! isPattern && ! isBuild && ! isBundle && ! isPackage {
248+ return errorutils .CheckErrorf ("spec must include either aql, pattern, build, bundle or package" )
238249 }
239250 if isOffset {
240251 if isBuild {
@@ -255,9 +266,6 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
255266 return fileSpecValidationError ("bundle" , "limit" )
256267 }
257268 }
258- if isAql && isPattern {
259- return fileSpecValidationError ("aql" , "pattern" )
260- }
261269 if isAql && isExclusions {
262270 return fileSpecValidationError ("aql" , "exclusions" )
263271 }
@@ -291,6 +299,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
291299 if isBypassArchiveInspection && ! isExplode {
292300 return errorutils .CheckErrorf ("spec cannot include 'bypass-archive-inspection' if 'explode' is not included" )
293301 }
302+ if isPackage {
303+ if ! isVersion || ! isType || ! isRepoKey {
304+ return errorutils .CheckErrorf ("spec with type 'package' must include 'version', 'type' and 'repo_key'" )
305+ }
306+ }
294307 }
295308 return nil
296309}
0 commit comments