7
7
8
8
"github.com/operator-framework/deppy/pkg/deppy"
9
9
"github.com/operator-framework/deppy/pkg/deppy/input"
10
+ "k8s.io/apimachinery/pkg/util/sets"
10
11
11
12
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
12
13
catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
@@ -57,7 +58,7 @@ func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]depp
57
58
}
58
59
59
60
// build bundle and dependency variables
60
- visited := map [deppy.Identifier ]struct {} {}
61
+ visited := sets. Set [deppy.Identifier ]{}
61
62
for len (bundleQueue ) > 0 {
62
63
// pop head of queue
63
64
var head * catalogmetadata.Bundle
@@ -66,10 +67,10 @@ func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]depp
66
67
id := olmvariables .BundleVariableID (head )
67
68
68
69
// ignore bundles that have already been processed
69
- if _ , ok := visited [ id ]; ok {
70
+ if visited . Has ( id ) {
70
71
continue
71
72
}
72
- visited [ id ] = struct {}{}
73
+ visited . Insert ( id )
73
74
74
75
// get bundle dependencies
75
76
dependencies , err := b .filterBundleDependencies (allBundles , head )
@@ -89,7 +90,7 @@ func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]depp
89
90
90
91
func (b * BundlesAndDepsVariableSource ) filterBundleDependencies (allBundles []* catalogmetadata.Bundle , bundle * catalogmetadata.Bundle ) ([]* catalogmetadata.Bundle , error ) {
91
92
var dependencies []* catalogmetadata.Bundle
92
- added := map [deppy.Identifier ]struct {} {}
93
+ added := sets. Set [deppy.Identifier ]{}
93
94
94
95
// gather required package dependencies
95
96
// todo(perdasilva): disambiguate between not found and actual errors
@@ -102,9 +103,9 @@ func (b *BundlesAndDepsVariableSource) filterBundleDependencies(allBundles []*ca
102
103
for i := 0 ; i < len (packageDependencyBundles ); i ++ {
103
104
bundle := packageDependencyBundles [i ]
104
105
id := olmvariables .BundleVariableID (bundle )
105
- if _ , ok := added [ id ]; ! ok {
106
+ if ! added . Has ( id ) {
106
107
dependencies = append (dependencies , bundle )
107
- added [ id ] = struct {}{}
108
+ added . Insert ( id )
108
109
}
109
110
}
110
111
}
0 commit comments