diff --git a/internal/project/auto/golang.go b/internal/project/auto/golang.go index 804c1bd..b06d3f0 100644 --- a/internal/project/auto/golang.go +++ b/internal/project/auto/golang.go @@ -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) diff --git a/internal/project/helm/build.go b/internal/project/helm/build.go index 36177fb..ce2d056 100644 --- a/internal/project/helm/build.go +++ b/internal/project/helm/build.go @@ -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). diff --git a/internal/project/helm/helm_docs.go b/internal/project/helm/helm_docs.go deleted file mode 100644 index 9716313..0000000 --- a/internal/project/helm/helm_docs.go +++ /dev/null @@ -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 -}