Skip to content

Commit

Permalink
feat(linter): added blueprint option verification level check
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Chirkov committed Jun 27, 2023
1 parent e8c62f2 commit 9ce3da5
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .scripts/marketplace_devices_checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const (

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

type VerificationLevel = string

const (
VerificationLevelReadyForTesting VerificationLevel = "ready_for_testing"
VerificationLevelCommunityTested VerificationLevel = "community_tested"
VerificationLevelVerified VerificationLevel = "verified"
)

type vendorID = string

type Vendor struct {
Expand All @@ -36,9 +44,10 @@ type Device struct {
}

type BlueprintOption struct {
Blueprint yaml.Node `yaml:"blueprint"`
DisplayName yaml.Node `yaml:"display_name"`
Description yaml.Node `yaml:"description"`
Blueprint yaml.Node `yaml:"blueprint"`
DisplayName yaml.Node `yaml:"display_name"`
Description yaml.Node `yaml:"description"`
VerificationLevel yaml.Node `yaml:"verification_level"`
}

func main() {
Expand Down Expand Up @@ -280,6 +289,21 @@ func validateBlueprintOptions(name string, node yaml.Node) (bool, error) {
return false, err
}

if !checkRequiredAndNotEmpty(name+".verification_level", opt.VerificationLevel) {
return false, err
}
switch opt.VerificationLevel.Value {
case VerificationLevelVerified,
VerificationLevelReadyForTesting,
VerificationLevelCommunityTested:
logDeviceWarning(
opt.VerificationLevel.Line,
opt.VerificationLevel.Column,
"invalid value verification_level should be only verified, community_tested or ready_for_testing",
)
return false, nil
}

if len(opts) > 1 {
if !checkRequiredAndNotEmpty(name+".display_name", opt.DisplayName) {
return false, nil
Expand Down

0 comments on commit 9ce3da5

Please sign in to comment.