Skip to content

Commit

Permalink
empty archive
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <michaelsv@jfrog.com>
  • Loading branch information
sverdlov93 committed Feb 8, 2024
1 parent 23ece04 commit 1f9b54c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
28 changes: 28 additions & 0 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4204,6 +4204,34 @@ func TestUploadZipAndCheckDeploymentViewWithArchive(t *testing.T) {

}

func TestUploadEmptyArchiveWhehEmptyArchiveEnvSelected(t *testing.T) {
initArtifactoryTest(t, "")

// Create tmp dir
assert.NoError(t, os.Mkdir(tests.Out, 0755))
wd, err := os.Getwd()
assert.NoError(t, err)
defer cleanArtifactoryTest()
chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, tests.Out)
defer chdirCallback()

// Create file and a zip
zipName := "test.zip"

setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_CLI_UPLOAD_EMPTY_ARCHIVE", "true")
defer setEnvCallBack()

// Upload & download zip file
assert.NoError(t, artifactoryCli.Exec("upload", "NonExistingPatttern/*", path.Join(tests.RtRepo1, zipName), "--archive", "zip"))
assert.NoError(t, artifactoryCli.Exec("download", path.Join(tests.RtRepo1, zipName)))

// Check that the zip file uploaded and it's empty
r, err := zip.OpenReader(zipName)
assert.NoError(t, err)
defer func() { assert.NoError(t, r.Close()) }()
assert.Empty(t, r.File)
}

func TestUploadDetailedSummary(t *testing.T) {
initArtifactoryTest(t, "")
uploadCmd := generic.NewUploadCommand()
Expand Down
2 changes: 1 addition & 1 deletion docs/artifactory/upload/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/jfrog/jfrog-cli/docs/common"
var Usage = []string{"rt u [command options] <source pattern> <target pattern>",
"rt u --spec=<File Spec path> [command options]"}

var EnvVar = []string{common.JfrogCliMinChecksumDeploySizeKb, common.JfrogCliFailNoOp}
var EnvVar = []string{common.JfrogCliMinChecksumDeploySizeKb, common.JfrogCliFailNoOp, common.JfrogCliUploadEmptyArchive}

func GetDescription() string {
return "Upload files."
Expand Down
5 changes: 5 additions & 0 deletions docs/common/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const (
Set to true if you'd like the command to return exit code 2 in case of no files are affected.
Support by the following commands: copy, delete, delete-props, set-props, download, move, search and upload`

JfrogCliUploadEmptyArchive = ` JFROG_CLI_UPLOAD_EMPTY_ARCHIVE
[Default: false]
Set to true if you'd like to upload an empty archive when '--archive' is set but no files are matched by the upload pattern. `

JfrogCliEncryptionKey = ` JFROG_CLI_ENCRYPTION_KEY
If provided, encrypt the sensitive data stored in the config with the provided key. Must be exactly 32 characters.`

Expand Down Expand Up @@ -119,6 +123,7 @@ func GetGlobalEnvVars() string {
JfrogCliReleasesRepo,
JfrogCliDependenciesDir,
JfrogCliMinChecksumDeploySizeKb,
JfrogCliUploadEmptyArchive,
JfrogCliBuildUrl,
JfrogCliEnvExclude,
JfrogCliFailNoOp,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,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.20240204105703-557f7a17d7f9
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20240208120441-21d747ed83b2

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df
replace github.com/jfrog/jfrog-client-go => github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240208113649-35aca6a22b15

// replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security v0.0.0-20240122124933-edf9cb4ca3ac

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,8 @@ 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-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.20240204105703-557f7a17d7f9 h1:rBtOFiF7YRdnC8dzMHVXUc/9d0y+W0iZ7iHQb9ur2qQ=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240204105703-557f7a17d7f9/go.mod h1:+eraSKhahQf7tj09+g3rAA2Z+XPnZGfMc0y8uUDecZw=
github.com/jfrog/jfrog-cli-security v0.0.0-20240122124933-edf9cb4ca3ac h1:tNn3TQXaIJZ9Fu5jiVB9lWpJAKkEGWNjz/6WzHhHePI=
github.com/jfrog/jfrog-cli-security v0.0.0-20240122124933-edf9cb4ca3ac/go.mod h1:X4rz1639L8vWKJgpLxpO3ddkIW7KaCaQjbwani7FPf4=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df h1:7yQ7m0N3AQNqGnymRP+Fka6FZCEYr9GzkTbVkUcxwtQ=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU=
github.com/jszwec/csvutil v1.9.0 h1:iTmq9G1P0e+AUq/MkFg6tetJ+1BH3fOX8Xi0RAcwiGc=
github.com/jszwec/csvutil v1.9.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down Expand Up @@ -259,6 +255,10 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20240208120441-21d747ed83b2 h1:tjVjMvOa1a8Ap6wknQSfXTcL+uYY9mWa1EXRPUWNjOw=
github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20240208120441-21d747ed83b2/go.mod h1:KSP41pqi9Z+hj9H6i8wbjlixqE5cftznCQvTYbzL5K0=
github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240208113649-35aca6a22b15 h1:v0Qo8FbI4sut42OiTz6pIrFmAr7d7CCaTiqGEOpnFHI=
github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240208113649-35aca6a22b15/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU=
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
github.com/testcontainers/testcontainers-go v0.23.0 h1:ERYTSikX01QczBLPZpqsETTBO7lInqEP349phDOVJVs=
github.com/testcontainers/testcontainers-go v0.23.0/go.mod h1:3gzuZfb7T9qfcH2pHpV4RLlWrPjeWNQah6XlYQ32c4I=
Expand Down

0 comments on commit 1f9b54c

Please sign in to comment.