From 0549bad42cedb4ece27b48b0b076bfeb48199913 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Mon, 30 Sep 2024 08:57:12 +0200 Subject: [PATCH] feat!: rename API and CLI public to publish Use an actionable name for the publication step to make the action more obvious. --- awspub/__init__.py | 4 ++-- awspub/api.py | 4 ++-- awspub/cli/__init__.py | 18 +++++++++--------- awspub/image.py | 2 +- awspub/tests/test_image.py | 6 +++--- docs/how_to/api.rst | 2 +- docs/how_to/publish.rst | 14 +++++++------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/awspub/__init__.py b/awspub/__init__.py index c59f03d..9d04477 100644 --- a/awspub/__init__.py +++ b/awspub/__init__.py @@ -1,3 +1,3 @@ -from awspub.api import cleanup, create, list, public, verify +from awspub.api import cleanup, create, list, publish, verify -__all__ = ["create", "list", "public", "cleanup", "verify"] +__all__ = ["create", "list", "publish", "cleanup", "verify"] diff --git a/awspub/api.py b/awspub/api.py index 0a3d48d..ebe72d2 100644 --- a/awspub/api.py +++ b/awspub/api.py @@ -111,7 +111,7 @@ def list( return images_by_name, images_by_group -def public(config: pathlib.Path, config_mapping: pathlib.Path, group: Optional[str]): +def publish(config: pathlib.Path, config_mapping: pathlib.Path, group: Optional[str]): """ Make available images in the partition of the used account based on the given configuration file public @@ -125,7 +125,7 @@ def public(config: pathlib.Path, config_mapping: pathlib.Path, group: Optional[s """ ctx = Context(config, config_mapping) for image_name, image in _images_filtered(ctx, group): - image.public() + image.publish() def cleanup(config: pathlib.Path, config_mapping: pathlib.Path, group: Optional[str]): diff --git a/awspub/cli/__init__.py b/awspub/cli/__init__.py index 606790f..f84c5dd 100644 --- a/awspub/cli/__init__.py +++ b/awspub/cli/__init__.py @@ -46,11 +46,11 @@ def _cleanup(args) -> None: awspub.cleanup(args.config, args.config_mapping, args.group) -def _public(args) -> None: +def _publish(args) -> None: """ Make available images public """ - awspub.public(args.config, args.config_mapping, args.group) + awspub.publish(args.config, args.config_mapping, args.group) def _parser(): @@ -102,16 +102,16 @@ def _parser(): p_cleanup.set_defaults(func=_cleanup) - # public - p_public = p_sub.add_parser("public", help="Publish images") - p_public.add_argument( + # publish + p_publish = p_sub.add_parser("publish", help="Publish images") + p_publish.add_argument( "--output", type=argparse.FileType("w+"), help="output file path. defaults to stdout", default=sys.stdout ) - p_public.add_argument("--config-mapping", type=pathlib.Path, help="the image config template mapping file path") - p_public.add_argument("--group", type=str, help="only handles images from given group") - p_public.add_argument("config", type=pathlib.Path, help="the image configuration file path") + p_publish.add_argument("--config-mapping", type=pathlib.Path, help="the image config template mapping file path") + p_publish.add_argument("--group", type=str, help="only handles images from given group") + p_publish.add_argument("config", type=pathlib.Path, help="the image configuration file path") - p_public.set_defaults(func=_public) + p_publish.set_defaults(func=_publish) return parser diff --git a/awspub/image.py b/awspub/image.py index 70b6598..ee11cda 100644 --- a/awspub/image.py +++ b/awspub/image.py @@ -474,7 +474,7 @@ def create(self) -> Dict[str, _ImageInfo]: return images - def public(self) -> None: + def publish(self) -> None: """ Handle all publication steps - make image and underlying root device snapshot public if the public flag is set diff --git a/awspub/tests/test_image.py b/awspub/tests/test_image.py index a0d81e1..7f9f3c6 100644 --- a/awspub/tests/test_image.py +++ b/awspub/tests/test_image.py @@ -126,11 +126,11 @@ def test_image___get_root_device_snapshot_id(root_device_name, block_device_mapp ("test-image-8", "aws-cn", True, True, False, True), ], ) -def test_image_public( +def test_image_publish( imagename, partition, called_mod_image, called_mod_snapshot, called_start_change_set, called_put_parameter ): """ - Test the public() for a given image + Test the publish() for a given image """ with patch("boto3.client") as bclient_mock: instance = bclient_mock.return_value @@ -156,7 +156,7 @@ def test_image_public( instance.get_parameters.return_value = {"Parameters": []} ctx = context.Context(curdir / "fixtures/config1.yaml", None) img = image.Image(ctx, imagename) - img.public() + img.publish() assert instance.modify_image_attribute.called == called_mod_image assert instance.modify_snapshot_attribute.called == called_mod_snapshot assert instance.start_change_set.called == called_start_change_set diff --git a/docs/how_to/api.rst b/docs/how_to/api.rst index afcc49f..246b1fa 100644 --- a/docs/how_to/api.rst +++ b/docs/how_to/api.rst @@ -10,4 +10,4 @@ Assuming there is a configuration file and a configuration file mapping: import awspub awspub.create("config.yaml", "mapping.yaml") - awspub.public("config.yaml", "mapping.yaml") + awspub.publish("config.yaml", "mapping.yaml") diff --git a/docs/how_to/publish.rst b/docs/how_to/publish.rst index fe2be20..fa2497e 100644 --- a/docs/how_to/publish.rst +++ b/docs/how_to/publish.rst @@ -171,8 +171,8 @@ only to images defined within `group2`. If no `--group` parameter is given, the different commands operate on **all** defined images. -Public images -~~~~~~~~~~~~~ +Publish images +~~~~~~~~~~~~~~ To make images public, the configuration needs to have the `public` flag set for each image that needs to be public. @@ -185,7 +185,7 @@ The image needs to be created and then published: .. code-block:: shell awspub create config.yaml - awspub public config.yaml + awspub publish config.yaml AWS Marketplace ~~~~~~~~~~~~~~~ @@ -195,13 +195,13 @@ It's possible to publish to `AWS Marketplace