forked from pulp/pulp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add container repository content management commands
fixes: pulp#422
- Loading branch information
Showing
5 changed files
with
258 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added container repository content management commands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=tests/scripts/config.source | ||
. "$(dirname "$(dirname "$(realpath "$0")")")"/config.source | ||
|
||
pulp debug has-plugin --name "container" || exit 3 | ||
|
||
cleanup() { | ||
pulp container remote destroy --name "cli_test_container_remote" || true | ||
pulp container repository destroy --name "cli_test_source_container_repository" || true | ||
pulp container repository destroy --name "cli_test_dest_container_repository" || true | ||
pulp orphan cleanup || true | ||
} | ||
trap cleanup EXIT | ||
|
||
# Prepare | ||
pulp container remote create --name "cli_test_container_remote" --url "$CONTAINER_REMOTE_URL" --upstream-name "$CONTAINER_IMAGE" | ||
source_href="$(pulp container repository create --name "cli_test_source_container_repository" | jq -r .pulp_href)" | ||
pulp container repository create --name "cli_test_dest_container_repository" | ||
pulp container repository sync --name "cli_test_source_container_repository" --remote "cli_test_container_remote" | ||
tag="$(pulp container repository content -t 'tag' list --repository "cli_test_source_container_repository" | jq -r .[0].name)" | ||
digest="$(pulp container repository content -t 'manifest' list --repository "cli_test_source_container_repository" | jq -r '.[] | select(.listed_manifests == []) | .digest' | sed -n '1p')" | ||
|
||
# Test copying manifests | ||
expect_succ pulp container repository copy-manifest --name "cli_test_dest_container_repository" --source "cli_test_source_container_repository" --digest "$digest" | ||
expect_succ pulp container repository content -t 'manifest' list --repository "cli_test_dest_container_repository" | ||
test "$(echo "$OUTPUT" | jq -r length)" -eq 1 | ||
test "$(echo "$OUTPUT" | jq -r .[0].digest)" = "$digest" | ||
|
||
expect_succ pulp container repository copy-manifest --name "cli_test_dest_container_repository" --source "cli_test_source_container_repository:1" --media-type "application/vnd.docker.distribution.manifest.v2+json" | ||
expect_succ pulp container repository content -t 'manifest' list --repository "cli_test_dest_container_repository" --version "2" | ||
copied="$(echo "$OUTPUT" | jq -r length)" | ||
test "$copied" -gt 1 | ||
|
||
expect_succ pulp container repository copy-manifest --name "cli_test_dest_container_repository" --source "$source_href" | ||
expect_succ pulp container repository content -t 'manifest' list --repository "cli_test_dest_container_repository" --version "3" | ||
test "$(echo "$OUTPUT" | jq -r length)" -gt "$copied" | ||
|
||
# Test copying tags | ||
expect_succ pulp container repository copy-tag --name "cli_test_dest_container_repository" --source "cli_test_source_container_repository" --tag "$tag" | ||
expect_succ pulp container repository content -t 'tag' list --repository "cli_test_dest_container_repository" --version "4" | ||
test "$(echo "$OUTPUT" | jq -r length)" -eq 1 | ||
test "$(echo "$OUTPUT" | jq -r .[0].name)" = "$tag" | ||
|
||
expect_succ pulp container repository copy-tag --name "cli_test_dest_container_repository" --source "$source_href""versions/1/" | ||
expect_succ pulp container repository content -t 'tag' list --repository "cli_test_dest_container_repository" --version "5" | ||
test "$(echo "$OUTPUT" | jq -r length)" -gt 1 | ||
|
||
# Test bad versions | ||
expect_fail pulp container repository copy-tag --name "cli_test_source_container_repository" --source "cli_test_dest_container_repository:0" | ||
expect_fail pulp container repository copy-tag --name "cli_test_source_container_repository" --source "cli_test_dest_container_repository:6" | ||
test "$ERROUTPUT" = "Error: Please specify a version that between 0 and the latest version 5" |