drop support for legacy patches (#4911)

* drop support for legacy patches

* fix CI
This commit is contained in:
Natasha Sarkar
2022-12-07 20:06:24 -06:00
committed by GitHub
parent 8a869f6045
commit 2db573b6a0
4 changed files with 2 additions and 70 deletions

View File

@@ -5,8 +5,6 @@ package types
import (
"regexp"
"sigs.k8s.io/yaml"
)
// FixKustomizationPreUnmarshalling modifies the raw data
@@ -20,35 +18,5 @@ func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) {
pattern := regexp.MustCompile(oldname)
data = pattern.ReplaceAll(data, []byte(newname))
}
doLegacy, err := useLegacyPatch(data)
if err != nil {
return nil, err
}
if doLegacy {
pattern := regexp.MustCompile("patches:")
data = pattern.ReplaceAll(data, []byte("patchesStrategicMerge:"))
}
return data, nil
}
func useLegacyPatch(data []byte) (bool, error) {
found := false
var object map[string]interface{}
err := yaml.Unmarshal(data, &object)
if err != nil {
return false, err
}
if rawPatches, ok := object["patches"]; ok {
patches, ok := rawPatches.([]interface{})
if !ok {
return false, err
}
for _, p := range patches {
_, ok := p.(string)
if ok {
found = true
}
}
}
return found, nil
}