1
0
mirror of https://github.com/siderolabs/kres.git synced 2026-02-05 09:45:35 +01:00

fix: separate helm toolchain

Previously helm tools were added to base. This splits them
into separate stage, with proper separation.

Signed-off-by: Mateusz Urbanek <mateusz.urbanek@siderolabs.com>
This commit is contained in:
Mateusz Urbanek
2026-01-27 20:22:18 +01:00
parent 49ba5d2bab
commit c0e89fb2ac
3 changed files with 19 additions and 55 deletions

View File

@@ -18,7 +18,6 @@ import (
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/project/common"
"github.com/siderolabs/kres/internal/project/golang"
"github.com/siderolabs/kres/internal/project/helm"
"github.com/siderolabs/kres/internal/project/meta"
"github.com/siderolabs/kres/internal/project/service"
"github.com/siderolabs/kres/internal/project/wrap"
@@ -236,10 +235,7 @@ func (builder *builder) BuildGolang() error {
// add common linter tools
linters := golang.NewLinters(builder.meta)
// add helm-docs tool
helmDocs := helm.NewHelmDocs(builder.meta)
toolchain.AddInput(generate, deepcopy, linters, helmDocs)
toolchain.AddInput(generate, deepcopy, linters)
builder.lintInputs = append(builder.lintInputs, toolchain, linters)

View File

@@ -29,6 +29,10 @@ type Build struct {
// NewBuild initializes Build.
func NewBuild(meta *meta.Options) *Build {
meta.BuildArgs.Add(
"HELMDOCS_VERSION",
)
return &Build{
meta: meta,
@@ -38,9 +42,22 @@ func NewBuild(meta *meta.Options) *Build {
// CompileDockerfile implements dockerfile.Compiler.
func (helm *Build) CompileDockerfile(output *dockerfile.Output) error {
output.Stage("helm-toolchain").
Description("helm toolchain").
From("base").
Step(step.Arg("HELMDOCS_VERSION")).
Step(step.Script(
fmt.Sprintf(
"go install github.com/norwoodj/helm-docs/cmd/helm-docs@${HELMDOCS_VERSION} \\\n"+
"\t&& mv /go/bin/helm-docs %s/helm-docs", helm.meta.BinPath),
).
MountCache(filepath.Join(helm.meta.CachePath, "go-build"), helm.meta.GitHubRepository).
MountCache(filepath.Join(helm.meta.GoPath, "pkg"), helm.meta.GitHubRepository),
)
output.Stage("helm-docs-run").
Description("runs helm-docs").
From("base").
From("helm-toolchain").
Step(step.Copy(helm.meta.HelmChartDir, filepath.Join("/src", helm.meta.HelmChartDir))).
Step(step.Run("helm-docs", "--badge-style=flat", "--template-files=README.md.gotpl").
MountCache(filepath.Join(helm.meta.CachePath, "go-build"), helm.meta.GitHubRepository).

View File

@@ -1,49 +0,0 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package helm
import (
"fmt"
"path/filepath"
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/project/meta"
)
// HelmDocs is a helm-docs node.
type HelmDocs struct {
meta *meta.Options
dag.BaseNode
}
// NewHelmDocs initializes HelmDocs.
func NewHelmDocs(meta *meta.Options) *HelmDocs {
meta.BuildArgs.Add(
"HELMDOCS_VERSION",
)
return &HelmDocs{
meta: meta,
BaseNode: dag.NewBaseNode("helm-docs"),
}
}
// ToolchainBuild implements common.ToolchainBuilder hook.
func (helm *HelmDocs) ToolchainBuild(stage *dockerfile.Stage) error {
stage.
Step(step.Arg("HELMDOCS_VERSION")).
Step(step.Script(
fmt.Sprintf(
"go install github.com/norwoodj/helm-docs/cmd/helm-docs@${HELMDOCS_VERSION} \\\n"+
"\t&& mv /go/bin/helm-docs %s/helm-docs", helm.meta.BinPath),
).
MountCache(filepath.Join(helm.meta.CachePath, "go-build"), helm.meta.GitHubRepository).
MountCache(filepath.Join(helm.meta.GoPath, "pkg"), helm.meta.GitHubRepository),
)
return nil
}