Skip to content

Commit 89c2053

Browse files
committed
Simplify file type validation
1 parent 6fd2312 commit 89c2053

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

sops/validate.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ package sops
22

33
import "fmt"
44

5+
var validTypes = map[string]bool{
6+
"json": true,
7+
"yaml": true,
8+
"dotenv": true,
9+
"ini": true,
10+
"raw": true,
11+
}
12+
513
// validateInputType ensures that we can decode the input
614
func validateInputType(inputType string) error {
7-
switch inputType {
8-
case "json":
9-
return nil
10-
case "yaml":
11-
return nil
12-
case "dotenv":
13-
return nil
14-
case "ini":
15-
return nil
16-
case "raw":
15+
if _, ok := validTypes[inputType]; ok {
1716
return nil
18-
default:
19-
return fmt.Errorf("Don't know how to decode file with input type %s, set input_type to json, yaml, ini, dotenv or raw as appropriate", inputType)
2017
}
18+
return fmt.Errorf("Don't know how to decode file with input type %s, set input_type as appropriate", inputType)
2119
}

0 commit comments

Comments
 (0)