Skip to content

Commit

Permalink
Add cf sub commands
Browse files Browse the repository at this point in the history
  Extract cf-* commands to separate cf sub commands
  • Loading branch information
ligangty committed Apr 25, 2024
1 parent 44d173b commit 9350aba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 5 additions & 3 deletions charon/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from charon.cmd.cmd_delete import delete
from charon.cmd.cmd_index import index
from charon.cmd.cmd_checksum import checksum_validate
from charon.cmd.cmd_cache import cf_invalidate, cf_check
from charon.cmd.cmd_cache import init_cf, cf


@group()
Expand All @@ -34,5 +34,7 @@ def cli():
cli.add_command(delete)
cli.add_command(index)
cli.add_command(checksum_validate)
cli.add_command(cf_invalidate)
cli.add_command(cf_check)

# init cf cmmand
init_cf()
cli.add_command(cf)
18 changes: 15 additions & 3 deletions charon/cmd/cmd_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from charon.cmd.internal import _decide_mode, _get_buckets
from charon.cache import CFClient
from charon.pkgs.pkg_utils import invalidate_cf_paths
from click import command, option, argument
from click import command, option, argument, group
from typing import List, Tuple

import traceback
Expand Down Expand Up @@ -75,7 +75,7 @@
default=False
)
@command()
def cf_invalidate(
def invalidate(
target: str,
paths: List[str],
path_file: str,
Expand Down Expand Up @@ -161,7 +161,7 @@ def cf_invalidate(
default=False
)
@command()
def cf_check(
def check(
invalidation_id: str,
target: str,
quiet: bool = False,
Expand Down Expand Up @@ -214,3 +214,15 @@ def _init_cmd(target: str) -> Tuple[List[Tuple[str, str, str, str, str]], str]:
sys.exit(1)

return (_get_buckets([target], conf), aws_profile)


@group()
def cf():
"""cf commands are responsible for the CloudFront cache operations in
products operated by Charon
"""


def init_cf():
cf.add_command(invalidate)
cf.add_command(check)
2 changes: 1 addition & 1 deletion charon/pkgs/pkg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def invalidate_cf_paths(
non_completed[status] = ids
logger.info(
"The CF invalidating requests done, following requests "
"are not completed yet:\n %s\nPlease use cf-check command to "
"are not completed yet:\n %s\nPlease use 'cf check' command to "
"check its details.", non_completed
)
logger.debug(
Expand Down

0 comments on commit 9350aba

Please sign in to comment.