mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
19 lines
465 B
Go
19 lines
465 B
Go
package utils
|
|
|
|
// JoinPatches joins array of serialized JSON patches to the single JSONPatch array
|
|
func JoinPatches(patches [][]byte) []byte {
|
|
var result []byte
|
|
if len(patches) == 0 {
|
|
return result
|
|
}
|
|
|
|
result = append(result, []byte("[\n")...)
|
|
for index, patch := range patches {
|
|
result = append(result, patch...)
|
|
if index != len(patches)-1 {
|
|
result = append(result, []byte(",\n")...)
|
|
}
|
|
}
|
|
result = append(result, []byte("\n]")...)
|
|
return result
|
|
}
|