-
Notifications
You must be signed in to change notification settings - Fork 240
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
Enhance download functionality to support RBV2 #2805
base: dev
Are you sure you want to change the base?
Conversation
004bebb
to
935dc22
Compare
935dc22
to
5eddf64
Compare
artifactory/cli.go
Outdated
if c.IsSet("bundle") { | ||
isRbv2, err = checkRbExistenceInV2(c) | ||
} | ||
//if the command contains --bundle and the bundle found in rbv2, we will download from rbv2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the bundle is not in V2? the download commands continues as it as?
And also this is a generic download code with too much RBV2 references, maybe we should extract some logic to a one liner function to avoid it.
I would move this logic inside the prepareDownloadCommand
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is:
if we have the same rb-name in both rbv1 and rbv2 - we will take rbv2.
if the cmd dose not contain --bundle , it will remain as it is.
moved the logic.
go.mod
Outdated
@@ -168,6 +168,10 @@ require ( | |||
gopkg.in/yaml.v3 v3.0.1 // indirect | |||
) | |||
|
|||
replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice to change replaces before pushing :)
5eddf64
to
eafc54a
Compare
eafc54a
to
7d9b52b
Compare
7d9b52b
to
c28b293
Compare
a94debd
to
4212def
Compare
4212def
to
1f1b004
Compare
1f1b004
to
8b5d83f
Compare
8b5d83f
to
c3a69e0
Compare
c3a69e0
to
8af902a
Compare
8af902a
to
5e2bcdd
Compare
artifactory/cli.go
Outdated
if c.IsSet("spec") { | ||
downloadSpec, err = cliutils.GetSpec(c, true, true) | ||
} else { | ||
downloadSpec, err = createDefaultDownloadSpec(c) | ||
if c.IsSet("bundle") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this check from here and insert this logic inside the createDefaultDownloadSpec
function. Since the context is already passed to the function, it can be checked inside.
artifactory_test.go
Outdated
func TestReleaseBundleImportOnPrem(t *testing.T) { | ||
// Cleanup | ||
defer func() { | ||
deleteReceivedReleaseBundle(t, "cli-tests", "2") | ||
deleteReceivedReleaseBundle(t, "artifactory/api/release/bundles/", "cli-tests", "2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the URLs constants with meaningful names so we understand their purposes? The same applies to the URL on line 247.
artifactory_test.go
Outdated
assert.NoError(t, err) | ||
|
||
// Download RBV2 | ||
err = artifactoryCli.Exec([]string{"download", "--bundle=" + tests.LcRbName1 + "/" + buildNumber}...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also verify the download succeeded and not just failed? maybe check the existence of the file ?
5e2bcdd
to
6a8be59
Compare
6a8be59
to
085055a
Compare
artifactory/cli.go
Outdated
return spec.NewBuilder(). | ||
Pattern(strings.TrimPrefix(c.Args().Get(0), "/")). | ||
Pattern(source). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put all the source logic inside a function that will also explain why it should be different?
Something like this:
func getSourcePattern(c *cli.Context) (string, error) {
if c.IsSet("bundle") {
isRbv2, err := checkRbExistenceInV2(c)
if err != nil {
log.Debug("Error occurred while checking if the bundle exists in rbv2:", err.Error())
} else if isRbv2 {
return buildSourceForRbv2(c)
}
}
return strings.TrimPrefix(c.Args().Get(0), "/"), nil
}
then the line will look like this:
return spec.NewBuilder().
Pattern(getSourcePattern(c)).
@oshratZairi looks good! Just to extract the last function and fix the static check and we are good to go 👍 |
085055a
to
d9f618f
Compare
offset, limit, err := getOffsetAndLimitValues(c) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could also move inside the getSourcePattern
function
d9f618f
to
02b64fd
Compare
dev
branch.go vet ./...
.go fmt ./...
.Enhance download functionality to support RBV2