-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthias Büchse <matthias.buechse@cloudandheat.com>
- Loading branch information
Showing
2 changed files
with
56 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,55 @@ | ||
#!/usr/bin/env python3 | ||
import click | ||
import sys | ||
|
||
from flavor_name_check import parser_v1, parser_v2 | ||
|
||
|
||
class Version: | ||
def __init__(self, parser): | ||
self.parser = parser | ||
|
||
|
||
VERSIONS = { | ||
'v1': Version(parser_v1), | ||
'v2': Version(parser_v2), | ||
'v3': Version(parser_v2), | ||
} | ||
VERSIONS['latest'] = VERSIONS['v3'] | ||
|
||
|
||
@click.group() | ||
@click.argument('version', type=click.Choice(list(VERSIONS), case_sensitive=False)) | ||
@click.pass_context | ||
def cli(ctx, version): | ||
vobj = VERSIONS.get(version) | ||
ctx.obj['version'] = vobj | ||
|
||
|
||
@cli.result_callback() | ||
def process_pipeline(rc, *args, **kwargs): | ||
sys.exit(rc) | ||
|
||
|
||
@cli.command() | ||
@click.argument('namestr', nargs=-1) | ||
@click.pass_context | ||
def check(ctx, namestr): | ||
version = ctx.obj['version'] | ||
errors = 0 | ||
for name in namestr: | ||
try: | ||
flavorname = version.parser(name) | ||
except ValueError as exc: | ||
print(f"✘ {name}: ERROR {exc}") | ||
errors += 1 | ||
else: | ||
if flavorname is None: | ||
print(f" {name}: NOT an SCS flavor") | ||
else: | ||
print(f"✓ {name}: OK") | ||
return errors | ||
|
||
|
||
if __name__ == '__main__': | ||
cli(obj={}) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
click | ||
fabric | ||
kubernetes_asyncio | ||
PyYAML==6.0 | ||
|