From 9ce3da51234c07cf026251016b6f1812fcb822af Mon Sep 17 00:00:00 2001 From: Alexandr Chirkov Date: Tue, 27 Jun 2023 12:06:46 +0300 Subject: [PATCH] feat(linter): added blueprint option verification level check --- .scripts/marketplace_devices_checker/main.go | 30 ++++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.scripts/marketplace_devices_checker/main.go b/.scripts/marketplace_devices_checker/main.go index 7f648615..b21eedea 100644 --- a/.scripts/marketplace_devices_checker/main.go +++ b/.scripts/marketplace_devices_checker/main.go @@ -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 { @@ -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() { @@ -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