|
|
|
@ -131,6 +131,7 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
|
|
|
|
|
linter.RunLinterRule(support.ErrorSev, path, validateYamlContent(err))
|
|
|
|
|
linter.RunLinterRule(support.ErrorSev, path, validateMetadataName(&yamlStruct))
|
|
|
|
|
linter.RunLinterRule(support.ErrorSev, path, validateNoDeprecations(&yamlStruct))
|
|
|
|
|
linter.RunLinterRule(support.ErrorSev, path, validateMatchSelector(&yamlStruct, renderedContent))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -185,6 +186,19 @@ func validateNoReleaseTime(manifest []byte) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// validateMatchSelector ensures that template specs have a selector declared.
|
|
|
|
|
// See https://github.com/helm/helm/issues/1990
|
|
|
|
|
func validateMatchSelector(yamlStruct *K8sYamlStruct, manifest string) error {
|
|
|
|
|
switch yamlStruct.Kind {
|
|
|
|
|
case "Deployment", "ReplicaSet", "DaemonSet", "StatefulSet":
|
|
|
|
|
// verify that matchLabels or matchExpressions is present
|
|
|
|
|
if !(strings.Contains(manifest, "matchLabels") || strings.Contains(manifest, "matchExpressions")) {
|
|
|
|
|
return fmt.Errorf("a %s must contain matchLabels or matchExpressions, and %q does not", yamlStruct.Kind, yamlStruct.Metadata.Name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// K8sYamlStruct stubs a Kubernetes YAML file.
|
|
|
|
|
//
|
|
|
|
|
// DEPRECATED: In Helm 4, this will be made a private type, as it is for use only within
|
|
|
|
|