mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-18 06:15:12 +00:00
23 lines
563 B
Go
23 lines
563 B
Go
// Copyright 2019 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package types
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
// FixKustomizationPreUnmarshalling modifies the raw data
|
|
// before marshalling - e.g. changes old field names to
|
|
// new field names.
|
|
func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) {
|
|
deprecatedFieldsMap := map[string]string{
|
|
"imageTags:": "images:",
|
|
}
|
|
for oldname, newname := range deprecatedFieldsMap {
|
|
pattern := regexp.MustCompile(oldname)
|
|
data = pattern.ReplaceAll(data, []byte(newname))
|
|
}
|
|
return data, nil
|
|
}
|