-
Notifications
You must be signed in to change notification settings - Fork 90
/
lists.go
59 lines (46 loc) · 1.27 KB
/
lists.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package midstream
import (
kustomizetypes "sigs.k8s.io/kustomize/api/types"
)
func removeExistingImages(new []kustomizetypes.Image, existing []kustomizetypes.Image) []kustomizetypes.Image {
filteredImages := make([]kustomizetypes.Image, 0)
names := make(map[string]bool)
for _, n := range new {
names[n.Name] = true
}
for _, e := range existing {
if _, exists := names[e.Name]; !exists {
names[e.Name] = true
filteredImages = append(filteredImages, e)
}
}
return filteredImages
}
func findNewPatches(new []kustomizetypes.PatchStrategicMerge, existing []kustomizetypes.PatchStrategicMerge) []kustomizetypes.PatchStrategicMerge {
newPatches := make([]kustomizetypes.PatchStrategicMerge, 0)
names := make(map[string]bool)
for _, e := range existing {
names[string(e)] = true
}
for _, n := range new {
if _, exists := names[string(n)]; !exists {
names[string(n)] = true
newPatches = append(newPatches, n)
}
}
return newPatches
}
func findNewStrings(new []string, existing []string) []string {
newStrings := make([]string, 0)
names := make(map[string]bool)
for _, e := range existing {
names[e] = true
}
for _, n := range new {
if _, exists := names[n]; !exists {
names[n] = true
newStrings = append(newStrings, n)
}
}
return newStrings
}