Skip to content

Commit

Permalink
Merge branch 'main' into allenporter-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter authored Apr 21, 2024
2 parents eca85f4 + e6625ca commit b9beb4a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flux_local/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ def _lookup_value_reference(
found_value: str | None = None
if found_data is None:
if not ref.optional:
raise InvalidValuesReference(
f"Unable to find {ref.kind} {namespace}/{ref.name} referenced"
_LOGGER.warning(
"Unable to find %s %s/%s referenced",
ref.kind,
namespace,
ref.name,
)
if ref.target_path:
# When a target path is specified, the value is expected to be
Expand Down
77 changes: 77 additions & 0 deletions tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,83 @@ def test_values_references_with_missing_values_key() -> None:
}



def test_values_references_with_missing_secret() -> None:
"""Test for expanding a value reference with a missing secret."""
hr = HelmRelease(
name="test",
namespace="test",
chart=HelmChart(
repo_name="test-repo",
repo_namespace="flux-system",
name="test-chart",
version="test-version",
),
values={"test": "test"},
values_from=[
ValuesReference(
kind="Secret",
name="test-values-secret",
values_key="some-key-does-not-exist",
target_path="target.path",
)
],
)
ks = Kustomization(
name="test",
namespace="test",
path="example/path",
helm_releases=[hr],
)
updated_hr = expand_value_references(hr, ks)
assert updated_hr.values == {
"test": "test",
"target": {
"path": "!!PLACEHOLDER!!",
},
}


def test_values_references_with_missing_secret_values_key() -> None:
"""Test for expanding a value reference with a secret key that is missing."""
hr = HelmRelease(
name="test",
namespace="test",
chart=HelmChart(
repo_name="test-repo",
repo_namespace="flux-system",
name="test-chart",
version="test-version",
),
values={"test": "test"},
values_from=[
ValuesReference(
kind="Secret",
name="test-values-secret",
values_key="some-key-does-not-exist",
target_path="target.path",
)
],
)
ks = Kustomization(
name="test",
namespace="test",
path="example/path",
helm_releases=[hr],
secrets=[
Secret(
name="test-values-secret",
namespace="test",
string_data={"some-key": "example_value"},
)
],
)
updated_hr = expand_value_references(hr, ks)
assert updated_hr.values == {
"test": "test",
}


def test_values_references_invalid_yaml() -> None:
"""Test for expanding a value reference with a values key."""
hr = HelmRelease(
Expand Down

0 comments on commit b9beb4a

Please sign in to comment.