diff --git a/distribution_test.go b/distribution_test.go index 62cbea526..5c5d12869 100644 --- a/distribution_test.go +++ b/distribution_test.go @@ -445,7 +445,7 @@ func TestUpdateBundleProps(t *testing.T) { cleanDistributionTest(t) } -func TestBundlePathMapping(t *testing.T) { +func TestBundlePathMappingFromPatternAndTarget(t *testing.T) { initDistributionTest(t) // Upload files @@ -465,6 +465,28 @@ func TestBundlePathMapping(t *testing.T) { cleanDistributionTest(t) } +func TestBundlePathMappingFromPatternAndTargetUsingSpec(t *testing.T) { + initDistributionTest(t) + + // Upload files + specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB) + assert.NoError(t, err) + runRt(t, "u", "--spec="+specFile) + + // Create and distribute release bundle with path mapping from /data/ to /target/ + spec, err := tests.CreateSpec(tests.DistributionCreateWithPatternAndTarget) + assert.NoError(t, err) + runDs(t, "rbc", tests.BundleName, bundleVersion, "--sign", "--spec="+spec) + runDs(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync") + + // Validate files are distributed to the target mapping + spec, err = tests.CreateSpec(tests.DistributionMappingDownload) + assert.NoError(t, err) + inttestutils.VerifyExistInArtifactory(tests.GetBundleMappingExpected(), spec, serverDetails, t) + + cleanDistributionTest(t) +} + func TestBundlePathMappingUsingSpec(t *testing.T) { initDistributionTest(t) diff --git a/go.mod b/go.mod index 7fe0e0330..f15100835 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,10 @@ module github.com/jfrog/jfrog-cli go 1.20 +replace github.com/jfrog/jfrog-client-go => github.com/YardenEdery/jfrog-client-go v1.28.1-0.20231119162547-c7934b968a7b + +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/YardenEdery/jfrog-cli-core/v2 v2.31.1-0.20231119163439-e62d1686d107 + require ( github.com/agnivade/levenshtein v1.1.1 github.com/buger/jsonparser v1.1.1 @@ -9,8 +13,8 @@ require ( github.com/gocarina/gocsv v0.0.0-20230616125104-99d496ca653d github.com/jfrog/build-info-go v1.9.15 github.com/jfrog/gofrog v1.3.1 - github.com/jfrog/jfrog-cli-core/v2 v2.46.1 - github.com/jfrog/jfrog-client-go v1.34.5 + github.com/jfrog/jfrog-cli-core/v2 v2.0.0-00010101000000-000000000000 + github.com/jfrog/jfrog-client-go v0.0.0-00010101000000-000000000000 github.com/jszwec/csvutil v1.8.0 github.com/mholt/archiver/v3 v3.5.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index a1346db72..7fb63d326 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,10 @@ github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= +github.com/YardenEdery/jfrog-cli-core/v2 v2.31.1-0.20231119163439-e62d1686d107 h1:YVNeBLl3EcNc/UrPJ6NnbC0Vcr+afpoDzUuglCf7zaM= +github.com/YardenEdery/jfrog-cli-core/v2 v2.31.1-0.20231119163439-e62d1686d107/go.mod h1:zAPvo53r2mzdbfiBmUht0eQYGPCKVpU+cUCybHfjUDw= +github.com/YardenEdery/jfrog-client-go v1.28.1-0.20231119162547-c7934b968a7b h1:dulhOrezvLTRvnypeaVRSC7/I/LJaYvRrg3QPTZ2lXI= +github.com/YardenEdery/jfrog-client-go v1.28.1-0.20231119162547-c7934b968a7b/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= @@ -243,10 +247,6 @@ github.com/jfrog/gofrog v1.3.1 h1:QqAwQXCVReT724uga1AYqG/ZyrNQ6f+iTxmzkb+YFQk= github.com/jfrog/gofrog v1.3.1/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= 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.46.1 h1:4bkyykJk9OUJFXW44NmYGlOmhu6HVG43KUtY5p/wsQA= -github.com/jfrog/jfrog-cli-core/v2 v2.46.1/go.mod h1:S+KpcxVw9O3jY1KtzvbFtnejinc4GgbykQNhLLtfR8I= -github.com/jfrog/jfrog-client-go v1.34.5 h1:NYZrOHvT5D5BwwHdArIz5WnbP+DPbADjV/SPdN33bfQ= -github.com/jfrog/jfrog-client-go v1.34.5/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= diff --git a/schema/filespec-schema.json b/schema/filespec-schema.json index ef325c155..7b4d0912c 100644 --- a/schema/filespec-schema.json +++ b/schema/filespec-schema.json @@ -42,6 +42,19 @@ } } }, + "mappings": { + "description": "If specified, determines release-bundle source and target metadata for artifacts that had been fetched using aql", + "properties": { + "input": { + "type": "string", + "description": "The input path for mapping." + }, + "output": { + "type": "string", + "description": "The output path for mapping." + } + } + }, "archive": { "type": "string", "enum": ["zip"], @@ -227,6 +240,7 @@ ] } }, + "mappings": { "required": ["aql"] }, "build": { "not": { "required": ["bundle", "limit", "offset"] } }, "bundle": { "not": { "required": ["build", "limit", "offset"] } }, "excludeArtifacts": { "required": ["build"] }, diff --git a/testdata/filespecs/dist_create_with_mapping.json b/testdata/filespecs/dist_create_with_mapping.json index 98502d1d9..abe25131b 100644 --- a/testdata/filespecs/dist_create_with_mapping.json +++ b/testdata/filespecs/dist_create_with_mapping.json @@ -1,8 +1,20 @@ { "files": [ { - "pattern": "${DIST_REPO1}/data/(*)", - "target": "${DIST_REPO2}/target/{1}" + "aql": { + "items.find": { + "repo": "${DIST_REPO1}", + "path": "data", + "$or": [ + { + "name": { + "$match": "*" + } + } + ] + } + }, + "mappings": { "input": "${DIST_REPO1}/data/(.*)", "output": "${DIST_REPO2}/target/$1" } } ] -} +} \ No newline at end of file diff --git a/testdata/filespecs/dist_create_with_pattern_and_target.json b/testdata/filespecs/dist_create_with_pattern_and_target.json new file mode 100644 index 000000000..98502d1d9 --- /dev/null +++ b/testdata/filespecs/dist_create_with_pattern_and_target.json @@ -0,0 +1,8 @@ +{ + "files": [ + { + "pattern": "${DIST_REPO1}/data/(*)", + "target": "${DIST_REPO2}/target/{1}" + } + ] +} diff --git a/testdata/go/projectmissingdependency/projectmissingdependecy.go b/testdata/go/projectmissingdependency/projectmissingdependecy.go index 30c5ed4ce..b59c02118 100644 --- a/testdata/go/projectmissingdependency/projectmissingdependecy.go +++ b/testdata/go/projectmissingdependency/projectmissingdependecy.go @@ -12,4 +12,4 @@ func execDependency() { func Exec() { fmt.Println("Executing ") execDependency() -} \ No newline at end of file +} diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index e101b863c..94d888400 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "github.com/jfrog/gofrog/version" + "github.com/jfrog/jfrog-client-go/utils/log" "io" "net/http" "os" @@ -26,7 +27,6 @@ import ( clientutils "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/io/content" - "github.com/jfrog/jfrog-client-go/utils/log" "github.com/urfave/cli" ) diff --git a/utils/tests/consts.go b/utils/tests/consts.go index b6e99dc77..d5bdb80b8 100644 --- a/utils/tests/consts.go +++ b/utils/tests/consts.go @@ -42,6 +42,7 @@ const ( DelSpecExclusions = "delete_spec_exclusions.json" DistributionCreateByAql = "dist_create_by_aql.json" DistributionCreateWithMapping = "dist_create_with_mapping.json" + DistributionCreateWithPatternAndTarget = "dist_create_with_pattern_and_target.json" DistributionMappingDownload = "dist_mapping_download_spec.json" DistributionRepoConfig1 = "dist_repository_config1.json" DistributionRepoConfig2 = "dist_repository_config2.json"