diff --git a/CHANGES/155.feature b/CHANGES/155.feature new file mode 100644 index 000000000..e13d2afd9 --- /dev/null +++ b/CHANGES/155.feature @@ -0,0 +1 @@ +Added support for autopublish and autodistribute. diff --git a/pulpcore/cli/file/context.py b/pulpcore/cli/file/context.py index 81cfc92e6..e0ead6f08 100644 --- a/pulpcore/cli/file/context.py +++ b/pulpcore/cli/file/context.py @@ -107,4 +107,7 @@ def preprocess_body(self, body: EntityDefinition) -> EntityDefinition: body = super().preprocess_body(body) if body.get("description") == "": body["description"] = None + if not self.pulp_ctx.has_plugin("file", min_version="1.7.dev"): + # autopublish defaults to false but was not added until 1.7 + body.pop("autopublish", None) return body diff --git a/pulpcore/cli/file/distribution.py b/pulpcore/cli/file/distribution.py index 411d7174a..ec915eb83 100644 --- a/pulpcore/cli/file/distribution.py +++ b/pulpcore/cli/file/distribution.py @@ -40,14 +40,13 @@ def distribution(ctx: click.Context, pulp_ctx: PulpContext, distribution_type: s filter_options = [label_select_option, base_path_option, base_path_contains_option] lookup_options = [href_option, name_option] -create_options = [ - click.option("--name", required=True), - click.option("--base-path", required=True), - click.option("--publication"), -] update_options = [ click.option("--base-path"), click.option("--publication"), + click.option("--repository"), +] +create_options = update_options + [ + click.option("--name", required=True), ] distribution.add_command(list_command(decorators=filter_options)) diff --git a/pulpcore/cli/file/repository.py b/pulpcore/cli/file/repository.py index d13825334..b13e012a8 100644 --- a/pulpcore/cli/file/repository.py +++ b/pulpcore/cli/file/repository.py @@ -64,14 +64,14 @@ def repository(ctx: click.Context, pulp_ctx: PulpContext, repo_type: str) -> Non lookup_options = [href_option, name_option] nested_lookup_options = [repository_href_option, repository_option] -create_options = [ - click.option("--name", required=True), - click.option("--description"), - click.option("--remote", callback=_remote_callback), -] update_options = [ click.option("--description"), click.option("--remote", callback=_remote_callback), + click.option("--manifest"), + click.option("--autopublish/--no-autopublish"), +] +create_options = update_options + [ + click.option("--name", required=True), ] repository.add_command(list_command(decorators=[label_select_option])) diff --git a/tests/scripts/pulp_file/test_repository.sh b/tests/scripts/pulp_file/test_repository.sh index 954a99deb..427649d70 100755 --- a/tests/scripts/pulp_file/test_repository.sh +++ b/tests/scripts/pulp_file/test_repository.sh @@ -19,6 +19,7 @@ expect_succ pulp file repository list expect_succ pulp file repository create --name "cli_test_file_repo" --description "Test repository for CLI tests" expect_succ pulp file repository update --name "cli_test_file_repo" --description "" --remote "cli_test_file_remote1" +expect_succ pulp file repository update --name "cli_test_file_repo" --manifest "manifest.csv" expect_succ pulp file repository show --name "cli_test_file_repo" expect_succ test "$(echo "$OUTPUT" | jq -r '.remote')" = "$REMOTE1_HREF" expect_succ pulp file repository update --name "cli_test_file_repo" --remote "cli_test_file_remote2" diff --git a/tests/scripts/pulp_file/test_sync.sh b/tests/scripts/pulp_file/test_sync.sh index fa0eeda97..1d2f09e83 100755 --- a/tests/scripts/pulp_file/test_sync.sh +++ b/tests/scripts/pulp_file/test_sync.sh @@ -5,9 +5,12 @@ pulp debug has-plugin --name "file" || exit 3 +autopublish_repo="cli_test_file_repository_autopublish" + cleanup() { pulp file remote destroy --name "cli_test_file_remote" || true pulp file repository destroy --name "cli_test_file_repository" || true + pulp file repository destroy --name "$autopublish_repo" || true } trap cleanup EXIT @@ -42,3 +45,13 @@ test "$(echo "$OUTPUT" | jq -r '.state')" = "completed" # Delete version again expect_succ pulp file repository version destroy --repository "cli_test_file_repository" --version 1 + +# Test autopublish +if [ "$(pulp debug has-plugin --name "file" --min-version "1.7.0.dev")" = "true" ] +then + expect_succ pulp file repository create --name "$autopublish_repo" --remote "cli_test_file_remote" --autopublish + expect_succ pulp file repository sync --name "$autopublish_repo" + task=$(echo "$ERROUTPUT" | grep -E -o "/pulp/api/v3/tasks/[-[:xdigit:]]*/") + created_resources=$(pulp show --href "$task" | jq -r ".created_resources") + echo "$created_resources" | grep -q '/pulp/api/v3/publications/file/file/' +fi