|
|
|
|
@ -27,8 +27,6 @@ import (
|
|
|
|
|
chartutil "helm.sh/helm/v4/pkg/chart/v2/util"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var values map[string]interface{}
|
|
|
|
|
|
|
|
|
|
const namespace = "testNamespace"
|
|
|
|
|
|
|
|
|
|
const badChartDir = "rules/testdata/badchartfile"
|
|
|
|
|
@ -41,6 +39,7 @@ const malformedTemplate = "rules/testdata/malformed-template"
|
|
|
|
|
const invalidChartFileDir = "rules/testdata/invalidchartfile"
|
|
|
|
|
|
|
|
|
|
func TestBadChart(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(badChartDir, values, namespace).Messages
|
|
|
|
|
if len(m) != 9 {
|
|
|
|
|
t.Errorf("Number of errors %v", len(m))
|
|
|
|
|
@ -95,6 +94,7 @@ func TestBadChart(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestInvalidYaml(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(badYamlFileDir, values, namespace).Messages
|
|
|
|
|
if len(m) != 1 {
|
|
|
|
|
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
|
|
|
|
@ -105,6 +105,7 @@ func TestInvalidYaml(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestInvalidChartYaml(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(invalidChartFileDir, values, namespace).Messages
|
|
|
|
|
if len(m) != 2 {
|
|
|
|
|
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
|
|
|
|
@ -115,6 +116,7 @@ func TestInvalidChartYaml(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBadValues(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(badValuesFileDir, values, namespace).Messages
|
|
|
|
|
if len(m) < 1 {
|
|
|
|
|
t.Fatalf("All didn't fail with expected errors, got %#v", m)
|
|
|
|
|
@ -125,6 +127,7 @@ func TestBadValues(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBadCrdFile(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(badCrdFileDir, values, namespace).Messages
|
|
|
|
|
assert.Lenf(t, m, 2, "All didn't fail with expected errors, got %#v", m)
|
|
|
|
|
assert.ErrorContains(t, m[0].Err, "apiVersion is not in 'apiextensions.k8s.io'")
|
|
|
|
|
@ -132,6 +135,7 @@ func TestBadCrdFile(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGoodChart(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(goodChartDir, values, namespace).Messages
|
|
|
|
|
if len(m) != 0 {
|
|
|
|
|
t.Error("All returned linter messages when it shouldn't have")
|
|
|
|
|
@ -145,6 +149,7 @@ func TestGoodChart(t *testing.T) {
|
|
|
|
|
//
|
|
|
|
|
// See https://github.com/helm/helm/issues/7923
|
|
|
|
|
func TestHelmCreateChart(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
|
|
|
|
|
createdChart, err := chartutil.Create("testhelmcreatepasseslint", dir)
|
|
|
|
|
@ -194,11 +199,11 @@ func TestHelmCreateChart_CheckDeprecatedWarnings(t *testing.T) {
|
|
|
|
|
// Add values to enable hpa, and ingress which are disabled by default.
|
|
|
|
|
// This is the equivalent of:
|
|
|
|
|
// helm lint checkdeprecatedwarnings --set 'autoscaling.enabled=true,ingress.enabled=true'
|
|
|
|
|
updatedValues := map[string]interface{}{
|
|
|
|
|
"autoscaling": map[string]interface{}{
|
|
|
|
|
updatedValues := map[string]any{
|
|
|
|
|
"autoscaling": map[string]any{
|
|
|
|
|
"enabled": true,
|
|
|
|
|
},
|
|
|
|
|
"ingress": map[string]interface{}{
|
|
|
|
|
"ingress": map[string]any{
|
|
|
|
|
"enabled": true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
@ -217,6 +222,7 @@ func TestHelmCreateChart_CheckDeprecatedWarnings(t *testing.T) {
|
|
|
|
|
// lint ignores import-values
|
|
|
|
|
// See https://github.com/helm/helm/issues/9658
|
|
|
|
|
func TestSubChartValuesChart(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
m := RunAll(subChartValuesDir, values, namespace).Messages
|
|
|
|
|
if len(m) != 0 {
|
|
|
|
|
t.Error("All returned linter messages when it shouldn't have")
|
|
|
|
|
@ -229,6 +235,7 @@ func TestSubChartValuesChart(t *testing.T) {
|
|
|
|
|
// lint stuck with malformed template object
|
|
|
|
|
// See https://github.com/helm/helm/issues/11391
|
|
|
|
|
func TestMalformedTemplate(t *testing.T) {
|
|
|
|
|
var values map[string]any
|
|
|
|
|
c := time.After(3 * time.Second)
|
|
|
|
|
ch := make(chan int, 1)
|
|
|
|
|
var m []support.Message
|
|
|
|
|
|