Skip to content

Commit 9872bb4

Browse files
committed
add required package variable source
Signed-off-by: perdasilva <[email protected]>
1 parent 75de4af commit 9872bb4

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

internal/resolution/variable_sources/required_package/required_package.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ import (
77
"github.com/operator-framework/deppy/pkg/deppy"
88
"github.com/operator-framework/deppy/pkg/deppy/constraint"
99
"github.com/operator-framework/deppy/pkg/deppy/input"
10-
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources"
10+
11+
olmentity "github.com/operator-framework/operator-controller/internal/resolution/variable_sources/entity"
1112
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/utils/predicates"
1213
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/utils/sort"
1314
)
1415

1516
type RequiredPackageVariable struct {
1617
*input.SimpleVariable
17-
bundleEntities []*variable_sources.BundleEntity
18+
bundleEntities []*olmentity.BundleEntity
1819
}
1920

20-
func (r *RequiredPackageVariable) BundleEntities() []*variable_sources.BundleEntity {
21+
func (r *RequiredPackageVariable) BundleEntities() []*olmentity.BundleEntity {
2122
return r.bundleEntities
2223
}
2324

24-
func NewRequiredPackageVariable(packageName string, bundleEntities []*variable_sources.BundleEntity) *RequiredPackageVariable {
25+
func NewRequiredPackageVariable(packageName string, bundleEntities []*olmentity.BundleEntity) *RequiredPackageVariable {
2526
id := deppy.IdentifierFromString(fmt.Sprintf("required package %s", packageName))
2627
var entityIDs []deppy.Identifier
2728
for _, bundle := range bundleEntities {
@@ -55,9 +56,9 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context, entity
5556
return nil, fmt.Errorf("package '%s' not found", r.packageName)
5657
}
5758
resultSet = resultSet.Sort(sort.ByChannelAndVersion)
58-
var bundleEntities []*variable_sources.BundleEntity
59+
var bundleEntities []*olmentity.BundleEntity
5960
for i := 0; i < len(resultSet); i++ {
60-
bundleEntities = append(bundleEntities, variable_sources.NewBundleEntity(&resultSet[i]))
61+
bundleEntities = append(bundleEntities, olmentity.NewBundleEntity(&resultSet[i]))
6162
}
6263
return []deppy.Variable{
6364
NewRequiredPackageVariable(r.packageName, bundleEntities),

internal/resolution/variable_sources/required_package/required_package_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
. "github.com/onsi/gomega"
1010
"github.com/operator-framework/deppy/pkg/deppy"
1111
"github.com/operator-framework/deppy/pkg/deppy/input"
12-
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources"
13-
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/required_package"
1412
"github.com/operator-framework/operator-registry/alpha/property"
13+
14+
olmentity "github.com/operator-framework/operator-controller/internal/resolution/variable_sources/entity"
15+
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/required_package"
1516
)
1617

1718
func TestRequiredPackage(t *testing.T) {
@@ -23,21 +24,21 @@ var _ = Describe("RequiredPackageVariable", func() {
2324
var (
2425
rpv *required_package.RequiredPackageVariable
2526
packageName string
26-
bundleEntities []*variable_sources.BundleEntity
27+
bundleEntities []*olmentity.BundleEntity
2728
)
2829

2930
BeforeEach(func() {
3031
packageName = "test-package"
31-
bundleEntities = []*variable_sources.BundleEntity{
32-
variable_sources.NewBundleEntity(input.NewEntity("bundle-1", map[string]string{
32+
bundleEntities = []*olmentity.BundleEntity{
33+
olmentity.NewBundleEntity(input.NewEntity("bundle-1", map[string]string{
3334
property.TypePackage: `{"packageName": "test-package", "version": "1.0.0"}`,
3435
property.TypeChannel: `{"channelName":"stable","priority":0}`,
3536
})),
36-
variable_sources.NewBundleEntity(input.NewEntity("bundle-2", map[string]string{
37+
olmentity.NewBundleEntity(input.NewEntity("bundle-2", map[string]string{
3738
property.TypePackage: `{"packageName": "test-package", "version": "2.0.0"}`,
3839
property.TypeChannel: `{"channelName":"stable","priority":0}`,
3940
})),
40-
variable_sources.NewBundleEntity(input.NewEntity("bundle-3", map[string]string{
41+
olmentity.NewBundleEntity(input.NewEntity("bundle-3", map[string]string{
4142
property.TypePackage: `{"packageName": "test-package", "version": "3.0.0"}`,
4243
property.TypeChannel: `{"channelName":"stable","priority":0}`,
4344
})),
@@ -104,16 +105,16 @@ var _ = Describe("RequiredPackageVariableSource", func() {
104105
Expect(reqPackageVar.Identifier()).To(Equal(deppy.IdentifierFromString(fmt.Sprintf("required package %s", packageName))))
105106

106107
// ensure bundle entities are in version order
107-
Expect(reqPackageVar.BundleEntities()).To(Equal([]*variable_sources.BundleEntity{
108-
variable_sources.NewBundleEntity(input.NewEntity("bundle-2", map[string]string{
108+
Expect(reqPackageVar.BundleEntities()).To(Equal([]*olmentity.BundleEntity{
109+
olmentity.NewBundleEntity(input.NewEntity("bundle-2", map[string]string{
109110
property.TypePackage: `{"packageName": "test-package", "version": "3.0.0"}`,
110111
property.TypeChannel: `{"channelName":"stable","priority":0}`,
111112
})),
112-
variable_sources.NewBundleEntity(input.NewEntity("bundle-3", map[string]string{
113+
olmentity.NewBundleEntity(input.NewEntity("bundle-3", map[string]string{
113114
property.TypePackage: `{"packageName": "test-package", "version": "2.0.0"}`,
114115
property.TypeChannel: `{"channelName":"stable","priority":0}`,
115116
})),
116-
variable_sources.NewBundleEntity(input.NewEntity("bundle-1", map[string]string{
117+
olmentity.NewBundleEntity(input.NewEntity("bundle-1", map[string]string{
117118
property.TypePackage: `{"packageName": "test-package", "version": "1.0.0"}`,
118119
property.TypeChannel: `{"channelName":"stable","priority":0}`})),
119120
}))

0 commit comments

Comments
 (0)