Skip to content

Commit

Permalink
Add radio & dropdown config item types (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh authored Aug 12, 2024
1 parent 4742c8b commit 4a2ac03
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions pkg/kots/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4104,6 +4104,42 @@ spec:
validRegexValidationConfigSpec,
},
expect: []domain.LintExpression{},
}, {
name: "radio-and-dropdown-config-item-types",
specFiles: domain.SpecFiles{
validKotsAppSpec,
validPreflightSpec,
validSupportBundleSpec,
{
Name: "app-config.yaml",
Path: "app-config.yaml",
Content: `apiVersion: kots.io/v1beta1
kind: Config
spec:
groups:
- name: example_settings
title: My Example Config
items:
- name: authentication_type
title: Authentication Type
default: authentication_type_anonymous
type: radio
items:
- name: authentication_type_anonymous
title: Anonymous
- name: authentication_type_password
title: Password
- name: version
title: Version
default: version_latest
type: dropdown
items:
- name: version_latest
title: latest
- name: version_123
title: 1.2.3`},
},
expect: []domain.LintExpression{},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kots/rego/kots-spec-opa-nonrendered.rego
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ lint[output] {
item := config_option.item
item.type
is_string(item.type)
not re_match("^(text|label|password|file|bool|select_one|select_many|textarea|select|heading)$", item.type)
not re_match("^(text|label|password|file|bool|select_one|select_many|textarea|select|heading|radio|dropdown)$", item.type)
field := concat(".", [config_option.field, "type"])
message := sprintf("Config option \"%s\" has an invalid type", [string(item.name)])
output := {
Expand Down

0 comments on commit 4a2ac03

Please sign in to comment.