Skip to content

Commit 8e01bae

Browse files
committed
Add helm_template_test.values
1 parent db0cb9b commit 8e01bae

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

helm/private/template.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ def _helm_template_test_impl(ctx):
4242
args.add("template")
4343
args.add(rlocationpath(pkg_info.chart, ctx.workspace_name))
4444

45+
for values in ctx.files.values:
46+
args.add("--values", values)
47+
4548
ctx.actions.write(
4649
output = args_file,
4750
content = args,
4851
)
4952

50-
runfiles = runfiles.merge(ctx.runfiles([
53+
runfiles = runfiles.merge(ctx.runfiles(ctx.files.values + [
5154
args_file,
5255
ctx.executable._runner,
5356
toolchain.helm,
@@ -108,6 +111,10 @@ helm_template_test = rule(
108111
"template_patterns": attr.string_list_dict(
109112
doc = "A mapping of template paths to regex patterns required to match.",
110113
),
114+
"values": attr.label_list(
115+
doc = "Values files to pass to `helm template --values`.",
116+
allow_files = [".yml", ".yaml"],
117+
),
111118
"_copier": attr.label(
112119
cfg = "exec",
113120
executable = True,

tests/template_with_values/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ helm_template(
2222
helm_template_test(
2323
name = "template_with_values_template_test",
2424
chart = ":template_with_values",
25+
template_patterns = {
26+
"template-with-values/templates/deployment.yaml": [
27+
" replicas: 10\\b", # overriden by template_values.yaml
28+
],
29+
},
30+
values = [
31+
":template_values.yaml",
32+
],
2533
)

0 commit comments

Comments
 (0)