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:
@@ -143,15 +143,16 @@ func TestParseAnnotations(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
annotations: []string{"a="},
|
||||
expectedErr: "invalid annotation format: a=",
|
||||
scenario: "incorrect annotation input (missing value)",
|
||||
expectErr: true,
|
||||
annotations: []string{"a="},
|
||||
expected: map[string]string{"a": ""},
|
||||
expectedRemove: []string{},
|
||||
scenario: "add valid annotation with empty value",
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
annotations: []string{"ab", "a="},
|
||||
expectedErr: "invalid annotation format: ab, a=",
|
||||
scenario: "incorrect multiple annotation input (missing value)",
|
||||
expectedErr: "invalid annotation format: ab",
|
||||
scenario: "incorrect annotation input (missing =value)",
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user