/
template.go
38 lines (29 loc) · 1.04 KB
/
template.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
package helm
import (
"fmt"
"os"
"github.com/spf13/cobra"
"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"
"github.com/werf/werf/pkg/deploy/helm/chart_extender"
)
var templateCmdData common.CmdData
func NewTemplateCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub) *cobra.Command {
cmd, _ := helm_v3.NewTemplateCmd(actionConfig, os.Stdout, helm_v3.TemplateCmdOptions{
StagesSplitter: helm.NewStagesSplitter(),
StagesExternalDepsGenerator: helm.NewStagesExternalDepsGenerator(&actionConfig.RESTClientGetter),
ChainPostRenderer: wc.ChainPostRenderer,
})
SetupRenderRelatedWerfChartParams(cmd, &templateCmdData)
oldRunE := cmd.RunE
cmd.RunE = func(cmd *cobra.Command, args []string) error {
ctx := common.GetContext()
if err := InitRenderRelatedWerfChartParams(ctx, &templateCmdData, wc); err != nil {
return fmt.Errorf("unable to init werf chart: %w", err)
}
return oldRunE(cmd, args)
}
return cmd
}