Skip to content

Commit

Permalink
Only allow for lower-case version name, fixes #22 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward authored Sep 16, 2022
1 parent 95cbd78 commit 1cbd75e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/viur_cli/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ def deploy(action, name, additional_args):
{k: v for k, v in conf.items() if k not in ["version"]}
)

# gcloud only allows for version identifiers following these rules
if not all([ch in (string.ascii_letters + string.digits + "-") for ch in version]):
echo_error(f"version name '{version}' contains invalid characters!")
return
# gcloud only allows for version identifiers in lower-case order and only accepting these characters
version = "".join([c for c in version.lower() if c in string.ascii_lowercase + string.digits + "-"])

# rebuild requirements.txt
create_req()
Expand Down
4 changes: 4 additions & 0 deletions src/viur_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def echo_info(msg):
"""colored cli feedback"""
click.echo(click.style(msg, fg="cyan"))


def replace_vars(string: str, vars: typing.Optional[typing.Dict[str, str]] = None) -> str:
"""Replaces $(placeholders) in a string by values from a dict until no more values are being replaced.
Expand All @@ -23,6 +24,9 @@ def replace_vars(string: str, vars: typing.Optional[typing.Dict[str, str]] = Non
- day: Current date's day
- month: Current date's month
- year: Current date's year
- hour: Current date's hour
- minute: Current date's minute
- second: Current date's second
"""
# set some defaults
if vars is None:
Expand Down

0 comments on commit 1cbd75e

Please sign in to comment.