Skip to content

Commit 15e2650

Browse files
committed
fix
Signed-off-by: Sinelnikov Michail <mikhail.sinelnikov@flant.com>
1 parent 06d0778 commit 15e2650

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/linters/module/rules/oss_library.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ type OSSRule struct {
5151
pkg.BoolRule
5252
}
5353

54-
const ossFilename = "oss.yaml"
54+
const (
55+
ossFilename = "oss.yaml"
56+
imagesDir = "images"
57+
)
5558

5659
func (r *OSSRule) OssModuleRule(moduleRoot string, errorList *errors.LintRuleErrorsList) {
5760
errorList = errorList.WithRule(r.GetName())
@@ -60,12 +63,18 @@ func (r *OSSRule) OssModuleRule(moduleRoot string, errorList *errors.LintRuleErr
6063
errorList = errorList.WithMaxLevel(ptr.To(pkg.Ignored))
6164
}
6265

66+
imagesPath := filepath.Join(moduleRoot, imagesDir)
67+
info, err := os.Stat(imagesPath)
68+
if err != nil || !info.IsDir() {
69+
return
70+
}
71+
6372
verifyOssFile(moduleRoot, errorList)
6473
}
6574

6675
func ossFileErrorMessage(err error) string {
6776
if os.IsNotExist(err) {
68-
return "module should have " + ossFilename
77+
return fmt.Sprintf("module has %s folder, so it likely should have %s", imagesDir, ossFilename)
6978
}
7079

7180
return fmt.Sprintf("invalid %s: %s", ossFilename, err.Error())
@@ -74,7 +83,11 @@ func ossFileErrorMessage(err error) string {
7483
func verifyOssFile(moduleRoot string, errorList *errors.LintRuleErrorsList) {
7584
projects, err := readOssFile(moduleRoot)
7685
if err != nil {
77-
errorList.Error(ossFileErrorMessage(err))
86+
if os.IsNotExist(err) {
87+
errorList.Warn(ossFileErrorMessage(err))
88+
} else {
89+
errorList.Error(ossFileErrorMessage(err))
90+
}
7891

7992
return
8093
}

0 commit comments

Comments
 (0)