Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promotions mermaid #4266

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tools/qontract_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,45 @@ def clusters(ctx, name):
print_output(ctx.obj["options"], clusters, columns)


@get.command()
@click.argument("app")
@click.pass_context
def promotions_mermaid(ctx, app):
saas_files = get_saas_files(app_name=app)
subscribers = defaultdict(list)
publishers = defaultdict(list)

print("""graph LR
classDef gate fill:#fff3d1,stroke:#ffe59e;
classDef soak fill:#daf7e2,stroke:#73bf7c;""")

for s in saas_files:
for rt in s.resource_templates:
for t in rt.targets:
if t.promotion is None:
continue
cluster = t.namespace.cluster.name
namespace = t.namespace.name

node = f"{s.name}/{rt.name}/{t.name}/{cluster}/{namespace}"
node += f'["{s.name}/{rt.name}/{t.name}<br/>on {cluster}/{namespace}"]'
if s.publish_job_logs:
node += ":::gate"

if t.promotion.publish:
for chan in t.promotion.publish:
publishers[chan].append(node)

if t.promotion.subscribe:
for chan in t.promotion.subscribe:
subscribers[chan].append(node)

for chan, nodes in publishers.items():
for subscriber in subscribers[chan]:
for publisher in nodes:
print(f" {publisher} --> {subscriber};")


@get.command()
@click.argument("name", default="")
@click.pass_context
Expand Down