From bd98908028afb5e396c78a3eabf769b280707471 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Fri, 22 Oct 2021 10:52:59 +0530 Subject: [PATCH] feat(cas-config): Add 'List' option to cas-config (#1824) Signed-off-by: Niladri Halder --- pkg/apis/openebs.io/v1alpha1/cas_template.go | 2 ++ pkg/apis/openebs.io/v1alpha1/cas_template_keys.go | 6 ++++++ pkg/apis/openebs.io/v1alpha1/cas_template_test.go | 3 ++- pkg/apis/openebs.io/v1alpha1/zz_generated.deepcopy.go | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/apis/openebs.io/v1alpha1/cas_template.go b/pkg/apis/openebs.io/v1alpha1/cas_template.go index 693f18f0d4..1cccda26a4 100644 --- a/pkg/apis/openebs.io/v1alpha1/cas_template.go +++ b/pkg/apis/openebs.io/v1alpha1/cas_template.go @@ -78,6 +78,8 @@ type Config struct { Value string `json:"value"` // Data represents an arbitrary map of key value pairs Data map[string]string `json:"data"` + // List represents a JSON(YAML) array + List []string `json:"list"` } // RunTasks contains fields to run a set of diff --git a/pkg/apis/openebs.io/v1alpha1/cas_template_keys.go b/pkg/apis/openebs.io/v1alpha1/cas_template_keys.go index bd0203abdd..a1ea02eebb 100644 --- a/pkg/apis/openebs.io/v1alpha1/cas_template_keys.go +++ b/pkg/apis/openebs.io/v1alpha1/cas_template_keys.go @@ -230,6 +230,12 @@ const ( // The corresponding value will be accessed as // {{ .Policy..data }} DataPTP PolicyTLPProperty = "data" + + // ListPTP is the data property of the policy + // NOTE: + // The corresponding value will be accessed as + // {{ .Policy..list }} + ListPTP PolicyTLPProperty = "list" ) const ( diff --git a/pkg/apis/openebs.io/v1alpha1/cas_template_test.go b/pkg/apis/openebs.io/v1alpha1/cas_template_test.go index 3c9ffe282e..cc4f525e1b 100644 --- a/pkg/apis/openebs.io/v1alpha1/cas_template_test.go +++ b/pkg/apis/openebs.io/v1alpha1/cas_template_test.go @@ -64,8 +64,9 @@ func TestCASConfigJSONIndent(t *testing.T) { Name: "Replicas", Value: "2", Enabled: "false", + List: []string{"openebs.io/cpu-node"}, }, - []string{`"name": "Replicas"`, `"value": "2"`, `"enabled": "false"`}, + []string{`"name": "Replicas"`, `"value": "2"`, `"enabled": "false"`, `"openebs.io/cpu-node"`}, }, } for name, mock := range tests { diff --git a/pkg/apis/openebs.io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/openebs.io/v1alpha1/zz_generated.deepcopy.go index ce3bf22d66..3c5bcb2d66 100644 --- a/pkg/apis/openebs.io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/openebs.io/v1alpha1/zz_generated.deepcopy.go @@ -1003,6 +1003,11 @@ func (in *Config) DeepCopyInto(out *Config) { (*out)[key] = val } } + if in.List != nil { + in, out := &in.List, &out.List + *out = make([]string, len(*in)) + copy(*out, *in) + } return }