mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 09:49:13 +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
|
continue
|
||||||
}
|
}
|
||||||
if err := o.writeToMap(lbl.Pairs, kind); err != nil {
|
if err := o.writeToMapEntry(lbl.Pairs, k, v, kind); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
m.Labels = append(m.Labels, lbl)
|
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",
|
name: "overwrite label with same settings",
|
||||||
baseLabels: []types.Label{
|
baseLabels: []types.Label{
|
||||||
|
|||||||
Reference in New Issue
Block a user