Skip to content

Commit a0e71fe

Browse files
Alexandr Chirkovnsmak
Alexandr Chirkov
authored andcommitted
feat(linter): added blueprint option verification level check
1 parent e8c62f2 commit a0e71fe

File tree

1 file changed

+29
-3
lines changed
  • .scripts/marketplace_devices_checker

1 file changed

+29
-3
lines changed

Diff for: β€Ž.scripts/marketplace_devices_checker/main.go

+29-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ const (
1919

2020
var errLinterFailed = errors.New("linter failed")
2121

22+
type VerificationLevel = string
23+
24+
const (
25+
VerificationLevelReadyForTesting VerificationLevel = "ready_for_testing"
26+
VerificationLevelCommunityTested VerificationLevel = "community_tested"
27+
VerificationLevelVerified VerificationLevel = "verified"
28+
)
29+
2230
type vendorID = string
2331

2432
type Vendor struct {
@@ -36,9 +44,10 @@ type Device struct {
3644
}
3745

3846
type BlueprintOption struct {
39-
Blueprint yaml.Node `yaml:"blueprint"`
40-
DisplayName yaml.Node `yaml:"display_name"`
41-
Description yaml.Node `yaml:"description"`
47+
Blueprint yaml.Node `yaml:"blueprint"`
48+
DisplayName yaml.Node `yaml:"display_name"`
49+
Description yaml.Node `yaml:"description"`
50+
VerificationLevel yaml.Node `yaml:"verification_level"`
4251
}
4352

4453
func main() {
@@ -280,6 +289,23 @@ func validateBlueprintOptions(name string, node yaml.Node) (bool, error) {
280289
return false, err
281290
}
282291

292+
if !checkRequiredAndNotEmpty(name+".verification_level", opt.VerificationLevel) {
293+
return false, err
294+
}
295+
296+
switch opt.VerificationLevel.Value {
297+
case VerificationLevelVerified,
298+
VerificationLevelReadyForTesting,
299+
VerificationLevelCommunityTested:
300+
default:
301+
logDeviceWarning(
302+
opt.VerificationLevel.Line,
303+
opt.VerificationLevel.Column,
304+
"invalid value verification_level should be only verified, community_tested or ready_for_testing",
305+
)
306+
return false, nil
307+
}
308+
283309
if len(opts) > 1 {
284310
if !checkRequiredAndNotEmpty(name+".display_name", opt.DisplayName) {
285311
return false, nil

0 commit comments

Comments
Β (0)