Skip to content

Commit

Permalink
Add support for autopublish and autodistribute
Browse files Browse the repository at this point in the history
fixes pulp#155
  • Loading branch information
David Davis committed Apr 8, 2021
1 parent 1fcecc1 commit 7652c56
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES/155.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for autopublish and autodistribute.
3 changes: 3 additions & 0 deletions pulpcore/cli/file/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions pulpcore/cli/file/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions pulpcore/cli/file/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/pulp_file/test_repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions tests/scripts/pulp_file/test_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 7652c56

Please sign in to comment.