mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add Delete function to patch pkg
This commit is contained in:
@@ -35,3 +35,20 @@ func Exist(patches []types.PatchStrategicMerge, path string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Delete deletes patches from a PatchStrategicMerge slice
|
||||
func Delete(patches []types.PatchStrategicMerge, paths ...string) []types.PatchStrategicMerge {
|
||||
// Convert paths into PatchStrategicMerge slice
|
||||
convertedPath := make([]types.PatchStrategicMerge, len(paths))
|
||||
for i, p := range paths {
|
||||
convertedPath[i] = types.PatchStrategicMerge(p)
|
||||
}
|
||||
|
||||
filteredPatches := make([]types.PatchStrategicMerge, 0, len(patches))
|
||||
for _, containedPatch := range patches {
|
||||
if !Exist(convertedPath, string(containedPatch)) {
|
||||
filteredPatches = append(filteredPatches, containedPatch)
|
||||
}
|
||||
}
|
||||
return filteredPatches
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user