mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Allow empty annotation values
Annotations with empty values can be used, for example, in diagnostics
logging. This patch removes the client-side check for empty values in
an annotation key-value pair.
**Before**
```
$ kubectl annotate pod zookeeper-1 node-selector="" --overwrite
error: invalid annotation format: node-selector=
```
**After**
```
$ kubectl annotate pod zookeeper-1 node-selector="" --overwrite
pod "zookeper-1" annotated
```
```
$ kubectl get po/zookeeper-1 --template='{{.metadata.annotations}}'
map[... node-selector: test-label:test]
```
This commit is contained in:
@@ -624,6 +624,22 @@ runTests() {
|
||||
# Post-condition: valid-pod is labelled
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{range$labels_field}}{{.}}:{{end}}" 'valid-pod:new-valid-pod:'
|
||||
|
||||
### Label the valid-pod POD with empty label value
|
||||
# Pre-condition: valid-pod does not have label "emptylabel"
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{range$labels_field}}{{.}}:{{end}}" 'valid-pod:new-valid-pod:'
|
||||
# Command
|
||||
kubectl label pods valid-pod emptylabel="" "${kube_flags[@]}"
|
||||
# Post-condition: valid pod contains "emptylabel" with no value
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{${labels_field}.emptylabel}}" ''
|
||||
|
||||
### Annotate the valid-pod POD with empty annotation value
|
||||
# Pre-condition: valid-pod does not have annotation "emptyannotation"
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{${annotations_field}.emptyannotation}}" '<no value>'
|
||||
# Command
|
||||
kubectl annotate pods valid-pod emptyannotation="" "${kube_flags[@]}"
|
||||
# Post-condition: valid pod contains "emptyannotation" with no value
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{${annotations_field}.emptyannotation}}" ''
|
||||
|
||||
### Record label change
|
||||
# Pre-condition: valid-pod does not have record annotation
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{range.items}}{{$annotations_field}}:{{end}}" ''
|
||||
|
||||
Reference in New Issue
Block a user