Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artifactory Release Lifecycle Management - Add Import bundle function #1153

Merged
merged 19 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.20240320102352-af2f392bb490
replace github.com/jfrog/jfrog-client-go => github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20240320110623-caee2e79e94b

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240319160313-0093dee91fc1

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdf
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20240320110623-caee2e79e94b h1:8jtFK0maAqV+bGn8Iv2I22AmRvJzNkEJ9xkdHthwSS0=
github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20240320110623-caee2e79e94b/go.mod h1:8z6in1qalzL1DqchUCrDKVgz2gKoPRhJpzm2Ww+VWYI=
github.com/forPelevin/gomoji v1.1.8 h1:JElzDdt0TyiUlecy6PfITDL6eGvIaxqYH1V52zrd0qQ=
github.com/forPelevin/gomoji v1.1.8/go.mod h1:8+Z3KNGkdslmeGZBC3tCrwMrcPy5GRzAD+gL9NAwMXg=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
Expand Down Expand Up @@ -87,8 +89,6 @@ github.com/jfrog/build-info-go v1.8.9-0.20240319160313-0093dee91fc1 h1:au9aqxUQI
github.com/jfrog/build-info-go v1.8.9-0.20240319160313-0093dee91fc1/go.mod h1:doFB4bFDVHeGulD6GF9LzsrRaIOrSoklV9DgIAEqHgc=
github.com/jfrog/gofrog v1.6.3 h1:F7He0+75HcgCe6SGTSHLFCBDxiE2Ja0tekvvcktW6wc=
github.com/jfrog/gofrog v1.6.3/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240320102352-af2f392bb490 h1:oGgwRJatirSNZyqO3e4FtHCe5W30VNgULCW/GYhHdao=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240320102352-af2f392bb490/go.mod h1:8z6in1qalzL1DqchUCrDKVgz2gKoPRhJpzm2Ww+VWYI=
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
49 changes: 49 additions & 0 deletions lifecycle/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package lifecycle

import (
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/utils/log"
)

type ReleaseBundleImportCommand struct {
releaseBundleCmd
filePath string
}

func (rbi *ReleaseBundleImportCommand) ServerDetails() (*config.ServerDetails, error) {
return rbi.serverDetails, nil
}

func (rbi *ReleaseBundleImportCommand) CommandName() string {
return "rb_export"
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
}

func NewReleaseBundleImportCommand() *ReleaseBundleImportCommand {
return &ReleaseBundleImportCommand{}
}
func (rbi *ReleaseBundleImportCommand) SetServerDetails(serverDetails *config.ServerDetails) *ReleaseBundleImportCommand {
rbi.serverDetails = serverDetails
rbi.releaseBundleCmd.serverDetails = serverDetails
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
return rbi
}

func (rbi *ReleaseBundleImportCommand) SetFilepath(filePath string) *ReleaseBundleImportCommand {
rbi.filePath = filePath
return rbi
}

func (rbi *ReleaseBundleImportCommand) Run() (err error) {
if err = validateArtifactoryVersionSupported(rbi.serverDetails); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can consider setting the supported version to the one that will include the fix, for this command only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added a function that will check if it is cloud platform, but what do you suggest about the version constraint? there is guarantee that it will be fixed the next patch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with checking whether the instance is a cloud is that it requires admin privileges, which is not a constraint we would like to set.
To be on the safe side, I would suggest to keep the command hidden till the patch is officially out, then exposing it with the same minimal version for both cloud and self hosted.

return
}
artService, err := createArtifactoryServiceManager(rbi.serverDetails)
if err != nil {
return
}
log.Info("Importing Release Bundle Archive...")
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
if err = artService.ReleaseBundleImport(rbi.filePath); err != nil {
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
return
}
log.Info("Successfully Imported Release Bundle archive")
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
return
}
Loading