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