From c3410c4b144746d9099ac7540a41b4aecca74a35 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Petersen" Date: Tue, 7 Nov 2023 10:29:53 -0500 Subject: [PATCH] improve custom_labels validation func --- deploy/concierge/values.yaml | 14 +++++++++++++- deploy/supervisor/values.yaml | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/deploy/concierge/values.yaml b/deploy/concierge/values.yaml index 7bbfbfcd7..5964abb97 100644 --- a/deploy/concierge/values.yaml +++ b/deploy/concierge/values.yaml @@ -31,8 +31,20 @@ into_namespace: "" #@ not assume that there was a static install-time yaml namespace." #@schema/desc custom_labels_desc #@schema/examples ("Example set of labels", {"myCustomLabelName": "myCustomLabelValue", "otherCustomLabelName": "otherCustomLabelValue"}) +#@ def validate_labels(labels): +#@ """ +#@ Returns True if labels is an associative data structure string→string, +#@ and False otherwise. +#@ """ +#@ for label in labels: +#@ if type(label) != "string" or type(labels[label]) != "string": +#@ return False +#@ end +#@ end +#@ return True +#@ end #@schema/type any=True -#@schema/validation ("a map of keys and values", lambda v: type(v) in ["yamlfragment"]) +#@schema/validation ("a map of keys and values", validate_labels) custom_labels: {} #@schema/title "Replicas" diff --git a/deploy/supervisor/values.yaml b/deploy/supervisor/values.yaml index 8cf5e928f..223515ef1 100644 --- a/deploy/supervisor/values.yaml +++ b/deploy/supervisor/values.yaml @@ -31,8 +31,20 @@ into_namespace: "" #@ not assume that there was a static install-time yaml namespace." #@schema/desc custom_labels_desc #@schema/examples ("Example set of labels", {"myCustomLabelName": "myCustomLabelValue", "otherCustomLabelName": "otherCustomLabelValue"}) +#@ def validate_labels(labels): +#@ """ +#@ Returns True if labels is an associative data structure string→string, +#@ and False otherwise. +#@ """ +#@ for label in labels: +#@ if type(label) != "string" or type(labels[label]) != "string": +#@ return False +#@ end +#@ end +#@ return True +#@ end #@schema/type any=True -#@schema/validation ("a map of keys and values", lambda v: type(v) in ["yamlfragment"]) +#@schema/validation ("a map of keys and values", validate_labels) custom_labels: {} #@schema/title "Replicas"