fix: lint with strict passes for helm create (#7926)

Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
pull/7960/head
Matt Butcher 5 years ago committed by GitHub
parent eb42670666
commit 0e32e6417b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -74,7 +74,7 @@ serviceAccount:
create: true create: true
# The name of the service account to use. # The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template # If not set and create is true, a name is generated using the fullname template
name: name: ""
podSecurityContext: {} podSecurityContext: {}
# fsGroup: 2000 # fsGroup: 2000

@ -17,11 +17,14 @@ limitations under the License.
package lint package lint
import ( import (
"io/ioutil"
"os"
"strings" "strings"
"testing"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/lint/support" "k8s.io/helm/pkg/lint/support"
"k8s.io/helm/pkg/proto/hapi/chart"
"testing"
) )
var values = []byte{} var values = []byte{}
@ -101,3 +104,36 @@ func TestGoodChart(t *testing.T) {
t.Errorf("All failed but shouldn't have: %#v", m) t.Errorf("All failed but shouldn't have: %#v", m)
} }
} }
// TestHelmCreateChart tests that a `helm create` always passes a `helm lint` test.
//
// See https://github.com/helm/helm/issues/7923
func TestHelmCreateChart(t *testing.T) {
dir, err := ioutil.TempDir("", "-helm-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
cfile := &chart.Metadata{
Name: "testhelmcreatepasseslint",
Description: "See lint_test.go",
Version: "0.1.0",
AppVersion: "1.0",
ApiVersion: chartutil.ApiVersionV1,
}
createdChart, err := chartutil.Create(cfile, dir)
if err != nil {
t.Error(err)
// Fatal is bad because of the defer.
return
}
m := All(createdChart, values, namespace, true).Messages
if ll := len(m); ll != 1 {
t.Errorf("All should have had exactly 1 error. Got %d", ll)
} else if msg := m[0].Err.Error(); !strings.Contains(msg, "icon is recommended") {
t.Errorf("Unexpected lint error: %s", msg)
}
}

Loading…
Cancel
Save