Replace patchesJson6902 field with patches.

This commit is contained in:
Eyob Tefera
2020-08-01 08:55:00 +00:00
parent 7eac250cf4
commit bc5859d44b

View File

@@ -9,14 +9,15 @@ import (
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
) )
// FixKustomizationPreUnmarshalling modies the raw data // FixKustomizationPreUnmarshalling modifies the raw data
// before marshalling - e.g. changes old field names to // before marshalling - e.g. changes old field names to
// new field names. // new field names.
func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) { func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) {
deprecateFieldsMap := map[string]string{ deprecatedFieldsMap := map[string]string{
"imageTags:": "images:", "imageTags:": "images:",
"patchesJson6902": "patches",
} }
for oldname, newname := range deprecateFieldsMap { for oldname, newname := range deprecatedFieldsMap {
pattern := regexp.MustCompile(oldname) pattern := regexp.MustCompile(oldname)
data = pattern.ReplaceAll(data, []byte(newname)) data = pattern.ReplaceAll(data, []byte(newname))
} }