Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelis committed May 15, 2024
1 parent dd65c3d commit d413920
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions reconcile/saas_auto_promotions_manager/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ def fetch_commit_shas_and_deployment_info(
target_config_hash=promotion_data.target_config_hash,
check_in=check_in,
)

def __repr__(self):
return f"{self.saas_name}/{self.resource_template_name}/{self.target_name}/{self.cluster_name}/{self.namespace_name}"
3 changes: 3 additions & 0 deletions reconcile/saas_auto_promotions_manager/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,6 @@ def combined_content_hash(subscribers: Iterable["Subscriber"]) -> str:
"""
m.update(msg.encode("utf-8"))
return m.hexdigest()[:CONTENT_HASH_LENGTH]

def __repr__(self):
return f"{self.saas_name}/{self.resource_template_name}/{self.target_name}/{self.cluster_name}/{self.namespace_name}"
41 changes: 41 additions & 0 deletions tools/qontract_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
gql,
promtool,
)
from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
SaasFilesInventory,
)
from reconcile.utils.aws_api import AWSApi
from reconcile.utils.binary import (
binary,
Expand Down Expand Up @@ -245,6 +248,44 @@ def clusters(ctx, name):
columns = ["name", "consoleUrl", "prometheusUrl", "sshuttle"]
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="")
Expand Down

0 comments on commit d413920

Please sign in to comment.