File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ import (
10
10
)
11
11
12
12
var (
13
- ErrInvalidPath = errors .New ("invalid path" )
14
- ErrNoExtension = errors .New ("file without extension" )
13
+ ErrInvalidPath = errors .New ("invalid path" )
14
+ ErrInvalidExtension = errors .New ("file with invalid extension, valid extensions: .cil .pp " )
15
15
)
16
16
17
17
func NewErrInvalidPath (path string ) error {
@@ -24,8 +24,10 @@ func GetFileWithoutExtension(filename string) string {
24
24
}
25
25
26
26
func PolicyNameFromPath (path string ) (string , error ) {
27
- if filepath .Ext (path ) == "" {
28
- return "" , fmt .Errorf ("ignoring: %w" , ErrNoExtension )
27
+ switch filepath .Ext (path ) {
28
+ case ".cil" , ".pp" :
29
+ default :
30
+ return "" , fmt .Errorf ("ignoring: %w" , ErrInvalidExtension )
29
31
}
30
32
baseFile := filepath .Base (path )
31
33
policy := GetFileWithoutExtension (baseFile )
You can’t perform that action at this time.
0 commit comments