Skip to content

Commit 8827818

Browse files
authored
Follow transitive search limitations (#312)
* Fixed some issues regarding limitations in transitive search: --transitive cannot be used with --sort-by and --offset.
1 parent 6d86954 commit 8827818

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

artifactory/commands/generic/download.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99

1010
buildinfo "github.com/jfrog/build-info-go/entities"
1111

12-
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
13-
1412
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
1513
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
1614
"github.com/jfrog/jfrog-client-go/artifactory/services"
@@ -240,7 +238,10 @@ func getDownloadParams(f *spec.File, configuration *utils.DownloadConfiguration)
240238
return
241239
}
242240

243-
downParams.Transitive = strings.ToLower(os.Getenv(coreutils.TransitiveDownload)) == "true"
241+
downParams.Transitive, err = f.IsTransitive(false)
242+
if err != nil {
243+
return
244+
}
244245

245246
downParams.PublicGpgKey = f.GetPublicGpgKey()
246247

common/spec/specfiles.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (f *File) ToCommonParams() (*utils.CommonParams, error) {
155155
return params, nil
156156
}
157157

158-
func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec, isUpload bool) error {
158+
func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error {
159159
if len(files) == 0 {
160160
return errors.New("Spec must include at least one file group")
161161
}
@@ -182,6 +182,7 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec, isUpload b
182182
isRegexp := file.Regexp == "true"
183183
isAnt := file.Ant == "true"
184184
isExplode, _ := file.IsExplode(false)
185+
isTransitive, _ := file.IsTransitive(false)
185186

186187
if isTargetMandatory && !isTarget {
187188
return errors.New("Spec must include target.")
@@ -192,25 +193,26 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec, isUpload b
192193
if isBuild && isBundle {
193194
return fileSpecValidationError("build", "bundle")
194195
}
195-
if isSearchBasedSpec {
196-
if !isAql && !isPattern && !isBuild && !isBundle {
197-
return errors.New("Spec must include either aql, pattern, build or bundle.")
196+
if isSearchBasedSpec && !isAql && !isPattern && !isBuild && !isBundle {
197+
return errors.New("Spec must include either aql, pattern, build or bundle.")
198+
}
199+
if isOffset {
200+
if isBuild {
201+
return fileSpecValidationError("build", "offset")
198202
}
199-
if isOffset {
200-
if isBuild {
201-
return fileSpecValidationError("build", "offset")
202-
}
203-
if isBundle {
204-
return fileSpecValidationError("bundle", "offset")
205-
}
203+
if isBundle {
204+
return fileSpecValidationError("bundle", "offset")
206205
}
207-
if isLimit {
208-
if isBuild {
209-
return fileSpecValidationError("build", "limit")
210-
}
211-
if isBundle {
212-
return fileSpecValidationError("bundle", "limit")
213-
}
206+
}
207+
if isTransitive && isOffset {
208+
return fileSpecValidationError("transitive", "offset")
209+
}
210+
if isLimit {
211+
if isBuild {
212+
return fileSpecValidationError("build", "limit")
213+
}
214+
if isBundle {
215+
return fileSpecValidationError("bundle", "limit")
214216
}
215217
}
216218
if isAql && isPattern {
@@ -228,6 +230,9 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec, isUpload b
228230
if isSortOrder && !isValidSortOrder {
229231
return errors.New("The value of 'sort-order' can only be 'asc' or 'desc'.")
230232
}
233+
if isTransitive && isSortBy {
234+
return fileSpecValidationError("transitive", "sort-by")
235+
}
231236
if !isBuild && (isExcludeArtifacts || isIncludeDeps) {
232237
return errors.New("Spec cannot include 'exclude-artifacts' or 'include-deps' if 'build' is not included.")
233238
}
@@ -248,5 +253,5 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec, isUpload b
248253
}
249254

250255
func fileSpecValidationError(fieldA, fieldB string) error {
251-
return errors.New(fmt.Sprintf("Spec cannot include both '%s' and '%s.'", fieldA, fieldB))
256+
return errors.New(fmt.Sprintf("Spec cannot include both '%s' and '%s'.", fieldA, fieldB))
252257
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exclude (
3030
github.com/pkg/sftp v1.10.1
3131
)
3232

33-
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.7.2-0.20220126202552-33ef52e50cde
33+
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.7.2-0.20220130082553-d834a1f73ff0
3434

3535
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.0.1-0.20220118114459-b944fdc6a593
3636

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ github.com/jfrog/build-info-go v1.0.1-0.20220118114459-b944fdc6a593 h1:QF8ZHXbXX
227227
github.com/jfrog/build-info-go v1.0.1-0.20220118114459-b944fdc6a593/go.mod h1:QyeMfNGt4W0eWazrd7j6uZVN5KTpB05nxF/MwvGnTqs=
228228
github.com/jfrog/gofrog v1.1.1 h1:uRjeZWidQl4FmKP4Zpj5hSKJp3gSIWW9VUwbQdVEVRU=
229229
github.com/jfrog/gofrog v1.1.1/go.mod h1:9YN5v4LlsCfLIXpwQnzSf1wVtgjdHM20FzuIu58RMI4=
230-
github.com/jfrog/jfrog-client-go v1.7.2-0.20220126202552-33ef52e50cde h1:T6oVCtmCtedMP4oIhMTEKG5UewBeNj3Yoxi396QARqE=
231-
github.com/jfrog/jfrog-client-go v1.7.2-0.20220126202552-33ef52e50cde/go.mod h1:LjMyvNTaSn8aMqgqCga1Ii5stlX+TBZyt/RD+K+hC7w=
230+
github.com/jfrog/jfrog-client-go v1.7.2-0.20220130082553-d834a1f73ff0 h1:PTS6i1nG8LPM+Tqx2DrjBCcQi4Xu9Yc67J2VyosNpuQ=
231+
github.com/jfrog/jfrog-client-go v1.7.2-0.20220130082553-d834a1f73ff0/go.mod h1:LjMyvNTaSn8aMqgqCga1Ii5stlX+TBZyt/RD+K+hC7w=
232232
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
233233
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
234234
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=

0 commit comments

Comments
 (0)