mirror of https://github.com/linkerd/linkerd2.git
update helm render tests to consider child charts values.yaml (#4725)
* update helm render tests to read child charts values.yaml Helm installation by default, considers values.yaml for dependend charts and uses them in rendering. This function is being used for add-ons to keep the default template values, allowing further overriden from the parent chart's i.e linkerd2 values.yaml or --addon-config through CLI. This PR updates the Helm tests to reflect the same i.e consider values.yaml of chart dependencies if present. This does not have any UX changes but helps with the follow up add-on related work.
This commit is contained in:
parent
e4273522b8
commit
1dd8ae425b
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/linkerd/linkerd2/pkg/charts"
|
||||
l5dcharts "github.com/linkerd/linkerd2/pkg/charts/linkerd2"
|
||||
"github.com/linkerd/linkerd2/pkg/k8s"
|
||||
"k8s.io/helm/pkg/chartutil"
|
||||
|
@ -230,6 +231,7 @@ func chartControlPlane(t *testing.T, ha bool, addOnConfig string, ignoreOutbound
|
|||
}
|
||||
|
||||
func buildAddOnChart(t *testing.T, addon l5dcharts.AddOn, chartPartials *pb.Chart) *pb.Chart {
|
||||
rawValues := readValuesFile(t, filepath.Join("add-ons", addon.Name()))
|
||||
addOnChart := pb.Chart{
|
||||
Metadata: &pb.Metadata{
|
||||
Name: addon.Name(),
|
||||
|
@ -240,6 +242,9 @@ func buildAddOnChart(t *testing.T, addon l5dcharts.AddOn, chartPartials *pb.Char
|
|||
Dependencies: []*pb.Chart{
|
||||
chartPartials,
|
||||
},
|
||||
Values: &pb.Config{
|
||||
Raw: string(rawValues),
|
||||
},
|
||||
}
|
||||
|
||||
for _, filepath := range append(addon.ConfigStageTemplates(), addon.ControlPlaneStageTemplates()...) {
|
||||
|
@ -291,3 +296,17 @@ func readTestValues(t *testing.T, ha bool, ignoreOutboundPorts string, ignoreInb
|
|||
|
||||
return yaml.Marshal(values)
|
||||
}
|
||||
|
||||
// readValues reads values.yaml file from the given path
|
||||
func readValuesFile(t *testing.T, path string) []byte {
|
||||
|
||||
valuesFiles := []*chartutil.BufferedFile{
|
||||
{Name: chartutil.ValuesfileName},
|
||||
}
|
||||
|
||||
if err := charts.FilesReader(path+"/", valuesFiles); err != nil {
|
||||
t.Fatal("Unexpected error", err)
|
||||
}
|
||||
|
||||
return valuesFiles[0].Data
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue