Skip to content

Commit fc2998d

Browse files
committed
feat: add valuesFiles support for helm template and cleanup flags
- Add valuesFiles option to HelmTemplate config for passing additional values files to helm template command - Remove redundant -f values.yaml flag from helm template (chart's default values.yaml is used automatically) - Remove --template-files flag with typo from helm-docs (default README.md.gotmpl is correct) - Add a dummy helm chart in kres to test helm chart ci flow Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
1 parent 4879152 commit fc2998d

17 files changed

Lines changed: 310 additions & 12 deletions

File tree

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2025-08-14T09:17:18Z by kres 9f63e23-dirty.
3+
# Generated on 2026-01-30T10:07:13Z by kres d81080ef-dirty.
44

55
*
66
!cmd
@@ -11,3 +11,4 @@
1111
!README.md
1212
!.markdownlint.json
1313
!hack/govulncheck.sh
14+
!test/test-helm-chart

.github/workflows/helm.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
2+
#
3+
# Generated on 2026-01-30T10:12:39Z by kres 0029fe1a-dirty.
4+
5+
concurrency:
6+
group: helm-${{ github.head_ref || github.run_id }}
7+
cancel-in-progress: true
8+
"on":
9+
push:
10+
tags:
11+
- v*
12+
pull_request:
13+
branches:
14+
- main
15+
- release-*
16+
paths:
17+
- test/**
18+
name: helm
19+
jobs:
20+
default:
21+
permissions:
22+
actions: read
23+
contents: write
24+
id-token: write
25+
issues: read
26+
packages: write
27+
pull-requests: read
28+
runs-on:
29+
group: generic
30+
steps:
31+
- name: gather-system-info
32+
id: system-info
33+
uses: kenchan0130/actions-system-info@59699597e84e80085a750998045983daa49274c4 # version: v1.4.0
34+
continue-on-error: true
35+
- name: print-system-info
36+
run: |
37+
MEMORY_GB=$((${{ steps.system-info.outputs.totalmem }}/1024/1024/1024))
38+
39+
OUTPUTS=(
40+
"CPU Core: ${{ steps.system-info.outputs.cpu-core }}"
41+
"CPU Model: ${{ steps.system-info.outputs.cpu-model }}"
42+
"Hostname: ${{ steps.system-info.outputs.hostname }}"
43+
"NodeName: ${NODE_NAME}"
44+
"Kernel release: ${{ steps.system-info.outputs.kernel-release }}"
45+
"Kernel version: ${{ steps.system-info.outputs.kernel-version }}"
46+
"Name: ${{ steps.system-info.outputs.name }}"
47+
"Platform: ${{ steps.system-info.outputs.platform }}"
48+
"Release: ${{ steps.system-info.outputs.release }}"
49+
"Total memory: ${MEMORY_GB} GB"
50+
)
51+
52+
for OUTPUT in "${OUTPUTS[@]}";do
53+
echo "${OUTPUT}"
54+
done
55+
continue-on-error: true
56+
- name: checkout
57+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # version: v6.0.1
58+
- name: Unshallow
59+
run: |
60+
git fetch --prune --unshallow
61+
- name: Install Helm
62+
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # version: v4.3.1
63+
- name: Install cosign
64+
if: github.event_name != 'pull_request'
65+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # version: v4.0.0
66+
- name: Login to registry
67+
if: github.event_name != 'pull_request'
68+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # version: v3.6.0
69+
with:
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
registry: ghcr.io
72+
username: ${{ github.repository_owner }}
73+
- name: Lint chart
74+
if: github.event_name == 'pull_request'
75+
run: |
76+
helm lint test/test-helm-chart
77+
- name: Template chart
78+
if: github.event_name == 'pull_request'
79+
run: |
80+
helm template -f test/test-helm-chart/test/test-helm-chart/ci-values.yaml test-helm-chart test/test-helm-chart
81+
- name: Install unit test plugin
82+
if: github.event_name == 'pull_request'
83+
run: |
84+
make helm-plugin-install
85+
- name: Unit test chart
86+
if: github.event_name == 'pull_request'
87+
run: |
88+
make chart-unittest
89+
- name: Generate schema
90+
if: github.event_name == 'pull_request'
91+
run: |
92+
make chart-gen-schema
93+
- name: Generate docs
94+
if: github.event_name == 'pull_request'
95+
run: |
96+
make helm-docs
97+
- name: Check dirty
98+
if: github.event_name == 'pull_request'
99+
run: |
100+
make check-dirty
101+
- name: helm login
102+
if: startsWith(github.ref, 'refs/tags/')
103+
env:
104+
HELM_CONFIG_HOME: /var/tmp/.config/helm
105+
run: |
106+
helm registry login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
107+
- name: Release chart
108+
if: startsWith(github.ref, 'refs/tags/')
109+
env:
110+
HELM_CONFIG_HOME: /var/tmp/.config/helm
111+
run: |
112+
make helm-release

.kres.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ spec:
9191
matchDatasources:
9292
- docker
9393
allowedVersions: /^24\.\d+\.\d+-alpine$/
94+
---
95+
kind: auto.Helm
96+
spec:
97+
enabled: true
98+
chartDir: test/test-helm-chart
99+
template:
100+
valuesFiles:
101+
- test/test-helm-chart/ci-values.yaml

Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2026-01-16T08:46:36Z by kres 6f7b97a-dirty.
5+
# Generated on 2026-01-30T10:07:13Z by kres d81080ef-dirty.
66

77
ARG TOOLCHAIN=scratch
88

@@ -64,6 +64,12 @@ RUN mkdir -p internal/version/data && \
6464
echo -n ${SHA} > internal/version/data/sha && \
6565
echo -n ${TAG} > internal/version/data/tag
6666

67+
# helm toolchain
68+
FROM base AS helm-toolchain
69+
ARG HELMDOCS_VERSION
70+
RUN --mount=type=cache,target=/root/.cache/go-build,id=kres/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=kres/go/pkg go install github.com/norwoodj/helm-docs/cmd/helm-docs@${HELMDOCS_VERSION} \
71+
&& mv /go/bin/helm-docs /bin/helm-docs
72+
6773
# runs gofumpt
6874
FROM base AS lint-gofumpt
6975
RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumpt -w .':\n${FILES}"; exit 1)
@@ -107,6 +113,11 @@ ARG ABBREV_TAG
107113
RUN echo -n 'undefined' > internal/version/data/sha && \
108114
echo -n ${ABBREV_TAG} > internal/version/data/tag
109115

116+
# runs helm-docs
117+
FROM helm-toolchain AS helm-docs-run
118+
COPY test/test-helm-chart /src/test/test-helm-chart
119+
RUN --mount=type=cache,target=/root/.cache/go-build,id=kres/root/.cache/go-build --mount=type=cache,target=/root/.cache/helm-docs,id=kres/root/.cache/helm-docs,sharing=locked helm-docs --badge-style=flat
120+
110121
# clean golangci-lint fmt output
111122
FROM scratch AS lint-golangci-lint-fmt
112123
COPY --from=lint-golangci-lint-fmt-run /src .
@@ -118,6 +129,10 @@ COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt
118129
FROM scratch AS generate
119130
COPY --from=embed-abbrev-generate /src/internal/version internal/version
120131

132+
# clean helm-docs output
133+
FROM scratch AS helm-docs
134+
COPY --from=helm-docs-run /src/test/test-helm-chart test/test-helm-chart
135+
121136
# builds kres-darwin-amd64
122137
FROM base AS kres-darwin-amd64-build
123138
COPY --from=generate / /

Makefile

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2026-01-28T15:12:29Z by kres edff623.
3+
# Generated on 2026-01-30T10:07:13Z by kres d81080ef-dirty.
44

55
# common variables
66

@@ -36,6 +36,9 @@ GOTOOLCHAIN ?= local
3636
GOEXPERIMENT ?=
3737
GO_BUILDFLAGS += -tags $(GO_BUILDTAGS)
3838
TESTPKGS ?= ./...
39+
HELMREPO ?= $(REGISTRY)/$(USERNAME)/charts
40+
COSIGN_ARGS ?=
41+
HELMDOCS_VERSION ?= v1.14.2
3942
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
4043
CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest
4144

@@ -76,6 +79,7 @@ COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
7679
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)"
7780
COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)"
7881
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
82+
COMMON_ARGS += --build-arg=HELMDOCS_VERSION="$(HELMDOCS_VERSION)"
7983
TOOLCHAIN ?= docker.io/golang:1.25-alpine
8084

8185
# help menu
@@ -144,7 +148,7 @@ else
144148
GO_LDFLAGS += -s
145149
endif
146150

147-
all: unit-tests kres image-kres lint
151+
all: unit-tests kres image-kres helm lint
148152

149153
$(ARTIFACTS): ## Creates artifacts directory.
150154
@mkdir -p $(ARTIFACTS)
@@ -177,6 +181,7 @@ check-dirty:
177181

178182
generate: ## Generate .proto definitions.
179183
@$(MAKE) local-$@ DEST=./
184+
@sed -i "s/appVersion: .*/appVersion: \"$$(cat internal/version/data/tag)\"/" test/test-helm-chart/Chart.yaml
180185

181186
lint-golangci-lint: ## Runs golangci-lint linter.
182187
@$(MAKE) target-$@
@@ -255,6 +260,44 @@ lint-fmt: lint-golangci-lint-fmt ## Run all linter formatters and fix up the so
255260
image-kres: ## Builds image for kres.
256261
@$(MAKE) registry-$@ IMAGE_NAME="kres"
257262

263+
.PHONY: helm
264+
helm: ## Package helm chart
265+
@helm package test/test-helm-chart -d $(ARTIFACTS)
266+
267+
.PHONY: helm-release
268+
helm-release: helm ## Release helm chart
269+
@helm push $(ARTIFACTS)/test-helm-chart-*.tgz oci://$(HELMREPO) 2>&1 | tee $(ARTIFACTS)/.digest
270+
@cosign sign --yes $(COSIGN_ARGS) $(HELMREPO)/test-helm-chart@$$(cat $(ARTIFACTS)/.digest | awk -F "[, ]+" '/Digest/{print $$NF}')
271+
272+
.PHONY: chart-lint
273+
chart-lint: ## Lint helm chart
274+
@helm lint test/test-helm-chart
275+
276+
.PHONY: helm-plugin-install
277+
helm-plugin-install: ## Install helm plugins
278+
-helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version=v1.0.3
279+
-helm plugin install https://github.com/losisin/helm-values-schema-json.git --verify=false --version=v2.3.1
280+
281+
.PHONY: kuttl-plugin-install
282+
kuttl-plugin-install: ## Install kubectl kuttl plugin
283+
kubectl krew install kuttl
284+
285+
.PHONY: chart-e2e
286+
chart-e2e: ## Run helm chart e2e tests
287+
export KUBECONFIG=$(shell pwd)/$(ARTIFACTS)/kubeconfig && cd test/e2e && kubectl kuttl test
288+
289+
.PHONY: chart-unittest
290+
chart-unittest: $(ARTIFACTS) ## Run helm chart unit tests
291+
@helm unittest test/test-helm-chart --output-type junit --output-file $(ARTIFACTS)/helm-unittest-report.xml
292+
293+
.PHONY: chart-gen-schema
294+
chart-gen-schema: ## Generate helm chart schema
295+
@helm schema --use-helm-docs --draft=7 --indent=2 --values=test/test-helm-chart/values.yaml --output=test/test-helm-chart/values.schema.json
296+
297+
.PHONY: helm-docs
298+
helm-docs: ## Runs helm-docs and generates chart documentation
299+
@$(MAKE) local-$@ DEST=.
300+
258301
.PHONY: rekres
259302
rekres:
260303
@docker pull $(KRES_IMAGE)

internal/project/auto/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ type Helm struct {
5252

5353
// HelmTemplate defines helm template settings.
5454
type HelmTemplate struct {
55-
Set []string `yaml:"set"`
56-
SetFile []string `yaml:"setFile"`
57-
SetJSON []string `yaml:"setJSON"`
58-
SetLiteral []string `yaml:"setLiteral"`
59-
SetString []string `yaml:"setString"`
55+
ValuesFiles []string `yaml:"valuesFiles"`
56+
Set []string `yaml:"set"`
57+
SetFile []string `yaml:"setFile"`
58+
SetJSON []string `yaml:"setJSON"`
59+
SetLiteral []string `yaml:"setLiteral"`
60+
SetString []string `yaml:"setString"`
6061
}
6162

6263
// IntegrationTests defines integration tests builder to be generated.

internal/project/auto/helm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func (builder *builder) DetectHelm() (bool, error) {
4343

4444
var flags []string
4545

46+
for _, valuesFile := range helm.Template.ValuesFiles {
47+
flags = append(flags, "-f", filepath.Join(builder.meta.HelmChartDir, valuesFile))
48+
}
49+
4650
for _, flag := range helm.Template.Set {
4751
flags = append(flags, "--set", flag)
4852
}

internal/project/helm/build.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (helm *Build) CompileDockerfile(output *dockerfile.Output) error {
5959
Description("runs helm-docs").
6060
From("helm-toolchain").
6161
Step(step.Copy(helm.meta.HelmChartDir, filepath.Join("/src", helm.meta.HelmChartDir))).
62-
Step(step.Run("helm-docs", "--badge-style=flat", "--template-files=README.md.gotpl").
62+
Step(step.Run("helm-docs", "--badge-style=flat").
6363
MountCache(filepath.Join(helm.meta.CachePath, "go-build"), helm.meta.GitHubRepository).
6464
MountCache(filepath.Join(helm.meta.CachePath, "helm-docs"), helm.meta.GitHubRepository, step.CacheLocked))
6565

@@ -180,8 +180,7 @@ func (helm *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
180180
}
181181

182182
templateStep := ghworkflow.Step("Template chart").
183-
SetCommand(fmt.Sprintf("helm template -f %s %s %s %s",
184-
filepath.Join(helm.meta.HelmChartDir, "values.yaml"),
183+
SetCommand(fmt.Sprintf("helm template %s %s %s",
185184
strings.Join(helm.meta.HelmTemplateFlags, " "),
186185
filepath.Base(helm.meta.HelmChartDir),
187186
helm.meta.HelmChartDir,

test/test-helm-chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

test/test-helm-chart/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: test-helm-chart
3+
description: A minimal test Helm chart for kres
4+
type: application
5+
version: 0.1.0
6+
appVersion: "1.0.0"

0 commit comments

Comments
 (0)