-
Notifications
You must be signed in to change notification settings - Fork 144
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
Support for Distribution path mapping with AQL #861
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
1 similar comment
I have read the CLA Document and I hereby sign the CLA |
recheck |
Thanks for creating this PR @YardenEdery! |
tests/distribution_test.go
Outdated
// Make sure <RtTargetRepo>/b.out does exist in Artifactory | ||
searchParams := artifactoryServices.NewSearchParams() | ||
searchParams.Pattern = getRtTargetRepo() + "b.out" | ||
reader, err := testsSearchService.Search(searchParams) | ||
assert.NoError(t, err) | ||
readerCloseAndAssert(t, reader) | ||
length, err := reader.Length() | ||
assert.NoError(t, err) | ||
assert.Equal(t, 1, length) |
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 above code lines seem to be duplicated multiple times in this file. Let's move into a function and reuse the code.
tests/distribution_test.go
Outdated
// Distribute release bundle | ||
distributeBundleParams := distribution.NewDistributeReleaseBundleParams(bundleName, bundleVersion) | ||
distributeBundleParams.DistributionRules = []*distribution.DistributionCommonParams{{SiteName: "*"}} | ||
testsBundleDistributeService.Sync = true | ||
// On distribution with path mapping, the target repository cannot be auto-created | ||
testsBundleDistributeService.AutoCreateRepo = false | ||
testsBundleDistributeService.DistributeParams = distributeBundleParams | ||
err = testsBundleDistributeService.Distribute() | ||
assert.NoError(t, 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.
The above code lines seem to be duplicated multiple times in this file. Let's move into a function and reuse the code.
tests/distribution_test.go
Outdated
createBundleParams.SpecFiles = []*utils.CommonParams{ | ||
{ | ||
Aql: utils.Aql{ | ||
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\": \"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"b.in\"}}]}]}", |
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.
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\": \"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"b.in\"}}]}]}", | |
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\":\"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"b.in\"}}]}]}", |
tests/distribution_test.go
Outdated
createBundleParams.SpecFiles = []*utils.CommonParams{ | ||
{ | ||
Aql: utils.Aql{ | ||
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\": \"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"*.in\"}}]}]}", |
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.
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\": \"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"*.in\"}}]}]}", | |
ItemsFind: "{\"$or\":[{\"$and\":[{\"repo\":{\"$match\":\"" + strings.TrimSuffix(getRtTargetRepo(), "/") + "\"},\"name\":{\"$match\":\"*.in\"}}]}]}", |
tests/distribution_test.go
Outdated
|
||
createBundleParams.SignImmediately = true | ||
summary, err := testsBundleCreateService.CreateReleaseBundle(createBundleParams) | ||
if !assert.NoError(t, 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.
For better readability and shorter code, let's not use "ifs" in tests. The "assert" and/or "require" alone should help us to eliminate them.
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.
Well done @Yarden-Edery!
Thanks.
Added support of "mappings" property to file spec in order to have the ability to control where to distribute the artifacts that are being added dynamically when using AQL in the release bundle that is being created.
When looking for docker artifacts using AQL, the release bundle also includes, in the distribution server backend, all the layers for a manifest.json and all of the manifest.json files and their layers if its a list.manifest.json
From now on the "mappings" will take affect on those none specified added manifests and layers and will allow the users a native way of creating the file spec for distribution commands.
FYI This couldn't be achieved using "target" for the list.manifest.json example.