Skip to content

Commit

Permalink
Add distribution path mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarden-Edery committed Nov 27, 2023
1 parent 96ddaba commit d3576fd
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 12 deletions.
24 changes: 23 additions & 1 deletion distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <DistRepo1>/data/ to <DistRepo2>/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)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ require (

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

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

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

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231101142932-422f20520a28
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ 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.31.1-0.20231123122346-6325ab61a7b2 h1:BosujG/vEgXUEycZBxCLFZ58yRSJ20grvZ7sprU3kp0=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231123122346-6325ab61a7b2/go.mod h1:+jzmxaxiiJgzascARg5Ioi4o3pfFfewk8rE5Pbo8u9Q=
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/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231127135302-daea501a3826 h1:N49B28/2uy2+Rm2djugMrQ0yvgruLqudsJRIqaLMAIc=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231127135302-daea501a3826/go.mod h1:gsB5hTyVwtwZDHvwcKxO6BnLgLbBVy+EcRTf/D5dNo8=
github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a h1:hZFfT7i+vwhDhJ7xf211XbS9uxjR83vC618di1Eo0wo=
github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a/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=
Expand Down
16 changes: 16 additions & 0 deletions schema/filespec-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
}
}
},
"pathMapping": {
"description": "If specified, determines release-bundle source and target paths for artifacts that had been fetched using aql.",
"properties": {
"input": {
"type": "string",
"description": "The input path for mapping.",
"examples": ["(.*)/old_folder/(.*)"]
},
"output": {
"type": "string",
"description": "The output path for mapping.",
"examples": ["$1/new_folder/$2"]
}
}
},
"archive": {
"type": "string",
"enum": ["zip"],
Expand Down Expand Up @@ -227,6 +242,7 @@
]
}
},
"pathMapping": { "required": ["aql"] },
"build": { "not": { "required": ["bundle", "limit", "offset"] } },
"bundle": { "not": { "required": ["build", "limit", "offset"] } },
"excludeArtifacts": { "required": ["build"] },
Expand Down
18 changes: 15 additions & 3 deletions testdata/filespecs/dist_create_with_mapping.json
Original file line number Diff line number Diff line change
@@ -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": "*"
}
}
]
}
},
"pathMapping": { "input": "${DIST_REPO1}/data/(.*)", "output": "${DIST_REPO2}/target/$1" }
}
]
}
}
8 changes: 8 additions & 0 deletions testdata/filespecs/dist_create_with_pattern_and_target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files": [
{
"pattern": "${DIST_REPO1}/data/(*)",
"target": "${DIST_REPO2}/target/{1}"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func execDependency() {
func Exec() {
fmt.Println("Executing ")
execDependency()
}
}
2 changes: 1 addition & 1 deletion utils/cliutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-client-go/utils/log"
"io"
"net/http"
"os"
Expand All @@ -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"
)

Expand Down
1 change: 1 addition & 0 deletions utils/tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d3576fd

Please sign in to comment.