Skip to content

Commit

Permalink
feat!: rename API and CLI public to publish
Browse files Browse the repository at this point in the history
Use an actionable name for the publication step to make the action
more obvious.
  • Loading branch information
toabctl committed Sep 30, 2024
1 parent b2fd250 commit 0549bad
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions awspub/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions awspub/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]):
Expand Down
18 changes: 9 additions & 9 deletions awspub/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion awspub/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions awspub/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/how_to/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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")
14 changes: 7 additions & 7 deletions docs/how_to/publish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
~~~~~~~~~~~~~~~
Expand All @@ -195,13 +195,13 @@ It's possible to publish to `AWS Marketplace <https://docs.aws.amazon.com/market
.. literalinclude:: ../config-samples/config-minimal-marketplace.yaml
:language: yaml

The image needs to be created first and the `public` command will request a new Marketplace version
The image needs to be created first and the `publish` command will request a new Marketplace version
for the given entity:

.. code-block:: shell
awspub create config.yaml
awspub public config.yaml
awspub publish config.yaml
SSM Parameter Store
~~~~~~~~~~~~~~~~~~~
Expand All @@ -219,12 +219,12 @@ along with a corresponding mapping file:
.. literalinclude:: ../config-samples/config-minimal-ssm.yaml.mapping
:language: yaml

Create the image and use the `public` command to publish the image and also push information to the parameter store:
Create the image and use the `publish` command to publish the image and also push information to the parameter store:

.. code-block:: shell
awspub create config.yaml --config-mapping config.yaml.mapping
awspub public config.yaml --config-mapping config.yaml.mapping
awspub publish config.yaml --config-mapping config.yaml.mapping
Resource tags
Expand Down

0 comments on commit 0549bad

Please sign in to comment.