Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions docs/notes/2.29.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Fixed an issue where environment targets with empty sequence fields would overri
#### Helm

[Fixed](https://github.com/pantsbuild/pants/pull/22565) a bug that would cause dependency inference (`k8s_parser`) to fail for Kubernetes manifests containing only yaml comments.
[Fixed](https://github.com/pantsbuild/pants/pull/22567) a bug where helm postrendering was not applied

#### JVM

Expand Down
4 changes: 3 additions & 1 deletion src/python/pants/backend/helm/util_rules/post_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def find_replacement(value: tuple[str, Address]) -> str | None:
replacements = mapping.indexed_docker_addresses.transform_values(find_replacement)

return SetupHelmPostRenderer(
replacements, description_of_origin=f"the `helm_deployment` {request.field_set.address}"
replacements,
description_of_origin=f"the `helm_deployment` {request.field_set.address}",
extra_post_renderers=request.field_set.post_renderers.to_unparsed_address_inputs(),
)


Expand Down
32 changes: 4 additions & 28 deletions src/python/pants/backend/helm/util_rules/post_renderer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,9 @@ def test_use_simple_extra_post_renderer(rule_runner: RuleRunner) -> None:
"src/mychart/templates/configmap.yaml": _TEST_GIVEN_CONFIGMAP_FILE,
"src/shell/BUILD": dedent(
"""\
shell_sources(name="scripts")

run_shell_command(
name="custom_post_renderer",
command="src/shell/my-script.sh",
execution_dependencies=[":scripts"]
command="sed 's/foo_value/modified_by_post_renderer/g'",
)
"""
),
Expand All @@ -316,29 +313,6 @@ def test_use_simple_extra_post_renderer(rule_runner: RuleRunner) -> None:
}
)

# We need to create the post-renderer script as a digest to ensure it has running permissions.
post_renderer_script_digest = rule_runner.request(
Digest,
[
CreateDigest(
[
FileContent(
path="src/shell/my-script.sh",
content=dedent(
"""\
#!/bin/bash
cat <&0
"""
).encode(),
is_executable=True,
)
]
)
],
)

rule_runner.write_digest(post_renderer_script_digest)

Comment on lines -319 to -341
Copy link
Author

@techanfa techanfa Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I apply this change locally the test passes. Is that expected? You had mentioned above that it does not.

That is expected--I found a workaround.

^^This code snippet shows the script I had to remove (my workaround) because this digest was throwing an error when attempting to run the test.

deployment_addr = Address("src/deployment", target_name="test")
tgt = rule_runner.get_target(deployment_addr)
field_set = HelmDeploymentFieldSet.create(tgt)
Expand Down Expand Up @@ -366,4 +340,6 @@ def test_use_simple_extra_post_renderer(rule_runner: RuleRunner) -> None:
digest=rendered_output.snapshot.digest,
filename="mychart/templates/configmap.yaml",
)
assert rendered_configmap_file == _TEST_EXPECTED_CONFIGMAP_FILE
# The post-renderer should have modified foo_value to modified_by_post_renderer
expected_modified_configmap = _TEST_EXPECTED_CONFIGMAP_FILE.replace("foo_value", "modified_by_post_renderer")
assert rendered_configmap_file == expected_modified_configmap
Loading