/
lint.go
42 lines (31 loc) · 1.16 KB
/
lint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package helm
import (
"fmt"
"os"
"github.com/spf13/cobra"
helm_v3 "helm.sh/helm/v3/cmd/helm"
"helm.sh/helm/v3/pkg/action"
"github.com/werf/werf/cmd/werf/common"
"github.com/werf/werf/pkg/deploy/helm/chart_extender"
"github.com/werf/werf/pkg/deploy/helm/chart_extender/helpers"
)
var lintCmdData common.CmdData
func NewLintCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub) *cobra.Command {
cmd := helm_v3.NewLintCmd(os.Stdout)
SetupRenderRelatedWerfChartParams(cmd, &lintCmdData)
common.SetupEnvironment(&lintCmdData, cmd)
oldRunE := cmd.RunE
cmd.RunE = func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
// NOTICE: This is temporary approach to use `werf helm lint` in pipelines correctly — respect --env / WERF_ENV param,
// NOTICE: which is typically set by the `werf ci-env` command.
if *lintCmdData.Environment != "" {
wc.SetStubServiceValuesOverrides(helpers.GetEnvServiceValues(*lintCmdData.Environment))
}
if err := InitRenderRelatedWerfChartParams(ctx, &lintCmdData, wc); err != nil {
return fmt.Errorf("unable to init werf chart: %w", err)
}
return oldRunE(cmd, args)
}
return cmd
}