fix env value lost in environment values (#605)

* fix env value lost in environment values

Signed-off-by: yxxhero <aiopsclub@163.com>

* add more test

Signed-off-by: yxxhero <aiopsclub@163.com>

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2022-12-27 09:48:07 +08:00
committed by GitHub
parent 6664f01596
commit d8cb740dcf
12 changed files with 111 additions and 15 deletions
+9
View File
@@ -15,6 +15,15 @@ type Environment struct {
var EmptyEnvironment Environment
// New return Environment with default name and values
func New(name string) *Environment {
return &Environment{
Name: name,
Values: map[string]interface{}{},
Defaults: map[string]interface{}{},
}
}
func (e Environment) DeepCopy() Environment {
valuesBytes, err := yaml.Marshal(e.Values)
if err != nil {
+8
View File
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
)
// See https://github.com/roboll/helmfile/issues/1150
@@ -97,3 +98,10 @@ func TestMerge_OverwriteWithNilValue_Issue1154(t *testing.T) {
t.Errorf(diff)
}
}
func TestNew(t *testing.T) {
envName := "test"
env := New(envName)
require.Equal(t, envName, env.Name, "environment name should be %s, but got %s", envName, env.Name)
}