|
1 | 1 | package bootstrap |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "k8s.io/apimachinery/pkg/util/sets" |
5 | | - |
6 | 4 | configv1 "github.com/openshift/api/config/v1" |
7 | 5 | "github.com/openshift/installer/pkg/types" |
8 | 6 | ) |
9 | 7 |
|
10 | | -type SourceSetKey struct { |
| 8 | +// sourceSetKey represents the set of fields that have to be unique to form |
| 9 | +// a merged list without duplicate entries for Image sources. |
| 10 | +type sourceSetKey struct { |
11 | 11 | Source string |
12 | 12 | SourcePolicy configv1.MirrorSourcePolicy |
13 | 13 | } |
14 | 14 |
|
15 | 15 | // MergedMirrorSets consolidates a list of ImageDigestSources so that each |
16 | 16 | // source appears only once. |
17 | 17 | func MergedMirrorSets(sources []types.ImageDigestSource) []types.ImageDigestSource { |
18 | | - sourceSet := make(map[SourceSetKey][]string) |
19 | | - mirrorSet := make(map[SourceSetKey]sets.String) |
20 | | - orderedSources := []SourceSetKey{} |
| 18 | + sourceSet := make(map[sourceSetKey][]string) |
| 19 | + mirrorSet := make(map[sourceSetKey][]string) |
| 20 | + orderedSources := []sourceSetKey{} |
21 | 21 |
|
22 | 22 | for _, group := range sources { |
23 | | - key := SourceSetKey{Source: group.Source, SourcePolicy: group.SourcePolicy} |
| 23 | + key := sourceSetKey{Source: group.Source, SourcePolicy: group.SourcePolicy} |
24 | 24 | if _, ok := sourceSet[key]; !ok { |
25 | 25 | orderedSources = append(orderedSources, key) |
26 | 26 | sourceSet[key] = nil |
27 | | - mirrorSet[key] = sets.NewString() |
| 27 | + mirrorSet[key] = nil |
28 | 28 | } |
29 | 29 | for _, mirror := range group.Mirrors { |
30 | | - if !mirrorSet[key].Has(mirror) { |
| 30 | + if _, ok := mirrorSet[key]; !ok { |
31 | 31 | sourceSet[key] = append(sourceSet[key], mirror) |
32 | | - mirrorSet[key].Insert(mirror) |
| 32 | + mirrorSet[key] = append(mirrorSet[key], mirror) |
33 | 33 | } |
34 | 34 | } |
35 | 35 | } |
|
0 commit comments