mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
Merge pull request #5991 from isarns/fix/labels-without-selector-duplicate-key-error
Fix duplicate key error when adding multiple labels with --without-selector
This commit is contained in:
@@ -183,7 +183,7 @@ func (o *addMetadataOptions) writeToLabels(m *types.Kustomization, kind kindOfAd
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := o.writeToMap(lbl.Pairs, kind); err != nil {
|
||||
if err := o.writeToMapEntry(lbl.Pairs, k, v, kind); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Labels = append(m.Labels, lbl)
|
||||
|
||||
@@ -375,6 +375,19 @@ func TestAddLabelWithoutSelector(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add multiple labels without selector",
|
||||
baseLabels: []types.Label{},
|
||||
options: addMetadataOptions{
|
||||
labelsWithoutSelector: true,
|
||||
metadata: map[string]string{"test1": "a", "test2": "b"},
|
||||
},
|
||||
expected: []types.Label{
|
||||
{
|
||||
Pairs: map[string]string{"test1": "a", "test2": "b"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "overwrite label with same settings",
|
||||
baseLabels: []types.Label{
|
||||
|
||||
Reference in New Issue
Block a user