Skip to content

Commit 33ec972

Browse files
authored
Support for Distribution path mapping with AQL (#2313)
1 parent 96ddaba commit 33ec972

File tree

9 files changed

+71
-12
lines changed

9 files changed

+71
-12
lines changed

Diff for: distribution_test.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ func TestUpdateBundleProps(t *testing.T) {
445445
cleanDistributionTest(t)
446446
}
447447

448-
func TestBundlePathMapping(t *testing.T) {
448+
func TestBundlePathMappingFromPatternAndTarget(t *testing.T) {
449449
initDistributionTest(t)
450450

451451
// Upload files
@@ -465,6 +465,28 @@ func TestBundlePathMapping(t *testing.T) {
465465
cleanDistributionTest(t)
466466
}
467467

468+
func TestBundlePathMappingFromPatternAndTargetUsingSpec(t *testing.T) {
469+
initDistributionTest(t)
470+
471+
// Upload files
472+
specFile, err := tests.CreateSpec(tests.DistributionUploadSpecB)
473+
assert.NoError(t, err)
474+
runRt(t, "u", "--spec="+specFile)
475+
476+
// Create and distribute release bundle with path mapping from <DistRepo1>/data/ to <DistRepo2>/target/
477+
spec, err := tests.CreateSpec(tests.DistributionCreateWithPatternAndTarget)
478+
assert.NoError(t, err)
479+
runDs(t, "rbc", tests.BundleName, bundleVersion, "--sign", "--spec="+spec)
480+
runDs(t, "rbd", tests.BundleName, bundleVersion, "--site=*", "--sync")
481+
482+
// Validate files are distributed to the target mapping
483+
spec, err = tests.CreateSpec(tests.DistributionMappingDownload)
484+
assert.NoError(t, err)
485+
inttestutils.VerifyExistInArtifactory(tests.GetBundleMappingExpected(), spec, serverDetails, t)
486+
487+
cleanDistributionTest(t)
488+
}
489+
468490
func TestBundlePathMappingUsingSpec(t *testing.T) {
469491
initDistributionTest(t)
470492

Diff for: go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ require (
131131

132132
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231126114158-b6719ec2da0e
133133

134-
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231123122346-6325ab61a7b2
134+
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231127135302-daea501a3826
135135

136136
// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27
137137

138-
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231101142932-422f20520a28
138+
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a

Diff for: go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ github.com/jfrog/gofrog v1.3.1 h1:QqAwQXCVReT724uga1AYqG/ZyrNQ6f+iTxmzkb+YFQk=
243243
github.com/jfrog/gofrog v1.3.1/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
244244
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
245245
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
246-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231123122346-6325ab61a7b2 h1:BosujG/vEgXUEycZBxCLFZ58yRSJ20grvZ7sprU3kp0=
247-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231123122346-6325ab61a7b2/go.mod h1:+jzmxaxiiJgzascARg5Ioi4o3pfFfewk8rE5Pbo8u9Q=
248-
github.com/jfrog/jfrog-client-go v1.34.5 h1:NYZrOHvT5D5BwwHdArIz5WnbP+DPbADjV/SPdN33bfQ=
249-
github.com/jfrog/jfrog-client-go v1.34.5/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM=
246+
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231127135302-daea501a3826 h1:N49B28/2uy2+Rm2djugMrQ0yvgruLqudsJRIqaLMAIc=
247+
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231127135302-daea501a3826/go.mod h1:gsB5hTyVwtwZDHvwcKxO6BnLgLbBVy+EcRTf/D5dNo8=
248+
github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a h1:hZFfT7i+vwhDhJ7xf211XbS9uxjR83vC618di1Eo0wo=
249+
github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a/go.mod h1:0PVhP6xGvBBaUzOU9LKf5OYkke/gY2IFILHA++iabFM=
250250
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
251251
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
252252
github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk=

Diff for: schema/filespec-schema.json

+16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@
4242
}
4343
}
4444
},
45+
"pathMapping": {
46+
"description": "If specified, determines release-bundle source and target paths for artifacts that had been fetched using aql.",
47+
"properties": {
48+
"input": {
49+
"type": "string",
50+
"description": "The input path for mapping.",
51+
"examples": ["(.*)/old_folder/(.*)"]
52+
},
53+
"output": {
54+
"type": "string",
55+
"description": "The output path for mapping.",
56+
"examples": ["$1/new_folder/$2"]
57+
}
58+
}
59+
},
4560
"archive": {
4661
"type": "string",
4762
"enum": ["zip"],
@@ -227,6 +242,7 @@
227242
]
228243
}
229244
},
245+
"pathMapping": { "required": ["aql"] },
230246
"build": { "not": { "required": ["bundle", "limit", "offset"] } },
231247
"bundle": { "not": { "required": ["build", "limit", "offset"] } },
232248
"excludeArtifacts": { "required": ["build"] },

Diff for: testdata/filespecs/dist_create_with_mapping.json

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"files": [
33
{
4-
"pattern": "${DIST_REPO1}/data/(*)",
5-
"target": "${DIST_REPO2}/target/{1}"
4+
"aql": {
5+
"items.find": {
6+
"repo": "${DIST_REPO1}",
7+
"path": "data",
8+
"$or": [
9+
{
10+
"name": {
11+
"$match": "*"
12+
}
13+
}
14+
]
15+
}
16+
},
17+
"pathMapping": { "input": "${DIST_REPO1}/data/(.*)", "output": "${DIST_REPO2}/target/$1" }
618
}
719
]
8-
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files": [
3+
{
4+
"pattern": "${DIST_REPO1}/data/(*)",
5+
"target": "${DIST_REPO2}/target/{1}"
6+
}
7+
]
8+
}

Diff for: testdata/go/projectmissingdependency/projectmissingdependecy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ func execDependency() {
1212
func Exec() {
1313
fmt.Println("Executing ")
1414
execDependency()
15-
}
15+
}

Diff for: utils/cliutils/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"github.com/jfrog/gofrog/version"
8+
"github.com/jfrog/jfrog-client-go/utils/log"
89
"io"
910
"net/http"
1011
"os"
@@ -26,7 +27,6 @@ import (
2627
clientutils "github.com/jfrog/jfrog-client-go/utils"
2728
"github.com/jfrog/jfrog-client-go/utils/errorutils"
2829
"github.com/jfrog/jfrog-client-go/utils/io/content"
29-
"github.com/jfrog/jfrog-client-go/utils/log"
3030
"github.com/urfave/cli"
3131
)
3232

Diff for: utils/tests/consts.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const (
4242
DelSpecExclusions = "delete_spec_exclusions.json"
4343
DistributionCreateByAql = "dist_create_by_aql.json"
4444
DistributionCreateWithMapping = "dist_create_with_mapping.json"
45+
DistributionCreateWithPatternAndTarget = "dist_create_with_pattern_and_target.json"
4546
DistributionMappingDownload = "dist_mapping_download_spec.json"
4647
DistributionRepoConfig1 = "dist_repository_config1.json"
4748
DistributionRepoConfig2 = "dist_repository_config2.json"

0 commit comments

Comments
 (0)