Skip to content

Commit

Permalink
Make apps and pipeline run app labels more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMGranger committed Mar 2, 2022
1 parent 248b540 commit 76f7655
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions exporters/committime/collector_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ def generate_metrics(self) -> Iterable[CommitMetric]:
except openshift.dynamic.exceptions.ResourceNotFoundError:
pipeline_runs = pelorus.NoOpResourceInstance()

# use a jsonpath expression to find all possible values for the app label
jsonpath_str = f"$['items'][*]['metadata']['labels']['{app_label_key}']"
jsonpath_expr = parse(jsonpath_str)
jsonpath_labels_expr = parse("$['items'][*]['metadata']['labels']")

apps: set[str] = {match.value for match in jsonpath_expr.find(builds)}
apps: set[str] = {
match.value[app_label_key]
for match in jsonpath_labels_expr.find(builds)
}
pipeline_run_app_labels: set[str] = {
match.value for match in jsonpath_expr.find(pipeline_runs)
match.value[app_label_key]
for match in jsonpath_labels_expr.find(pipeline_runs)
}

builds_by_app: dict[str, list] = {
Expand Down

0 comments on commit 76f7655

Please sign in to comment.