Skip to content

Commit

Permalink
Merge pull request lsst-sqre#2589 from lsst-sqre/tickets/DM-40947
Browse files Browse the repository at this point in the history
DM-40947: Fix Chart.yaml for new applications
  • Loading branch information
rra authored Sep 27, 2023
2 parents 8e352af + 9f77a35 commit ef5052f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
14 changes: 12 additions & 2 deletions src/phalanx/services/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,19 @@ def create_application(
raise ApplicationExistsError(name)
self._helm.create(name, starter)

# Replace the description in the chart with the provided one.
chart = yaml.safe_load((path / "Chart.yaml").read_text())
# Unfortunately, Helm completely ignores the Chart.yaml in a starter
# so far as I can tell, so we have to load the starter Chart.yaml
# ourselves and replace the generated Chart.yaml with it, but
# preserving the substitutions that Helm does make.
starter_path = self._config.get_starter_path(starter)
chart = yaml.safe_load((starter_path / "Chart.yaml").read_text())
helm_chart = yaml.safe_load((path / "Chart.yaml").read_text())
chart["name"] = helm_chart["name"]
chart["description"] = description
if "sources" in chart:
chart["sources"] = [
s.replace("<CHARTNAME>", name) for s in chart["sources"]
]
with (path / "Chart.yaml").open("w") as fh:
yaml.dump(chart, fh)

Expand Down
27 changes: 0 additions & 27 deletions starters/web-service/README.md

This file was deleted.

13 changes: 12 additions & 1 deletion tests/cli/application_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_create(tmp_path: Path) -> None:
(apps_path / "zzz-other-app" / "values-minikube.yaml").write_text("")

# Load the environment, make sure the new apps are enabled, and check that
# the chart descriptions are correct.
# the chart metadata is correct.
factory = Factory(config_path)
config_storage = factory.create_config_storage()
environment = config_storage.load_environment("minikube")
Expand All @@ -104,6 +104,17 @@ def test_create(tmp_path: Path) -> None:
("zzz-other-app", "Last new app"),
):
assert environment.applications[app].chart["description"] == expected
assert environment.applications[app].chart["version"] == "1.0.0"

# Charts created from the empty starter should not have appVersion. Charts
# using the web-service starter should, set to 0.1.0.
assert "appVersion" not in environment.applications["aaa-new-app"].chart
assert "appVersion" not in environment.applications["zzz-other-app"].chart
assert environment.applications["hips"].chart["appVersion"] == "0.1.0"

# Charts using the web-service starter should have a default sources.
expected = "https://github.com/lsst-sqre/hips"
assert environment.applications["hips"].chart["sources"][0] == expected


def test_create_prompt(tmp_path: Path) -> None:
Expand Down
3 changes: 2 additions & 1 deletion tests/data/input/starters/web-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v2
name: <CHARTNAME>
version: 1.0.0
description: "Helm starter chart for a new RSP service"
home: "https://github.com/lsst-sqre/<CHARTNAME>"
sources:
- "https://github.com/lsst-sqre/<CHARTNAME>"
type: application
appVersion: "0.1.0"

0 comments on commit ef5052f

Please sign in to comment.