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 command #2472

Merged
merged 42 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8e19e74
add import command
EyalDelarea Mar 11, 2024
63cef5d
Merge branch 'dev' into rb-import
EyalDelarea Mar 12, 2024
04bc171
pull dev
EyalDelarea Mar 20, 2024
a3b1dc3
pull dev
EyalDelarea Mar 20, 2024
fa188aa
update deps
EyalDelarea Mar 20, 2024
6e55da9
CR part 1
EyalDelarea Mar 21, 2024
19b9f0b
Add hidden import test
EyalDelarea Mar 21, 2024
7397135
prepare import test to enable in the future
EyalDelarea Mar 21, 2024
404c87b
add custom name test
EyalDelarea Mar 21, 2024
91bb97e
comment out tests
EyalDelarea Mar 21, 2024
475fabe
update deps
EyalDelarea Mar 21, 2024
f95e52c
hide command
EyalDelarea Mar 21, 2024
d9c2fa1
pull dev
EyalDelarea Mar 25, 2024
f0a762f
update deps
EyalDelarea Mar 25, 2024
9f55350
test local art test
EyalDelarea Mar 25, 2024
7f61965
change to run cli
EyalDelarea Mar 25, 2024
83e99f3
fix test
EyalDelarea Mar 25, 2024
e422fda
fix test
EyalDelarea Mar 25, 2024
c612937
fix test
EyalDelarea Mar 25, 2024
ed6905b
fix test
EyalDelarea Mar 25, 2024
1b8c741
fix test
EyalDelarea Mar 25, 2024
54171eb
remove signature
EyalDelarea Mar 25, 2024
21c29ca
fix files
EyalDelarea Mar 25, 2024
9d8bc28
test
EyalDelarea Mar 26, 2024
caa7817
remove test
EyalDelarea Mar 26, 2024
53c2ad5
test
EyalDelarea Mar 26, 2024
767caba
Update deps
EyalDelarea Mar 27, 2024
32eb371
pull dev
EyalDelarea Mar 27, 2024
2585048
add test
EyalDelarea Mar 28, 2024
4d2f898
add bundle
EyalDelarea Mar 28, 2024
f8e7070
delete old bundle
EyalDelarea Mar 28, 2024
8acaef0
Fix delete bundle for tests
EyalDelarea Apr 7, 2024
1c482c8
pull dev
EyalDelarea Apr 7, 2024
3c1e698
update go mod
EyalDelarea Apr 7, 2024
f842f71
replace consts
EyalDelarea Apr 7, 2024
69bbcbf
update deps
EyalDelarea Apr 7, 2024
0aebeec
CR
EyalDelarea Apr 7, 2024
ec6ea8d
static check fix
EyalDelarea Apr 7, 2024
ef8b570
CR
EyalDelarea Apr 7, 2024
690e6bf
throw error when file not found
EyalDelarea Apr 7, 2024
c6e6343
update deps
EyalDelarea Apr 7, 2024
9518d35
Update deps
EyalDelarea Apr 8, 2024
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
13 changes: 13 additions & 0 deletions docs/lifecycle/importbundle/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package importbundle

var Usage = []string{"rbi [command options] <path to bundle>"}
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved

func GetDescription() string {
return "Import a Release Bundle archive"
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
}

func GetArguments() string {
return ` path to bundle
Path for the desired imported bundle
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
`
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240320104952-b5807fd0102d
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/eyaldelarea/jfrog-cli-core/v2 v2.0.0-20240320111241-791602b8384c

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 dev

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ 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-cli-core/v2 v2.0.0-20240320111241-791602b8384c h1:RhpxHS2taMNKidLT8HkK0nybh5a6+Wp5bDa1hhqdCVo=
github.com/eyaldelarea/jfrog-cli-core/v2 v2.0.0-20240320111241-791602b8384c/go.mod h1:zFSoWiE3TulQvpOA222I2IhccOjjJ6C80sPzYnG2Cng=
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/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/forPelevin/gomoji v1.1.8 h1:JElzDdt0TyiUlecy6PfITDL6eGvIaxqYH1V52zrd0qQ=
Expand Down Expand Up @@ -135,12 +139,8 @@ 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-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240320104952-b5807fd0102d h1:DEMgTYNfXlJbrTjBWOJo1twLGTztJJ26RFZhL6J1u/Q=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240320104952-b5807fd0102d/go.mod h1:XZP7fmNBBoieQTUE2p2mvA8h/CFO5z4PE7KW1s2cdNk=
github.com/jfrog/jfrog-cli-security v1.0.4 h1:wJwvpaozhzvMCwJA/puU5jQCnjFPqMUeZAntndgYuB0=
github.com/jfrog/jfrog-cli-security v1.0.4/go.mod h1:jtRSzr/E2s7LnwUzKX5w4vtJxHFHCKGmuo8qm8HSy2o=
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/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI=
github.com/jszwec/csvutil v1.10.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
29 changes: 29 additions & 0 deletions lifecycle/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
rbDeleteRemote "github.com/jfrog/jfrog-cli/docs/lifecycle/deleteremote"
rbDistribute "github.com/jfrog/jfrog-cli/docs/lifecycle/distribute"
rbExport "github.com/jfrog/jfrog-cli/docs/lifecycle/export"
rbImport "github.com/jfrog/jfrog-cli/docs/lifecycle/importbundle"
rbPromote "github.com/jfrog/jfrog-cli/docs/lifecycle/promote"
"github.com/jfrog/jfrog-cli/utils/cliutils"
"github.com/jfrog/jfrog-cli/utils/distribution"
Expand Down Expand Up @@ -102,6 +103,18 @@ func GetCommands() []cli.Command {
Category: lcCategory,
Action: deleteRemote,
},
{
Name: "release-bundle-import",
Aliases: []string{"rbi"},
Flags: cliutils.GetCommandFlags(cliutils.ReleaseBundleImport),
Usage: rbImport.GetDescription(),
HelpName: coreCommon.CreateUsage("rbi", rbImport.GetDescription(), rbImport.Usage),
UsageText: rbImport.GetArguments(),
ArgsUsage: common.CreateEnvVars(),
BashComplete: coreCommon.CreateBashCompletionFunc(),
Category: lcCategory,
Action: releaseBundleImport,
},
})
}

Expand Down Expand Up @@ -296,6 +309,22 @@ func export(c *cli.Context) error {
return commands.Exec(exportCmd)
}

func releaseBundleImport(c *cli.Context) error {
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
lcDetails, err := createLifecycleDetailsByFlags(c)
if err != nil {
return err
}
importCmd := lifecycle.NewReleaseBundleImportCommand()
if err != nil {
return err
}
importCmd.
SetServerDetails(lcDetails).
SetFilepath(c.Args().Get(0))

return commands.Exec(importCmd)
}

func validateDistributeCommand(c *cli.Context) error {
if err := distribution.ValidateReleaseBundleDistributeCmd(c); err != nil {
return err
Expand Down
16 changes: 16 additions & 0 deletions lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func TestLifecycleFullFlow(t *testing.T) {
exportRb(t, tests.LcRbName2, number2, tempDir)
defer deleteExportedReleaseBundle(t, tests.LcRbName2)

// Test import
importRb(t, tests.LcRbName2, number2)
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved

// TODO Temporarily disabling till distribution on testing suite is stable.
/*
distributeRb(t)
Expand Down Expand Up @@ -446,6 +449,19 @@ func sendGpgKeyPair() {
coreutils.ExitOnErr(errorutils.CheckResponseStatusWithBody(resp, body, http.StatusCreated))
}

func importRb(t *testing.T, rbName, rbVersion string) {
wd, err := os.Getwd()
assert.NoError(t, err)
exportedFileName := rbName + "-" + rbVersion + ".zip"
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
exportedFilePath := path.Join(wd, rbName, rbVersion, exportedFileName)
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
output := lcCli.RunCliCmdWithOutput(t, "rbi", exportedFilePath)
var importResp string
if !assert.NoError(t, json.Unmarshal([]byte(output), &importResp)) {
return
}
assert.Equal(t, "", importResp)
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
}

type KeyPairPayload struct {
PairName string `json:"pairName,omitempty"`
PairType string `json:"pairType,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions utils/cliutils/commandsflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const (
ReleaseBundleDeleteLocal = "release-bundle-delete-local"
ReleaseBundleDeleteRemote = "release-bundle-delete-remote"
ReleaseBundleExport = "release-bundle-export"
ReleaseBundleImport = "release-bundle-import"

// Access Token Create commands keys
AccessTokenCreate = "access-token-create"
Expand Down Expand Up @@ -2024,6 +2025,9 @@ var commandFlags = map[string][]string{
platformUrl, user, password, accessToken, serverId, lcPathMappingTarget, lcPathMappingPattern, Project,
downloadMinSplit, downloadSplitCount,
},
ReleaseBundleImport: {
user, password, accessToken, serverId, lcDryRun,
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
},
// Mission Control's commands
McConfig: {
mcUrl, mcAccessToken, mcInteractive,
Expand Down
Loading