|
|
@ -27,6 +27,7 @@ import (
|
|
|
|
"k8s.io/apimachinery/pkg/version"
|
|
|
|
"k8s.io/apimachinery/pkg/version"
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/engine"
|
|
|
|
"k8s.io/helm/pkg/engine"
|
|
|
|
|
|
|
|
"k8s.io/helm/pkg/kube"
|
|
|
|
"k8s.io/helm/pkg/lint/support"
|
|
|
|
"k8s.io/helm/pkg/lint/support"
|
|
|
|
"k8s.io/helm/pkg/timeconv"
|
|
|
|
"k8s.io/helm/pkg/timeconv"
|
|
|
|
tversion "k8s.io/helm/pkg/version"
|
|
|
|
tversion "k8s.io/helm/pkg/version"
|
|
|
@ -116,6 +117,27 @@ func Templates(linter *support.Linter) {
|
|
|
|
if !validYaml {
|
|
|
|
if !validYaml {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// access kubectl client
|
|
|
|
|
|
|
|
kubeClient := kube.New(kube.GetConfig(""))
|
|
|
|
|
|
|
|
f := kubeClient.Factory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the schema validator
|
|
|
|
|
|
|
|
schema, err := f.Validator(true, kubeClient.SchemaCacheDir)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// convert to YAML to JSON, validated above so should be ok
|
|
|
|
|
|
|
|
j, _ := yaml.YAMLToJSON([]byte(renderedContent))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
err = schema.ValidateBytes(j)
|
|
|
|
|
|
|
|
validSchema := linter.RunLinterRule(support.ErrorSev, path, validateSchema(err))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !validSchema {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -149,6 +171,13 @@ func validateYamlContent(err error) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func validateSchema(err error) error {
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("schema validation failure - %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// K8sYamlStruct stubs a Kubernetes YAML file.
|
|
|
|
// K8sYamlStruct stubs a Kubernetes YAML file.
|
|
|
|
// Need to access for now to Namespace only
|
|
|
|
// Need to access for now to Namespace only
|
|
|
|
type K8sYamlStruct struct {
|
|
|
|
type K8sYamlStruct struct {
|
|
|
|