mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-05 23:57:12 +00:00
improve custom_labels validation func
This commit is contained in:
committed by
Ryan Richard
parent
1e9f9181a1
commit
c3410c4b14
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user