From f7d8d31061581b7bc9a9e99b35debd0d03961470 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Mon, 14 Aug 2023 16:58:51 +0100 Subject: [PATCH] fix(ext/controller/flipt): correct schema for recent validation changes --- build/hack/config/flags.json | 2 +- build/hack/config/segments.json | 42 ++++++++++++++++++- .../flipt.io/v1alpha1/cmd/flipt/flag.go | 2 +- .../flipt.io/v1alpha1/cmd/flipt/segment.go | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/build/hack/config/flags.json b/build/hack/config/flags.json index 22cb6ee..fa70858 100644 --- a/build/hack/config/flags.json +++ b/build/hack/config/flags.json @@ -47,7 +47,7 @@ } } }, - "additionalProperties": false + "additionalProperties": true } } } diff --git a/build/hack/config/segments.json b/build/hack/config/segments.json index 7afa4fd..6dba017 100644 --- a/build/hack/config/segments.json +++ b/build/hack/config/segments.json @@ -15,9 +15,47 @@ "v1alpha1": { "type": "object", "properties": { - "enabled": { "type": "boolean" } + "spec": { + "type": "object", + "properties": { + "enabled": {"type": "boolean"}, + "match_type": { "enum": ["", "ANY_MATCH_TYPE", "ALL_MATCH_TYPE"]}, + "description": {"type": "string"}, + "constraints": { + "type": ["array", "null"], + "items": { + "type": "object", + "properties": { + "type": { + "enum": ["", "STRING_COMPARISON_TYPE","NUMBER_COMPARISON_TYPE","BOOLEAN_COMPARISON_TYPE","DATETIME_COMPARISON_TYPE"] + }, + "property": {"type": "string"}, + "operator": {"enum": [ + "", + "eq", + "neq", + "empty", + "notempty", + "prefix", + "suffix", + "present", + "notpresent", + "le", + "lte", + "gt", + "gte", + "true", + "false" + ]}, + "value": {"type": "string"}, + "description": {"type": "string"} + } + } + } + } + } }, - "additionalProperties": false + "additionalProperties": true } } } diff --git a/ext/controllers/flipt.io/v1alpha1/cmd/flipt/flag.go b/ext/controllers/flipt.io/v1alpha1/cmd/flipt/flag.go index b6abc8b..613f52f 100644 --- a/ext/controllers/flipt.io/v1alpha1/cmd/flipt/flag.go +++ b/ext/controllers/flipt.io/v1alpha1/cmd/flipt/flag.go @@ -165,7 +165,7 @@ func (f *Flag) MarshalJSON() (_ []byte, err error) { flag.Key = "" // key will be carried by the resource name flag.Name = "" // key will be carried by the resource name - resource.Spec, err = json.Marshal(&f.flag) + resource.Spec, err = json.Marshal(&flag) if err != nil { return nil, fmt.Errorf("marshalling flag: %w", err) } diff --git a/ext/controllers/flipt.io/v1alpha1/cmd/flipt/segment.go b/ext/controllers/flipt.io/v1alpha1/cmd/flipt/segment.go index 1b0930c..2e47f7e 100644 --- a/ext/controllers/flipt.io/v1alpha1/cmd/flipt/segment.go +++ b/ext/controllers/flipt.io/v1alpha1/cmd/flipt/segment.go @@ -165,7 +165,7 @@ func (s *Segment) MarshalJSON() (_ []byte, err error) { segment.Key = "" // key will be carried by the resource name segment.Name = "" // key will be carried by the resource name - resource.Spec, err = json.Marshal(&s.segment) + resource.Spec, err = json.Marshal(&segment) if err != nil { return nil, fmt.Errorf("marshalling segment: %w", err) }