-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add container namespace command group
[noissue]
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 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 the container namespace command group. |
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,44 @@ | ||
import gettext | ||
|
||
import click | ||
|
||
from pulpcore.cli.common.context import PulpContext, pass_pulp_context | ||
from pulpcore.cli.common.generic import ( | ||
create_command, | ||
destroy_command, | ||
href_option, | ||
list_command, | ||
name_option, | ||
show_command, | ||
) | ||
from pulpcore.cli.container.context import PulpContainerNamespaceContext | ||
|
||
_ = gettext.gettext | ||
|
||
|
||
@click.group() | ||
@click.option( | ||
"-t", | ||
"--type", | ||
"namespace_type", | ||
type=click.Choice(["container"], case_sensitive=False), | ||
default="container", | ||
) | ||
@pass_pulp_context | ||
@click.pass_context | ||
def namespace(ctx: click.Context, pulp_ctx: PulpContext, namespace_type: str) -> None: | ||
if namespace_type == "container": | ||
ctx.obj = PulpContainerNamespaceContext(pulp_ctx) | ||
else: | ||
raise NotImplementedError() | ||
|
||
|
||
lookup_options = [href_option, name_option] | ||
create_options = [ | ||
click.option("--name", required=True), | ||
] | ||
|
||
namespace.add_command(list_command()) | ||
namespace.add_command(show_command(decorators=lookup_options)) | ||
namespace.add_command(create_command(decorators=create_options)) | ||
namespace.add_command(destroy_command(decorators=lookup_options)) |
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,19 @@ | ||
#!/bin/sh | ||
|
||
# shellcheck source=tests/scripts/config.source | ||
. "$(dirname "$(dirname "$(realpath "$0")")")"/config.source | ||
|
||
pulp debug has-plugin --name "container" || exit 3 | ||
|
||
cleanup() { | ||
pulp container namespace destroy --name "cli_test_container_namespace" || true | ||
} | ||
trap cleanup EXIT | ||
|
||
cleanup | ||
|
||
expect_succ pulp container namespace list | ||
|
||
expect_succ pulp container namespace create --name "cli_test_container_namespace" | ||
expect_succ pulp container namespace list | ||
expect_succ pulp container namespace destroy --name "cli_test_container_namespace" |