Skip to content

Commit

Permalink
Artifactory Release Lifecycle Management - Add Import bundle function (
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea authored Apr 8, 2024
1 parent 3df49e9 commit 13680c0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 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.20240403100335-8292671b7cc4
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240408071430-62ee0279ac58

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/jfrog/build-info-go v1.9.25 h1:IkjydGQA/HjOWjRaoKq1hOEgCCyBEJwQgXJSo4
github.com/jfrog/build-info-go v1.9.25/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.20240403100335-8292671b7cc4 h1:A67yoFRYjRzg+xhLYhH0QN7b4/wggRa/lSQKSjzOwNQ=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240403100335-8292671b7cc4/go.mod h1:tUyEmxznphh0nwAGo6xz9Sps7RRW/TBMxIJZteo+j2k=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240408071430-62ee0279ac58 h1:yyhOfECY3WGs6MsnJQWm/U7DYNIzxBiVlEwQ3RvqxwQ=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240408071430-62ee0279ac58/go.mod h1:tUyEmxznphh0nwAGo6xz9Sps7RRW/TBMxIJZteo+j2k=
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
60 changes: 60 additions & 0 deletions lifecycle/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package lifecycle

import (
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"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_import"
}

func NewReleaseBundleImportCommand() *ReleaseBundleImportCommand {
return &ReleaseBundleImportCommand{}
}
func (rbi *ReleaseBundleImportCommand) SetServerDetails(serverDetails *config.ServerDetails) *ReleaseBundleImportCommand {
rbi.serverDetails = serverDetails
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 {
return
}
artService, err := utils.CreateServiceManager(rbi.serverDetails, 3, 0, false)
if err != nil {
return
}

exists, err := fileutils.IsFileExists(rbi.filePath, false)
if err != nil {
return
}
if !exists {
return fmt.Errorf("file not found: %s", rbi.filePath)
}

log.Info("Importing the release bundle archive...")
if err = artService.ImportReleaseBundle(rbi.filePath); err != nil {
return
}
log.Info("Successfully imported the release bundle archive")
return
}

0 comments on commit 13680c0

Please sign in to comment.