Skip to content

Commit 420d35a

Browse files
author
Mikalai Radchuk
committed
Clean up the variable source code
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent a4c5228 commit 420d35a

11 files changed

+1
-1466
lines changed

internal/resolution/variablesources/bundle.go

-49
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package variablesources
22

33
import (
4-
"context"
54
"fmt"
65
"sort"
76

87
"github.com/operator-framework/deppy/pkg/deppy"
9-
"github.com/operator-framework/deppy/pkg/deppy/input"
108
"k8s.io/apimachinery/pkg/util/sets"
119

1210
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
@@ -15,53 +13,6 @@ import (
1513
olmvariables "github.com/operator-framework/operator-controller/internal/resolution/variables"
1614
)
1715

18-
var _ input.VariableSource = &BundlesAndDepsVariableSource{}
19-
20-
type BundlesAndDepsVariableSource struct {
21-
allBundles []*catalogmetadata.Bundle
22-
variableSources []input.VariableSource
23-
}
24-
25-
func NewBundlesAndDepsVariableSource(allBundles []*catalogmetadata.Bundle, inputVariableSources ...input.VariableSource) *BundlesAndDepsVariableSource {
26-
return &BundlesAndDepsVariableSource{
27-
allBundles: allBundles,
28-
variableSources: inputVariableSources,
29-
}
30-
}
31-
32-
func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]deppy.Variable, error) {
33-
variables := []deppy.Variable{}
34-
35-
for _, variableSource := range b.variableSources {
36-
inputVariables, err := variableSource.GetVariables(ctx)
37-
if err != nil {
38-
return nil, err
39-
}
40-
variables = append(variables, inputVariables...)
41-
}
42-
43-
requiredPackages := []*olmvariables.RequiredPackageVariable{}
44-
installedPackages := []*olmvariables.InstalledPackageVariable{}
45-
for _, variable := range variables {
46-
switch v := variable.(type) {
47-
case *olmvariables.RequiredPackageVariable:
48-
requiredPackages = append(requiredPackages, v)
49-
case *olmvariables.InstalledPackageVariable:
50-
installedPackages = append(installedPackages, v)
51-
}
52-
}
53-
54-
bundles, err := MakeBundleVariables(b.allBundles, requiredPackages, installedPackages)
55-
if err != nil {
56-
return nil, err
57-
}
58-
59-
for _, v := range bundles {
60-
variables = append(variables, v)
61-
}
62-
return variables, nil
63-
}
64-
6516
func MakeBundleVariables(
6617
allBundles []*catalogmetadata.Bundle,
6718
requiredPackages []*olmvariables.RequiredPackageVariable,

internal/resolution/variablesources/bundle_deployment.go

-52
This file was deleted.

internal/resolution/variablesources/bundle_deployment_test.go

-169
This file was deleted.

0 commit comments

Comments
 (0)