mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 06:02:58 +02:00
@@ -130,7 +130,9 @@ func (c *Context) EnvExec(envs map[string]interface{}, command string, args []in
|
||||
}
|
||||
|
||||
g.Go(func() error {
|
||||
defer stdin.Close()
|
||||
defer func() {
|
||||
_ = stdin.Close()
|
||||
}()
|
||||
|
||||
size := len(input)
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ func TestReadFile_PassAbsPath(t *testing.T) {
|
||||
|
||||
func TestToYaml_UnsupportedNestedMapKey(t *testing.T) {
|
||||
expected := ``
|
||||
// nolint: unconvert
|
||||
vals := Values(map[string]interface{}{
|
||||
"foo": map[interface{}]interface{}{
|
||||
"bar": "BAR",
|
||||
@@ -125,6 +126,7 @@ func TestToYaml(t *testing.T) {
|
||||
expected := `foo:
|
||||
bar: BAR
|
||||
`
|
||||
// nolint: unconvert
|
||||
vals := Values(map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
"bar": "BAR",
|
||||
@@ -143,6 +145,7 @@ func TestFromYaml(t *testing.T) {
|
||||
raw := `foo:
|
||||
bar: BAR
|
||||
`
|
||||
// nolint: unconvert
|
||||
expected := Values(map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
"bar": "BAR",
|
||||
@@ -276,7 +279,6 @@ func TestRequired(t *testing.T) {
|
||||
|
||||
// TestRequiredEnv tests that RequiredEnv returns an error if the environment variable is not set.
|
||||
func TestRequiredEnv(t *testing.T) {
|
||||
|
||||
// test that the environment variable is not set
|
||||
envKey := "HelmFile"
|
||||
envVal, err := RequiredEnv(envKey)
|
||||
@@ -298,7 +300,6 @@ func TestRequiredEnv(t *testing.T) {
|
||||
envVal, err = RequiredEnv(envKey)
|
||||
require.Nilf(t, err, "Expected no error to be returned when environment variable %s is set to a non-empty string", envKey)
|
||||
require.Equalf(t, expected, envVal, "Expected %s to be returned when environment variable %s is set to a non-empty string", expected, envKey)
|
||||
|
||||
}
|
||||
|
||||
// TestExec tests that Exec returns the expected output.
|
||||
|
||||
@@ -2,8 +2,9 @@ package tmpl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
"text/template"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
)
|
||||
|
||||
func (c *Context) CreateFuncMap() template.FuncMap {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/variantdev/vals"
|
||||
)
|
||||
|
||||
//to generate mock run mockgen -source=expand_secret_ref.go -destination=expand_secrets_mock.go -package=tmpl
|
||||
// to generate mock run mockgen -source=expand_secret_ref.go -destination=expand_secrets_mock.go -package=tmpl
|
||||
type valClient interface {
|
||||
Eval(template map[string]interface{}) (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package tmpl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/helmfile/helmfile/pkg/environment"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/environment"
|
||||
)
|
||||
|
||||
var emptyEnvTmplData = map[string]interface{}{
|
||||
@@ -50,8 +51,7 @@ func TestRenderToBytes_Yaml(t *testing.T) {
|
||||
`
|
||||
valuesFile := "values.yaml"
|
||||
r := NewFileRenderer(func(filename string) ([]byte, error) {
|
||||
switch filename {
|
||||
case valuesFile:
|
||||
if filename == valuesFile {
|
||||
return []byte(valuesYamlContent), nil
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected filename: expected=%v, actual=%s", valuesFile, filename)
|
||||
|
||||
@@ -28,7 +28,7 @@ func get(path string, varArgs ...interface{}) (interface{}, error) {
|
||||
def = varArgs[0]
|
||||
obj = varArgs[1]
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected number of args pased to the template function get(path, [def, ]obj): expected 1 or 2, got %d, args was %v", len(varArgs), varArgs)
|
||||
return nil, fmt.Errorf("unexpected number of args passed to the template function get(path, [def, ]obj): expected 1 or 2, got %d, args was %v", len(varArgs), varArgs)
|
||||
}
|
||||
|
||||
if path == "" {
|
||||
|
||||
@@ -10,6 +10,7 @@ type TextRenderer interface {
|
||||
RenderTemplateText(text string) (string, error)
|
||||
}
|
||||
|
||||
// nolint: golint
|
||||
func NewTextRenderer(readFile func(filename string) ([]byte, error), basePath string, data interface{}) *templateTextRenderer {
|
||||
return &templateTextRenderer{
|
||||
ReadText: readFile,
|
||||
|
||||
Reference in New Issue
Block a user