Skip to content

Commit

Permalink
Artifactory Release Lifecycle Management - Modify release bundle prom…
Browse files Browse the repository at this point in the history
…otion properties (#1121)
  • Loading branch information
RobiNino authored Feb 1, 2024
1 parent 6997ffa commit db7eee2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 5 additions & 7 deletions lifecycle/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions lifecycle/createcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions lifecycle/createfrombuilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions lifecycle/createfrombundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
25 changes: 19 additions & 6 deletions lifecycle/promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down

0 comments on commit db7eee2

Please sign in to comment.