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

[qc/get/osd-component-versions] add more information #4245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion tools/qontract_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
)
from reconcile.gql_definitions.fragments.aus_organization import AUSOCMOrganization
from reconcile.jenkins_job_builder import init_jjb
from reconcile.saas_auto_promotions_manager.integration import (
QONTRACT_INTEGRATION as SAPM,
)
from reconcile.slack_base import slackapi_from_queries
from reconcile.status_board import StatusBoardExporterIntegration
from reconcile.typed_queries.alerting_services_settings import get_alerting_services
Expand Down Expand Up @@ -2570,6 +2573,7 @@ def cost_report(ctx):
@get.command()
@click.pass_context
def osd_component_versions(ctx):
sapm_state = init_state(integration=SAPM).get("publisher-data.json")
osd_environments = [
e["name"] for e in queries.get_environments() if e["product"]["name"] == "OSDv4"
]
Expand All @@ -2580,14 +2584,23 @@ def osd_component_versions(ctx):
for t in rt.targets:
if t.namespace.environment.name not in osd_environments:
continue
sapm_key = f'{sf.name}/{rt.name}/{t.name or "default"}/{t.namespace.cluster.name}/{t.namespace.name}'
sapm_data = sapm_state.get(sapm_key)
if sapm_data:
commit_sha = sapm_data["commit_sha"]
deployment_state = sapm_data["deployment_state"]
else:
commit_sha = t.ref
deployment_state = "unknown"
item = {
"environment": t.namespace.environment.name,
"namespace": t.namespace.name,
"cluster": t.namespace.cluster.name,
"app": sf.app.name,
"saas_file": sf.name,
"resource_template": rt.name,
"ref": f"[{t.ref}]({rt.url}/blob/{t.ref}{rt.path})",
"ref": f"[{commit_sha}]({rt.url}/blob/{commit_sha}{rt.path})",
"deployment_state": deployment_state,
}
data.append(item)

Expand All @@ -2599,6 +2612,7 @@ def osd_component_versions(ctx):
"saas_file",
"resource_template",
"ref",
"deployment_state",
]
print_output(ctx.obj["options"], data, columns)

Expand Down