Skip to content

Commit 54ff6f6

Browse files
rimapolagrasth
andauthored
Introduce support for multisource and new source type 'package' (#1390)
* Update dependencies * Update dependencies * Introduce support for create release bundle from multiple sources defined in spec and support new source type * Update dependencies * Update dependencies * Update dependencies * Update dependencies * Resolve dependencies * Update common/spec/specfiles.go Co-authored-by: Agrasth Naman <agrasthn@jfrog.com> * Update artifactory/utils/search.go Co-authored-by: Agrasth Naman <agrasthn@jfrog.com> * Update artifactory/utils/search.go Co-authored-by: Agrasth Naman <agrasthn@jfrog.com> * Change ValidateSpec - support Package and multiple sources * Fix struct File (RepoKey) * update dependencies * Update dependencies * Update dependencies * Update dependencies * Update dependencies * Update dependencies * Update dependencies * Update dependencies --------- Co-authored-by: Agrasth Naman <agrasthn@jfrog.com>
1 parent 962c06a commit 54ff6f6

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
lines changed

artifactory/utils/search.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,18 @@ func SearchResultNoDate(reader *content.ContentReader) (contentReader *content.C
166166
return
167167
}
168168

169+
// SearchFiles performs a search operation using the provided spec files.
170+
// This is a wrapper around SearchFilesBySpecs for backward compatibility.
169171
func SearchFiles(servicesManager artifactory.ArtifactoryServicesManager, spec *spec.SpecFiles) (searchResults []*content.ContentReader, callbackFunc func() error, err error) {
172+
return SearchFilesBySpecs(servicesManager, spec.Files)
173+
}
174+
175+
// SearchFilesBySpecs performs a search operation using the provided file specifications.
176+
// It supports multiple source types including artifacts, packages, and release bundles.
177+
func SearchFilesBySpecs(servicesManager artifactory.ArtifactoryServicesManager, files []spec.File) (searchResults []*content.ContentReader, callbackFunc func() error, err error) {
178+
if len(files) == 0 {
179+
return nil, nil, errorutils.CheckErrorf("no files provided for search")
180+
}
170181
callbackFunc = func() error {
171182
var errs error
172183
for _, reader := range searchResults {
@@ -177,8 +188,8 @@ func SearchFiles(servicesManager artifactory.ArtifactoryServicesManager, spec *s
177188

178189
var curSearchParams services.SearchParams
179190
var curReader *content.ContentReader
180-
for i := 0; i < len(spec.Files); i++ {
181-
curSearchParams, err = GetSearchParams(spec.Get(i))
191+
for i := 0; i < len(files); i++ {
192+
curSearchParams, err = GetSearchParams(&files[i])
182193
if err != nil {
183194
return
184195
}

common/spec/specfiles.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ type File struct {
9393
Transitive string
9494
TargetPathInArchive string
9595
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"`
96100
}
97101

98102
func (f File) GetInclude() []string {
@@ -217,6 +221,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
217221
isExplode, _ := file.IsExplode(false)
218222
isBypassArchiveInspection, _ := file.IsBypassArchiveInspection(false)
219223
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+
220229
if isPathMapping {
221230
if !isAql {
222231
return errorutils.CheckErrorf("pathMapping is supported only with aql")
@@ -234,11 +243,9 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
234243
if !isSearchBasedSpec && !isPattern {
235244
return errorutils.CheckErrorf("spec must include a pattern")
236245
}
237-
if isBuild && isBundle {
238-
return fileSpecValidationError("build", "bundle")
239-
}
240-
if isSearchBasedSpec && !isAql && !isPattern && !isBuild && !isBundle {
241-
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")
242249
}
243250
if isOffset {
244251
if isBuild {
@@ -259,9 +266,6 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
259266
return fileSpecValidationError("bundle", "limit")
260267
}
261268
}
262-
if isAql && isPattern {
263-
return fileSpecValidationError("aql", "pattern")
264-
}
265269
if isAql && isExclusions {
266270
return fileSpecValidationError("aql", "exclusions")
267271
}
@@ -295,6 +299,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error
295299
if isBypassArchiveInspection && !isExplode {
296300
return errorutils.CheckErrorf("spec cannot include 'bypass-archive-inspection' if 'explode' is not included")
297301
}
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+
}
298307
}
299308
return nil
300309
}

general/token/oidctokenexchange.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,5 @@ func (otc *OidcTokenExchangeCommand) getOidcTokenParams() services.CreateOidcTok
191191
oidcTokenParams.Repo = otc.Repository
192192
oidcTokenParams.Audience = otc.Audience
193193
oidcTokenParams.ProviderName = otc.ProviderName
194-
oidcTokenParams.ProviderType = otc.ProviderType.String()
195194
return oidcTokenParams
196195
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ require (
114114
sigs.k8s.io/yaml v1.4.0 // indirect
115115
)
116116

117-
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250610112448-de5e55438dba
117+
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d
118118

119119
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250611113558-c1a092f216fd
120120

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ github.com/jfrog/build-info-go v1.10.14 h1:PWnw+rBwiQTHZ5q+84+E8MHFjtAQkB3+Oc2sK
113113
github.com/jfrog/build-info-go v1.10.14/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
114114
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
115115
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
116-
github.com/jfrog/jfrog-client-go v1.54.1 h1:IvobRCmwFS/HDht6Vv1JtGzPPytmOX3qS57hRC5fU98=
117-
github.com/jfrog/jfrog-client-go v1.54.1/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
116+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d h1:0TNgRnYr92lmxC4my2P07MqaWmYBuLP/sgoCD5k/fhA=
117+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
118118
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
119119
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
120120
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=

0 commit comments

Comments
 (0)