feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
@@ -45,7 +45,12 @@ var (
|
||||
)
|
||||
|
||||
// Templates lints the templates in the Linter.
|
||||
func Templates(linter *support.Linter, values map[string]interface{}, namespace string, strict bool) {
|
||||
func Templates(linter *support.Linter, values map[string]interface{}, namespace string, _ bool) {
|
||||
TemplatesWithKubeVersion(linter, values, namespace, nil)
|
||||
}
|
||||
|
||||
// TemplatesWithKubeVersion lints the templates in the Linter, allowing to specify the kubernetes version.
|
||||
func TemplatesWithKubeVersion(linter *support.Linter, values map[string]interface{}, namespace string, kubeVersion *chartutil.KubeVersion) {
|
||||
fpath := "templates/"
|
||||
templatesPath := filepath.Join(linter.ChartDir, fpath)
|
||||
|
||||
@@ -70,9 +75,14 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
|
||||
Namespace: namespace,
|
||||
}
|
||||
|
||||
caps := chartutil.DefaultCapabilities.Copy()
|
||||
if kubeVersion != nil {
|
||||
caps.KubeVersion = *kubeVersion
|
||||
}
|
||||
|
||||
// lint ignores import-values
|
||||
// See https://github.com/helm/helm/issues/9658
|
||||
if err := chartutil.ProcessDependencies(chart, values); err != nil {
|
||||
if err := chartutil.ProcessDependenciesWithMerge(chart, values); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -80,7 +90,8 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
valuesToRender, err := chartutil.ToRenderValues(chart, cvals, options, nil)
|
||||
|
||||
valuesToRender, err := chartutil.ToRenderValues(chart, cvals, options, caps)
|
||||
if err != nil {
|
||||
linter.RunLinterRule(support.ErrorSev, fpath, err)
|
||||
return
|
||||
@@ -141,15 +152,16 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace
|
||||
break
|
||||
}
|
||||
|
||||
// If YAML linting fails, we sill progress. So we don't capture the returned state
|
||||
// on this linter run.
|
||||
linter.RunLinterRule(support.ErrorSev, fpath, validateYamlContent(err))
|
||||
|
||||
// If YAML linting fails here, it will always fail in the next block as well, so we should return here.
|
||||
// fix https://github.com/helm/helm/issues/11391
|
||||
if !linter.RunLinterRule(support.ErrorSev, fpath, validateYamlContent(err)) {
|
||||
return
|
||||
}
|
||||
if yamlStruct != nil {
|
||||
// NOTE: set to warnings to allow users to support out-of-date kubernetes
|
||||
// Refs https://github.com/helm/helm/issues/8596
|
||||
linter.RunLinterRule(support.WarningSev, fpath, validateMetadataName(yamlStruct))
|
||||
linter.RunLinterRule(support.WarningSev, fpath, validateNoDeprecations(yamlStruct))
|
||||
linter.RunLinterRule(support.WarningSev, fpath, validateNoDeprecations(yamlStruct, kubeVersion))
|
||||
|
||||
linter.RunLinterRule(support.ErrorSev, fpath, validateMatchSelector(yamlStruct, renderedContent))
|
||||
linter.RunLinterRule(support.ErrorSev, fpath, validateListAnnotations(yamlStruct, renderedContent))
|
||||
@@ -187,10 +199,10 @@ func validateTopIndentLevel(content string) error {
|
||||
|
||||
// Validation functions
|
||||
func validateTemplatesDir(templatesPath string) error {
|
||||
if fi, err := os.Stat(templatesPath); err != nil {
|
||||
return errors.New("directory not found")
|
||||
} else if !fi.IsDir() {
|
||||
return errors.New("not a directory")
|
||||
if fi, err := os.Stat(templatesPath); err == nil {
|
||||
if !fi.IsDir() {
|
||||
return errors.New("not a directory")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user