Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #71 from tumido/workaround-ocp-issues
Browse files Browse the repository at this point in the history
fix(schema): wourkaround OCP Helm catalog form render issues
  • Loading branch information
tumido authored Jun 15, 2023
2 parents 8f423c6 + 3d75d6a commit 5f13f2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 66 deletions.
26 changes: 23 additions & 3 deletions .pre-commit/jsonschema-dereference.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,27 @@ def template_schema(chart_dir: Path, lock: Dict[str, Any]):

return json.loads(schema_template.render(lock))

def dereference_and_save(chart_dir: Path, schema_template: Any):
def tidy_schema(schema: Any):
"""Hack to support OCP Form view.
https://issues.redhat.com/browse/OCPBUGS-14874
https://issues.redhat.com/browse/OCPBUGS-14875
"""
if isinstance(schema, dict):
try:
del schema["$schema"]
except:
pass
try:
del schema["format"]
except:
pass
for v in schema.values():
tidy_schema(v)
return schema

def save(chart_dir: Path, schema: Any):
"""Take schema containing $refs and dereference them."""
schema = jsonref.replace_refs(schema_template)
with open(chart_dir / JSONSCHEMA_NAME, "w") as f:
json.dump(schema, f, indent=4, sort_keys=True)

Expand All @@ -40,8 +58,10 @@ def dereference_and_save(chart_dir: Path, schema_template: Any):
try:
lock = parse_chart_lock(chart)
schema_template = template_schema(chart, lock)
schema = jsonref.replace_refs(schema_template)
schema = tidy_schema(schema)

dereference_and_save(chart, schema_template)
save(chart, schema)
except BaseException as e:
print(f"Could not process schema for '{chart}': {e}")
errors.append(e)
Expand Down
2 changes: 1 addition & 1 deletion charts/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ sources:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.0.2
version: 2.0.3
2 changes: 1 addition & 1 deletion charts/backstage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Janus-IDP Backstage Helm Chart

[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/janus-idp&style=flat-square)](https://artifacthub.io/packages/search?repo=janus-idp)
![Version: 2.0.2](https://img.shields.io/badge/Version-2.0.2-informational?style=flat-square)
![Version: 2.0.3](https://img.shields.io/badge/Version-2.0.3-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A Helm chart for deploying a Backstage application
Expand Down
Loading

0 comments on commit 5f13f2a

Please sign in to comment.