|
|
@ -21,6 +21,7 @@ import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"io/fs"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
|
|
|
@ -35,13 +36,13 @@ func Crds(linter *support.Linter) {
|
|
|
|
fpath := "crds/"
|
|
|
|
fpath := "crds/"
|
|
|
|
crdsPath := filepath.Join(linter.ChartDir, fpath)
|
|
|
|
crdsPath := filepath.Join(linter.ChartDir, fpath)
|
|
|
|
|
|
|
|
|
|
|
|
crdsDirExist := linter.RunLinterRule(support.WarningSev, fpath, validateCrdsDir(crdsPath))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// crds directory is optional
|
|
|
|
// crds directory is optional
|
|
|
|
if !crdsDirExist {
|
|
|
|
if _, err := os.Stat(crdsPath); errors.Is(err, fs.ErrNotExist) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
linter.RunLinterRule(support.WarningSev, fpath, validateCrdsDir(crdsPath))
|
|
|
|
|
|
|
|
|
|
|
|
// Load chart and parse CRDs
|
|
|
|
// Load chart and parse CRDs
|
|
|
|
chart, err := loader.Load(linter.ChartDir)
|
|
|
|
chart, err := loader.Load(linter.ChartDir)
|
|
|
|
|
|
|
|
|
|
|
@ -81,10 +82,12 @@ func Crds(linter *support.Linter) {
|
|
|
|
|
|
|
|
|
|
|
|
// Validation functions
|
|
|
|
// Validation functions
|
|
|
|
func validateCrdsDir(crdsPath string) error {
|
|
|
|
func validateCrdsDir(crdsPath string) error {
|
|
|
|
if fi, err := os.Stat(crdsPath); err == nil {
|
|
|
|
fi, err := os.Stat(crdsPath)
|
|
|
|
if !fi.IsDir() {
|
|
|
|
if err != nil {
|
|
|
|
return errors.New("not a directory")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !fi.IsDir() {
|
|
|
|
|
|
|
|
return errors.New("not a directory")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|