diff --git a/artifactory/utils/search.go b/artifactory/utils/search.go index 6128fb8d1..1f22b33dd 100644 --- a/artifactory/utils/search.go +++ b/artifactory/utils/search.go @@ -166,7 +166,18 @@ func SearchResultNoDate(reader *content.ContentReader) (contentReader *content.C return } +// SearchFiles performs a search operation using the provided spec files. +// This is a wrapper around SearchFilesBySpecs for backward compatibility. func SearchFiles(servicesManager artifactory.ArtifactoryServicesManager, spec *spec.SpecFiles) (searchResults []*content.ContentReader, callbackFunc func() error, err error) { + return SearchFilesBySpecs(servicesManager, spec.Files) +} + +// SearchFilesBySpecs performs a search operation using the provided file specifications. +// It supports multiple source types including artifacts, packages, and release bundles. +func SearchFilesBySpecs(servicesManager artifactory.ArtifactoryServicesManager, files []spec.File) (searchResults []*content.ContentReader, callbackFunc func() error, err error) { + if len(files) == 0 { + return nil, nil, errorutils.CheckErrorf("no files provided for search") + } callbackFunc = func() error { var errs error for _, reader := range searchResults { @@ -177,8 +188,8 @@ func SearchFiles(servicesManager artifactory.ArtifactoryServicesManager, spec *s var curSearchParams services.SearchParams var curReader *content.ContentReader - for i := 0; i < len(spec.Files); i++ { - curSearchParams, err = GetSearchParams(spec.Get(i)) + for i := 0; i < len(files); i++ { + curSearchParams, err = GetSearchParams(&files[i]) if err != nil { return } diff --git a/common/spec/specfiles.go b/common/spec/specfiles.go index 178355fd1..21efc8e3a 100644 --- a/common/spec/specfiles.go +++ b/common/spec/specfiles.go @@ -93,6 +93,10 @@ type File struct { Transitive string TargetPathInArchive string include []string + Package string `json:"package,omitempty"` + Version string `json:"version,omitempty"` + Type string `json:"type,omitempty"` + RepoKey string `json:"repoKey,omitempty"` } func (f File) GetInclude() []string { @@ -217,6 +221,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error isExplode, _ := file.IsExplode(false) isBypassArchiveInspection, _ := file.IsBypassArchiveInspection(false) isTransitive, _ := file.IsTransitive(false) + isPackage := len(file.Package) > 0 + isVersion := len(file.Version) > 0 + isType := len(file.Type) > 0 + isRepoKey := len(file.RepoKey) > 0 + if isPathMapping { if !isAql { return errorutils.CheckErrorf("pathMapping is supported only with aql") @@ -234,11 +243,9 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error if !isSearchBasedSpec && !isPattern { return errorutils.CheckErrorf("spec must include a pattern") } - if isBuild && isBundle { - return fileSpecValidationError("build", "bundle") - } - if isSearchBasedSpec && !isAql && !isPattern && !isBuild && !isBundle { - return errorutils.CheckErrorf("spec must include either aql, pattern, build or bundle") + + if isSearchBasedSpec && !isAql && !isPattern && !isBuild && !isBundle && !isPackage { + return errorutils.CheckErrorf("spec must include either aql, pattern, build, bundle or package") } if isOffset { if isBuild { @@ -259,9 +266,6 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error return fileSpecValidationError("bundle", "limit") } } - if isAql && isPattern { - return fileSpecValidationError("aql", "pattern") - } if isAql && isExclusions { return fileSpecValidationError("aql", "exclusions") } @@ -295,6 +299,11 @@ func ValidateSpec(files []File, isTargetMandatory, isSearchBasedSpec bool) error if isBypassArchiveInspection && !isExplode { return errorutils.CheckErrorf("spec cannot include 'bypass-archive-inspection' if 'explode' is not included") } + if isPackage { + if !isVersion || !isType || !isRepoKey { + return errorutils.CheckErrorf("spec with type 'package' must include 'version', 'type' and 'repo_key'") + } + } } return nil } diff --git a/general/token/oidctokenexchange.go b/general/token/oidctokenexchange.go index 31ba0dcf6..c92cad010 100644 --- a/general/token/oidctokenexchange.go +++ b/general/token/oidctokenexchange.go @@ -191,6 +191,5 @@ func (otc *OidcTokenExchangeCommand) getOidcTokenParams() services.CreateOidcTok oidcTokenParams.Repo = otc.Repository oidcTokenParams.Audience = otc.Audience oidcTokenParams.ProviderName = otc.ProviderName - oidcTokenParams.ProviderType = otc.ProviderType.String() return oidcTokenParams } diff --git a/go.mod b/go.mod index cbd344fe1..7b4a48cdf 100644 --- a/go.mod +++ b/go.mod @@ -114,7 +114,7 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250610112448-de5e55438dba +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250611113558-c1a092f216fd diff --git a/go.sum b/go.sum index c01bdc01c..f7bdcaa22 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,8 @@ github.com/jfrog/build-info-go v1.10.14 h1:PWnw+rBwiQTHZ5q+84+E8MHFjtAQkB3+Oc2sK github.com/jfrog/build-info-go v1.10.14/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s= github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4= -github.com/jfrog/jfrog-client-go v1.54.1 h1:IvobRCmwFS/HDht6Vv1JtGzPPytmOX3qS57hRC5fU98= -github.com/jfrog/jfrog-client-go v1.54.1/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY= +github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d h1:0TNgRnYr92lmxC4my2P07MqaWmYBuLP/sgoCD5k/fhA= +github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=