diff --git a/go.mod b/go.mod index 9977aad09..4d9c972dd 100644 --- a/go.mod +++ b/go.mod @@ -96,7 +96,7 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240122123649-74f725715bbe +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240201133918-82ad9eb51c3f // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231220102935-c8776c613ad8 diff --git a/go.sum b/go.sum index 185260231..65d7f80c1 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,8 @@ github.com/jfrog/build-info-go v1.9.21 h1:bcD0SEC2lEilhjE+aDB3xlvA8zsr4Kw/bFzvr9 github.com/jfrog/build-info-go v1.9.21/go.mod h1:Vxv6zmx4e1NWsx40OHaDWCCYDeYAq2yXzpJ4nsDChbE= github.com/jfrog/gofrog v1.5.1 h1:2AXL8hHu1jJFMIoCqTp2OyRUfEqEp4nC7J8fwn6KtwE= github.com/jfrog/gofrog v1.5.1/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg= -github.com/jfrog/jfrog-client-go v1.36.0 h1:iODLDjYSlK7rLH8/lEmAFHwYsboeBfaqxXybz6waraE= -github.com/jfrog/jfrog-client-go v1.36.0/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU= +github.com/jfrog/jfrog-client-go v1.28.1-0.20240201133918-82ad9eb51c3f h1:mbWuP+LpyOKJI7FLFdauGG0SEQQ6KcoA4CwOAgsiYg8= +github.com/jfrog/jfrog-client-go v1.28.1-0.20240201133918-82ad9eb51c3f/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= diff --git a/lifecycle/common.go b/lifecycle/common.go index 55e7ef771..e185cb578 100644 --- a/lifecycle/common.go +++ b/lifecycle/common.go @@ -19,7 +19,8 @@ type releaseBundleCmd struct { rbProjectKey string } -func (rbc *releaseBundleCmd) getPrerequisites() (servicesManager *lifecycle.LifecycleServicesManager, rbDetails services.ReleaseBundleDetails, params services.CreateOrPromoteReleaseBundleParams, err error) { +func (rbc *releaseBundleCmd) getPrerequisites() (servicesManager *lifecycle.LifecycleServicesManager, + rbDetails services.ReleaseBundleDetails, queryParams services.CommonOptionalQueryParams, err error) { servicesManager, err = utils.CreateLifecycleServiceManager(rbc.serverDetails, false) if err != nil { return @@ -28,12 +29,9 @@ func (rbc *releaseBundleCmd) getPrerequisites() (servicesManager *lifecycle.Life ReleaseBundleName: rbc.releaseBundleName, ReleaseBundleVersion: rbc.releaseBundleVersion, } - params = services.CreateOrPromoteReleaseBundleParams{ - ReleaseBundleQueryParams: services.ReleaseBundleQueryParams{ - ProjectKey: rbc.rbProjectKey, - Async: !rbc.sync, - }, - SigningKeyName: rbc.signingKeyName, + queryParams = services.CommonOptionalQueryParams{ + ProjectKey: rbc.rbProjectKey, + Async: !rbc.sync, } return } diff --git a/lifecycle/createcommon.go b/lifecycle/createcommon.go index 5149a82a7..4d5fba599 100644 --- a/lifecycle/createcommon.go +++ b/lifecycle/createcommon.go @@ -67,13 +67,13 @@ func (rbc *ReleaseBundleCreateCommand) Run() error { return err } - servicesManager, rbDetails, params, err := rbc.getPrerequisites() + servicesManager, rbDetails, queryParams, err := rbc.getPrerequisites() if err != nil { return err } if rbc.buildsSpecPath != "" { - return rbc.createFromBuilds(servicesManager, rbDetails, params) + return rbc.createFromBuilds(servicesManager, rbDetails, queryParams) } - return rbc.createFromReleaseBundles(servicesManager, rbDetails, params) + return rbc.createFromReleaseBundles(servicesManager, rbDetails, queryParams) } diff --git a/lifecycle/createfrombuilds.go b/lifecycle/createfrombuilds.go index f9a13ed2e..26cf0e0a2 100644 --- a/lifecycle/createfrombuilds.go +++ b/lifecycle/createfrombuilds.go @@ -12,7 +12,7 @@ import ( ) func (rbc *ReleaseBundleCreateCommand) createFromBuilds(servicesManager *lifecycle.LifecycleServicesManager, - rbDetails services.ReleaseBundleDetails, params services.CreateOrPromoteReleaseBundleParams) error { + rbDetails services.ReleaseBundleDetails, queryParams services.CommonOptionalQueryParams) error { builds := CreateFromBuildsSpec{} content, err := fileutils.ReadFile(rbc.buildsSpecPath) @@ -31,7 +31,7 @@ func (rbc *ReleaseBundleCreateCommand) createFromBuilds(servicesManager *lifecyc if err != nil { return err } - return servicesManager.CreateReleaseBundleFromBuilds(rbDetails, params, buildsSource) + return servicesManager.CreateReleaseBundleFromBuilds(rbDetails, queryParams, rbc.signingKeyName, buildsSource) } func (rbc *ReleaseBundleCreateCommand) convertToBuildsSource(builds CreateFromBuildsSpec) (services.CreateFromBuildsSource, error) { diff --git a/lifecycle/createfrombundles.go b/lifecycle/createfrombundles.go index 872d76765..1e9253351 100644 --- a/lifecycle/createfrombundles.go +++ b/lifecycle/createfrombundles.go @@ -9,7 +9,7 @@ import ( ) func (rbc *ReleaseBundleCreateCommand) createFromReleaseBundles(servicesManager *lifecycle.LifecycleServicesManager, - rbDetails services.ReleaseBundleDetails, params services.CreateOrPromoteReleaseBundleParams) error { + rbDetails services.ReleaseBundleDetails, queryParams services.CommonOptionalQueryParams) error { bundles := CreateFromReleaseBundlesSpec{} content, err := fileutils.ReadFile(rbc.releaseBundlesSpecPath) @@ -25,7 +25,7 @@ func (rbc *ReleaseBundleCreateCommand) createFromReleaseBundles(servicesManager } releaseBundlesSource := rbc.convertToReleaseBundlesSource(bundles) - return servicesManager.CreateReleaseBundleFromBundles(rbDetails, params, releaseBundlesSource) + return servicesManager.CreateReleaseBundleFromBundles(rbDetails, queryParams, rbc.signingKeyName, releaseBundlesSource) } func (rbc *ReleaseBundleCreateCommand) convertToReleaseBundlesSource(bundles CreateFromReleaseBundlesSpec) services.CreateFromReleaseBundlesSource { diff --git a/lifecycle/promote.go b/lifecycle/promote.go index 6958bae5a..0cf8b64d0 100644 --- a/lifecycle/promote.go +++ b/lifecycle/promote.go @@ -3,14 +3,16 @@ package lifecycle import ( "encoding/json" "github.com/jfrog/jfrog-cli-core/v2/utils/config" + "github.com/jfrog/jfrog-client-go/lifecycle/services" "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/log" ) type ReleaseBundlePromoteCommand struct { releaseBundleCmd - environment string - overwrite bool + environment string + includeReposPatterns []string + excludeReposPatterns []string } func NewReleaseBundlePromoteCommand() *ReleaseBundlePromoteCommand { @@ -52,8 +54,13 @@ func (rbp *ReleaseBundlePromoteCommand) SetEnvironment(environment string) *Rele return rbp } -func (rbp *ReleaseBundlePromoteCommand) SetOverwrite(overwrite bool) *ReleaseBundlePromoteCommand { - rbp.overwrite = overwrite +func (rbp *ReleaseBundlePromoteCommand) SetIncludeReposPatterns(includeReposPatterns []string) *ReleaseBundlePromoteCommand { + rbp.includeReposPatterns = includeReposPatterns + return rbp +} + +func (rbp *ReleaseBundlePromoteCommand) SetExcludeReposPatterns(excludeReposPatterns []string) *ReleaseBundlePromoteCommand { + rbp.excludeReposPatterns = excludeReposPatterns return rbp } @@ -70,12 +77,18 @@ func (rbp *ReleaseBundlePromoteCommand) Run() error { return err } - servicesManager, rbDetails, params, err := rbp.getPrerequisites() + servicesManager, rbDetails, queryParams, err := rbp.getPrerequisites() if err != nil { return err } - promotionResp, err := servicesManager.PromoteReleaseBundle(rbDetails, params, rbp.environment, rbp.overwrite) + promotionParams := services.RbPromotionParams{ + Environment: rbp.environment, + IncludedRepositoryKeys: rbp.includeReposPatterns, + ExcludedRepositoryKeys: rbp.excludeReposPatterns, + } + + promotionResp, err := servicesManager.PromoteReleaseBundle(rbDetails, queryParams, rbp.signingKeyName, promotionParams) if err != nil { return err }