@@ -55,8 +55,8 @@ func (w *debugWriter) Write(b []byte) (int, error) {
55
55
func (r * SatResolver ) SolveOperators (namespaces []string , csvs []* v1alpha1.ClusterServiceVersion , subs []* v1alpha1.Subscription ) (cache.OperatorSet , error ) {
56
56
var errs []error
57
57
58
- installables := make (map [solver.Identifier ]solver.Installable )
59
- visited := make (map [* cache.Entry ]* BundleInstallable )
58
+ variables := make (map [solver.Identifier ]solver.Variable )
59
+ visited := make (map [* cache.Entry ]* BundleVariable )
60
60
61
61
// TODO: better abstraction
62
62
startingCSVs := make (map [string ]struct {})
@@ -68,12 +68,12 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
68
68
}
69
69
namespacedCache := r .cache .Namespaced (namespaces ... ).WithExistingOperators (existingSnapshot , namespaces [0 ])
70
70
71
- _ , existingInstallables , err := r .getBundleInstallables (namespaces [0 ], cache .Filter (existingSnapshot .Entries , cache .True ()), namespacedCache , visited )
71
+ _ , existingVariables , err := r .getBundleVariables (namespaces [0 ], cache .Filter (existingSnapshot .Entries , cache .True ()), namespacedCache , visited )
72
72
if err != nil {
73
73
return nil , err
74
74
}
75
- for _ , i := range existingInstallables {
76
- installables [i .Identifier ()] = i
75
+ for _ , i := range existingVariables {
76
+ variables [i .Identifier ()] = i
77
77
}
78
78
79
79
// build constraints for each Subscription
@@ -96,25 +96,25 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
96
96
}
97
97
98
98
// find operators, in channel order, that can skip from the current version or list the current in "replaces"
99
- subInstallables , err := r .getSubscriptionInstallables (sub , current , namespacedCache , visited )
99
+ subVariables , err := r .getSubscriptionVariables (sub , current , namespacedCache , visited )
100
100
if err != nil {
101
101
errs = append (errs , err )
102
102
continue
103
103
}
104
104
105
- for _ , i := range subInstallables {
106
- installables [i .Identifier ()] = i
105
+ for _ , i := range subVariables {
106
+ variables [i .Identifier ()] = i
107
107
}
108
108
}
109
109
110
- r .addInvariants (namespacedCache , installables )
110
+ r .addInvariants (namespacedCache , variables )
111
111
112
112
if err := namespacedCache .Error (); err != nil {
113
113
return nil , err
114
114
}
115
115
116
- input := make ([]solver.Installable , 0 )
117
- for _ , i := range installables {
116
+ input := make ([]solver.Variable , 0 )
117
+ for _ , i := range variables {
118
118
input = append (input , i )
119
119
}
120
120
@@ -125,30 +125,30 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
125
125
if err != nil {
126
126
return nil , err
127
127
}
128
- solvedInstallables , err := s .Solve (context .TODO ())
128
+ solvedVariables , err := s .Solve (context .TODO ())
129
129
if err != nil {
130
130
return nil , err
131
131
}
132
132
133
- // get the set of bundle installables from the result solved installables
134
- operatorInstallables := make ([]BundleInstallable , 0 )
135
- for _ , installable := range solvedInstallables {
136
- if bundleInstallable , ok := installable .(* BundleInstallable ); ok {
137
- _ , _ , catalog , err := bundleInstallable .BundleSourceInfo ()
133
+ // get the set of bundle variables from the result solved variables
134
+ operatorVariables := make ([]BundleVariable , 0 )
135
+ for _ , variable := range solvedVariables {
136
+ if bundleVariable , ok := variable .(* BundleVariable ); ok {
137
+ _ , _ , catalog , err := bundleVariable .BundleSourceInfo ()
138
138
if err != nil {
139
139
return nil , fmt .Errorf ("error determining origin of operator: %w" , err )
140
140
}
141
141
if catalog .Virtual () {
142
142
// Result is expected to contain only new things.
143
143
continue
144
144
}
145
- operatorInstallables = append (operatorInstallables , * bundleInstallable )
145
+ operatorVariables = append (operatorVariables , * bundleVariable )
146
146
}
147
147
}
148
148
149
149
operators := make (map [string ]* cache.Entry )
150
- for _ , installableOperator := range operatorInstallables {
151
- csvName , channel , catalog , err := installableOperator .BundleSourceInfo ()
150
+ for _ , variableOperator := range operatorVariables {
151
+ csvName , channel , catalog , err := variableOperator .BundleSourceInfo ()
152
152
if err != nil {
153
153
errs = append (errs , err )
154
154
continue
@@ -181,11 +181,11 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
181
181
BundlePath : op .BundlePath ,
182
182
Bundle : op .Bundle ,
183
183
}
184
- if len (installableOperator .Replaces ) > 0 {
185
- op .Replaces = installableOperator .Replaces
184
+ if len (variableOperator .Replaces ) > 0 {
185
+ op .Replaces = variableOperator .Replaces
186
186
}
187
187
188
- // lookup if this installable came from a starting CSV
188
+ // lookup if this variable came from a starting CSV
189
189
if _ , ok := startingCSVs [csvName ]; ok {
190
190
op .SourceInfo .StartingCSV = csvName
191
191
}
@@ -200,10 +200,10 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
200
200
return operators , nil
201
201
}
202
202
203
- // newBundleInstallableFromEntry converts an entry into a bundle installable with
203
+ // newBundleVariableFromEntry converts an entry into a bundle variable with
204
204
// system constraints applied, if they are defined for the entry
205
- func (r * SatResolver ) newBundleInstallableFromEntry (entry * cache.Entry ) (* BundleInstallable , error ) {
206
- bundleInstalleble , err := NewBundleInstallableFromOperator (entry )
205
+ func (r * SatResolver ) newBundleVariableFromEntry (entry * cache.Entry ) (* BundleVariable , error ) {
206
+ bundleInstalleble , err := NewBundleVariableFromOperator (entry )
207
207
if err != nil {
208
208
return nil , err
209
209
}
@@ -219,9 +219,9 @@ func (r *SatResolver) newBundleInstallableFromEntry(entry *cache.Entry) (*Bundle
219
219
return & bundleInstalleble , nil
220
220
}
221
221
222
- func (r * SatResolver ) getSubscriptionInstallables (sub * v1alpha1.Subscription , current * cache.Entry , namespacedCache cache.MultiCatalogOperatorFinder , visited map [* cache.Entry ]* BundleInstallable ) (map [solver.Identifier ]solver.Installable , error ) {
222
+ func (r * SatResolver ) getSubscriptionVariables (sub * v1alpha1.Subscription , current * cache.Entry , namespacedCache cache.MultiCatalogOperatorFinder , visited map [* cache.Entry ]* BundleVariable ) (map [solver.Identifier ]solver.Variable , error ) {
223
223
var cachePredicates , channelPredicates []cache.Predicate
224
- installables := make (map [solver.Identifier ]solver.Installable )
224
+ variables := make (map [solver.Identifier ]solver.Variable )
225
225
226
226
catalog := cache.SourceKey {
227
227
Name : sub .Spec .CatalogSource ,
@@ -249,21 +249,21 @@ func (r *SatResolver) getSubscriptionInstallables(sub *v1alpha1.Subscription, cu
249
249
))
250
250
entries = namespacedCache .Catalog (catalog ).Find (cachePredicates ... )
251
251
252
- var si solver.Installable
252
+ var si solver.Variable
253
253
switch {
254
254
case nall == 0 :
255
- si = NewInvalidSubscriptionInstallable (sub .GetName (), fmt .Sprintf ("no operators found from catalog %s in namespace %s referenced by subscription %s" , sub .Spec .CatalogSource , sub .Spec .CatalogSourceNamespace , sub .GetName ()))
255
+ si = NewInvalidSubscriptionVariable (sub .GetName (), fmt .Sprintf ("no operators found from catalog %s in namespace %s referenced by subscription %s" , sub .Spec .CatalogSource , sub .Spec .CatalogSourceNamespace , sub .GetName ()))
256
256
case npkg == 0 :
257
- si = NewInvalidSubscriptionInstallable (sub .GetName (), fmt .Sprintf ("no operators found in package %s in the catalog referenced by subscription %s" , sub .Spec .Package , sub .GetName ()))
257
+ si = NewInvalidSubscriptionVariable (sub .GetName (), fmt .Sprintf ("no operators found in package %s in the catalog referenced by subscription %s" , sub .Spec .Package , sub .GetName ()))
258
258
case nch == 0 :
259
- si = NewInvalidSubscriptionInstallable (sub .GetName (), fmt .Sprintf ("no operators found in channel %s of package %s in the catalog referenced by subscription %s" , sub .Spec .Channel , sub .Spec .Package , sub .GetName ()))
259
+ si = NewInvalidSubscriptionVariable (sub .GetName (), fmt .Sprintf ("no operators found in channel %s of package %s in the catalog referenced by subscription %s" , sub .Spec .Channel , sub .Spec .Package , sub .GetName ()))
260
260
case ncsv == 0 :
261
- si = NewInvalidSubscriptionInstallable (sub .GetName (), fmt .Sprintf ("no operators found with name %s in channel %s of package %s in the catalog referenced by subscription %s" , sub .Spec .StartingCSV , sub .Spec .Channel , sub .Spec .Package , sub .GetName ()))
261
+ si = NewInvalidSubscriptionVariable (sub .GetName (), fmt .Sprintf ("no operators found with name %s in channel %s of package %s in the catalog referenced by subscription %s" , sub .Spec .StartingCSV , sub .Spec .Channel , sub .Spec .Package , sub .GetName ()))
262
262
}
263
263
264
264
if si != nil {
265
- installables [si .Identifier ()] = si
266
- return installables , nil
265
+ variables [si .Identifier ()] = si
266
+ return variables , nil
267
267
}
268
268
}
269
269
@@ -305,23 +305,23 @@ func (r *SatResolver) getSubscriptionInstallables(sub *v1alpha1.Subscription, cu
305
305
}
306
306
}
307
307
308
- candidates := make ([]* BundleInstallable , 0 )
308
+ candidates := make ([]* BundleVariable , 0 )
309
309
for _ , o := range cache .Filter (sortedBundles , channelPredicates ... ) {
310
310
predicates := append (cachePredicates , cache .CSVNamePredicate (o .Name ))
311
311
stack := namespacedCache .Catalog (catalog ).Find (predicates ... )
312
- id , installable , err := r .getBundleInstallables (sub .Namespace , stack , namespacedCache , visited )
312
+ id , variable , err := r .getBundleVariables (sub .Namespace , stack , namespacedCache , visited )
313
313
if err != nil {
314
314
return nil , err
315
315
}
316
316
if len (id ) < 1 {
317
317
return nil , fmt .Errorf ("could not find any potential bundles for subscription: %s" , sub .Spec .Package )
318
318
}
319
319
320
- for _ , i := range installable {
320
+ for _ , i := range variable {
321
321
if _ , ok := id [i .Identifier ()]; ok {
322
322
candidates = append (candidates , i )
323
323
}
324
- installables [i .Identifier ()] = i
324
+ variables [i .Identifier ()] = i
325
325
}
326
326
}
327
327
@@ -347,17 +347,17 @@ func (r *SatResolver) getSubscriptionInstallables(sub *v1alpha1.Subscription, cu
347
347
}
348
348
349
349
// all candidates added as options for this constraint
350
- subInstallable := NewSubscriptionInstallable (sub .GetName (), depIds )
351
- installables [ subInstallable .Identifier ()] = subInstallable
350
+ subVariable := NewSubscriptionVariable (sub .GetName (), depIds )
351
+ variables [ subVariable .Identifier ()] = subVariable
352
352
353
- return installables , nil
353
+ return variables , nil
354
354
}
355
355
356
- func (r * SatResolver ) getBundleInstallables (preferredNamespace string , bundleStack []* cache.Entry , namespacedCache cache.MultiCatalogOperatorFinder , visited map [* cache.Entry ]* BundleInstallable ) (map [solver.Identifier ]struct {}, map [solver.Identifier ]* BundleInstallable , error ) {
356
+ func (r * SatResolver ) getBundleVariables (preferredNamespace string , bundleStack []* cache.Entry , namespacedCache cache.MultiCatalogOperatorFinder , visited map [* cache.Entry ]* BundleVariable ) (map [solver.Identifier ]struct {}, map [solver.Identifier ]* BundleVariable , error ) {
357
357
errs := make ([]error , 0 )
358
- installables := make (map [solver.Identifier ]* BundleInstallable ) // all installables , including dependencies
358
+ variables := make (map [solver.Identifier ]* BundleVariable ) // all variables , including dependencies
359
359
360
- // track the first layer of installable ids
360
+ // track the first layer of variable ids
361
361
var initial = make (map [* cache.Entry ]struct {})
362
362
for _ , o := range bundleStack {
363
363
initial [o ] = struct {}{}
@@ -372,17 +372,17 @@ func (r *SatResolver) getBundleInstallables(preferredNamespace string, bundleSta
372
372
bundleStack = bundleStack [:len (bundleStack )- 1 ]
373
373
374
374
if b , ok := visited [bundle ]; ok {
375
- installables [b .identifier ] = b
375
+ variables [b .identifier ] = b
376
376
continue
377
377
}
378
378
379
- bundleInstallable , err := r .newBundleInstallableFromEntry (bundle )
379
+ bundleVariable , err := r .newBundleVariableFromEntry (bundle )
380
380
if err != nil {
381
381
errs = append (errs , err )
382
382
continue
383
383
}
384
384
385
- visited [bundle ] = bundleInstallable
385
+ visited [bundle ] = bundleVariable
386
386
387
387
dependencyPredicates , err := r .pc .convertDependencyProperties (bundle .Properties )
388
388
if err != nil {
@@ -431,34 +431,34 @@ func (r *SatResolver) getBundleInstallables(preferredNamespace string, bundleSta
431
431
// (after sorting) to remove all bundles that
432
432
// don't satisfy the dependency.
433
433
for _ , b := range cache .Filter (sortedBundles , d ) {
434
- i , err := r .newBundleInstallableFromEntry (b )
434
+ i , err := r .newBundleVariableFromEntry (b )
435
435
if err != nil {
436
436
errs = append (errs , err )
437
437
continue
438
438
}
439
- installables [i .Identifier ()] = i
439
+ variables [i .Identifier ()] = i
440
440
bundleDependencies = append (bundleDependencies , i .Identifier ())
441
441
bundleStack = append (bundleStack , b )
442
442
}
443
- bundleInstallable .AddConstraint (PrettyConstraint (
443
+ bundleVariable .AddConstraint (PrettyConstraint (
444
444
solver .Dependency (bundleDependencies ... ),
445
445
fmt .Sprintf ("bundle %s requires an operator %s" , bundle .Name , d .String ()),
446
446
))
447
447
}
448
448
449
- installables [ bundleInstallable .Identifier ()] = bundleInstallable
449
+ variables [ bundleVariable .Identifier ()] = bundleVariable
450
450
}
451
451
452
452
if len (errs ) > 0 {
453
453
return nil , nil , utilerrors .NewAggregate (errs )
454
454
}
455
455
456
- ids := make (map [solver.Identifier ]struct {}) // immediate installables found via predicates
456
+ ids := make (map [solver.Identifier ]struct {}) // immediate variables found via predicates
457
457
for o := range initial {
458
458
ids [visited [o ].Identifier ()] = struct {}{}
459
459
}
460
460
461
- return ids , installables , nil
461
+ return ids , variables , nil
462
462
}
463
463
464
464
func (r * SatResolver ) inferProperties (csv * v1alpha1.ClusterServiceVersion , subs []* v1alpha1.Subscription ) ([]* api.Property , error ) {
@@ -571,16 +571,16 @@ func (r *SatResolver) newSnapshotForNamespace(namespace string, subs []*v1alpha1
571
571
return & cache.Snapshot {Entries : standaloneOperators }, nil
572
572
}
573
573
574
- func (r * SatResolver ) addInvariants (namespacedCache cache.MultiCatalogOperatorFinder , installables map [solver.Identifier ]solver.Installable ) {
574
+ func (r * SatResolver ) addInvariants (namespacedCache cache.MultiCatalogOperatorFinder , variables map [solver.Identifier ]solver.Variable ) {
575
575
// no two operators may provide the same GVK or Package in a namespace
576
- gvkConflictToInstallable := make (map [opregistry.GVKProperty ][]solver.Identifier )
577
- packageConflictToInstallable := make (map [string ][]solver.Identifier )
578
- for _ , installable := range installables {
579
- bundleInstallable , ok := installable .(* BundleInstallable )
576
+ gvkConflictToVariable := make (map [opregistry.GVKProperty ][]solver.Identifier )
577
+ packageConflictToVariable := make (map [string ][]solver.Identifier )
578
+ for _ , variable := range variables {
579
+ bundleVariable , ok := variable .(* BundleVariable )
580
580
if ! ok {
581
581
continue
582
582
}
583
- csvName , channel , catalog , err := bundleInstallable .BundleSourceInfo ()
583
+ csvName , channel , catalog , err := bundleVariable .BundleSourceInfo ()
584
584
if err != nil {
585
585
continue
586
586
}
@@ -600,7 +600,7 @@ func (r *SatResolver) addInvariants(namespacedCache cache.MultiCatalogOperatorFi
600
600
if err != nil {
601
601
continue
602
602
}
603
- gvkConflictToInstallable [prop ] = append (gvkConflictToInstallable [prop ], installable .Identifier ())
603
+ gvkConflictToVariable [prop ] = append (gvkConflictToVariable [prop ], variable .Identifier ())
604
604
}
605
605
606
606
// cannot have the same package
@@ -613,18 +613,18 @@ func (r *SatResolver) addInvariants(namespacedCache cache.MultiCatalogOperatorFi
613
613
if err != nil {
614
614
continue
615
615
}
616
- packageConflictToInstallable [prop .PackageName ] = append (packageConflictToInstallable [prop .PackageName ], installable .Identifier ())
616
+ packageConflictToVariable [prop .PackageName ] = append (packageConflictToVariable [prop .PackageName ], variable .Identifier ())
617
617
}
618
618
}
619
619
620
- for gvk , is := range gvkConflictToInstallable {
621
- s := NewSingleAPIProviderInstallable (gvk .Group , gvk .Version , gvk .Kind , is )
622
- installables [s .Identifier ()] = s
620
+ for gvk , is := range gvkConflictToVariable {
621
+ s := NewSingleAPIProviderVariable (gvk .Group , gvk .Version , gvk .Kind , is )
622
+ variables [s .Identifier ()] = s
623
623
}
624
624
625
- for pkg , is := range packageConflictToInstallable {
626
- s := NewSinglePackageInstanceInstallable (pkg , is )
627
- installables [s .Identifier ()] = s
625
+ for pkg , is := range packageConflictToVariable {
626
+ s := NewSinglePackageInstanceVariable (pkg , is )
627
+ variables [s .Identifier ()] = s
628
628
}
629
629
}
630
630
0 commit comments