mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
feat: support labels key in transformer configuration (#5556)
* feat: support labels key in transformer configuration Allow the usage of a separate transformer configuration for the labels key, similar to what is currently available for commonLabels and commonAnnotations. This aims to provide the same functionality that commonLabels currently provide for labels, since commonLabels is deprecated and slated for removal in a future release. * chore(transformerconfig): add nolint hint Add a nolint hint to the new method so the returns can stay consistent with one another. * fix: changes from code review * Rename methods `AddCommonLabelFieldSpec` and `AddLabelFieldSpec` to `AddCommonLabelsFieldSpec` and `AddLabelsFieldSpec`. * Add extra test to verify scenarios applying labels to Custom Resource Definitions.
This commit is contained in:
@@ -70,30 +70,3 @@ namoPrefix:
|
||||
t.Fatalf("expected error %s, but got %s", errMsg, err)
|
||||
}
|
||||
}
|
||||
|
||||
// please remove this failing test after implements the labels support
|
||||
func TestLoadDefaultConfigsFromFilesWithMissingFieldsLabels(t *testing.T) {
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
filePathContainsTypo := "config_contains_typo.yaml"
|
||||
if err := fSys.WriteFile(filePathContainsTypo, []byte(`
|
||||
labels:
|
||||
- path: spec/podTemplate/metadata/labels
|
||||
create: true
|
||||
kind: FlinkDeployment
|
||||
`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ldr, err := loader.NewLoader(
|
||||
loader.RestrictionRootOnly, filesys.Separator, fSys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
errMsg := "error unmarshaling JSON: while decoding JSON: json: unknown field"
|
||||
_, err = loadDefaultConfig(ldr, []string{filePathContainsTypo})
|
||||
if err == nil {
|
||||
t.Fatalf("expected to fail unmarshal yaml, but got nil %s", filePathContainsTypo)
|
||||
}
|
||||
if !strings.Contains(err.Error(), errMsg) {
|
||||
t.Fatalf("expected error %s, but got %s", errMsg, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user