Skip to content

Commit

Permalink
Merge pull request #16 from lazychanger/hotfix/template-panic
Browse files Browse the repository at this point in the history
add more panic
  • Loading branch information
lazychanger authored Nov 17, 2022
2 parents 9c88830 + 33130ec commit ccd85a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/helm-variable-in-values/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func buildVIVEngine(args []string) (*vivEngine.Engine, error) {
}

e := vivEngine.NewEngine(&vivEngine.Config{
WorkDir: strings.TrimRight(workdir[0:len(workdir)-len(chartRequested.Name())], "/"),
WorkDir: strings.TrimRight(workdir, "/"),
Values: values,
Chart: chartRequested,
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.0
github.com/stretchr/testify v1.8.0
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.10.1
k8s.io/client-go v0.25.3
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -117,7 +118,6 @@ require (
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.25.3 // indirect
k8s.io/apiextensions-apiserver v0.25.2 // indirect
Expand Down
11 changes: 7 additions & 4 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewEngine(cfg *Config) *Engine {

func (e *Engine) RenderTo(dst string) []string {
if !path.IsAbs(dst) {
dst = path.Join(e.cfg.WorkDir, e.cfg.Chart.ChartFullPath(), dst)
dst = path.Join(e.cfg.WorkDir, dst)
}

if err := os.MkdirAll(dst, os.ModePerm); err != nil {
Expand All @@ -37,15 +37,17 @@ func (e *Engine) RenderTo(dst string) []string {

outputFiles, err := e.eachChart(e.cfg.Chart, "")
if err != nil {
log.Println(err)
return []string{}
panic(errors.Wrap(err, "eachChart failed"))
}

e.cfg.Chart.Templates = append(e.cfg.Chart.Templates, outputFiles...)
e.cfg.Chart.Files = append(e.cfg.Chart.Files, outputFiles...)
e.cfg.Chart.Raw = append(e.cfg.Chart.Raw, outputFiles...)
//

tmpls, err := engine.Render(e.cfg.Chart, e.cfg.Values)
if err != nil {
return []string{}
panic(errors.Wrap(err, "vivs render failed"))
}

outputRealFilepath := make([]string, len(outputFiles))
Expand Down Expand Up @@ -80,6 +82,7 @@ func (e *Engine) eachChart(ch *chart.Chart, node string) ([]*chart.File, error)
continue
}
f.Name = path.Join(ch.ChartFullPath()[len(e.cfg.Chart.Name()):], f.Name)
log.Printf("load viv files: %s", f.Name)
renderFiles = append(renderFiles, f)
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "viv"
version: "0.2.3"
version: "0.2.4"
usage: "get the last release name"
command: "$HELM_PLUGIN_DIR/bin/helm-viv"
description: "get the last release name"
Expand Down

0 comments on commit ccd85a1

Please sign in to comment.