Skip to content

Commit

Permalink
Clean up the variable source code
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola committed Nov 7, 2023
1 parent e31e43d commit f564436
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 1,466 deletions.
49 changes: 0 additions & 49 deletions internal/resolution/variablesources/bundle.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package variablesources

import (
"context"
"fmt"
"sort"

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

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

var _ input.VariableSource = &BundlesAndDepsVariableSource{}

type BundlesAndDepsVariableSource struct {
allBundles []*catalogmetadata.Bundle
variableSources []input.VariableSource
}

func NewBundlesAndDepsVariableSource(allBundles []*catalogmetadata.Bundle, inputVariableSources ...input.VariableSource) *BundlesAndDepsVariableSource {
return &BundlesAndDepsVariableSource{
allBundles: allBundles,
variableSources: inputVariableSources,
}
}

func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]deppy.Variable, error) {
variables := []deppy.Variable{}

for _, variableSource := range b.variableSources {
inputVariables, err := variableSource.GetVariables(ctx)
if err != nil {
return nil, err
}
variables = append(variables, inputVariables...)
}

requiredPackages := []*olmvariables.RequiredPackageVariable{}
installedPackages := []*olmvariables.InstalledPackageVariable{}
for _, variable := range variables {
switch v := variable.(type) {
case *olmvariables.RequiredPackageVariable:
requiredPackages = append(requiredPackages, v)
case *olmvariables.InstalledPackageVariable:
installedPackages = append(installedPackages, v)
}
}

bundles, err := MakeBundleVariables(b.allBundles, requiredPackages, installedPackages)
if err != nil {
return nil, err
}

for _, v := range bundles {
variables = append(variables, v)
}
return variables, nil
}

func MakeBundleVariables(
allBundles []*catalogmetadata.Bundle,
requiredPackages []*olmvariables.RequiredPackageVariable,
Expand Down
52 changes: 0 additions & 52 deletions internal/resolution/variablesources/bundle_deployment.go

This file was deleted.

169 changes: 0 additions & 169 deletions internal/resolution/variablesources/bundle_deployment_test.go

This file was deleted.

Loading

0 comments on commit f564436

Please sign in to comment.