@@ -14,33 +14,33 @@ import (
14
14
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/util/sort"
15
15
)
16
16
17
- type RequiredPackageVariable struct {
17
+ type Variable struct {
18
18
* input.SimpleVariable
19
19
bundleEntities []* olmentity.BundleEntity
20
20
}
21
21
22
- func (r * RequiredPackageVariable ) BundleEntities () []* olmentity.BundleEntity {
22
+ func (r * Variable ) BundleEntities () []* olmentity.BundleEntity {
23
23
return r .bundleEntities
24
24
}
25
25
26
- func NewRequiredPackageVariable (packageName string , bundleEntities []* olmentity.BundleEntity ) * RequiredPackageVariable {
26
+ func NewRequiredPackageVariable (packageName string , bundleEntities []* olmentity.BundleEntity ) * Variable {
27
27
id := deppy .IdentifierFromString (fmt .Sprintf ("required package %s" , packageName ))
28
28
entityIDs := make ([]deppy.Identifier , 0 , len (bundleEntities ))
29
29
for _ , bundle := range bundleEntities {
30
30
entityIDs = append (entityIDs , bundle .ID )
31
31
}
32
- return & RequiredPackageVariable {
32
+ return & Variable {
33
33
SimpleVariable : input .NewSimpleVariable (id , constraint .Mandatory (), constraint .Dependency (entityIDs ... )),
34
34
bundleEntities : bundleEntities ,
35
35
}
36
36
}
37
37
38
- var _ input.VariableSource = & RequiredPackageVariableSource {}
38
+ var _ input.VariableSource = & VariableSource {}
39
39
40
- type RequiredPackageOption func (* RequiredPackageVariableSource ) error
40
+ type Option func (* VariableSource ) error
41
41
42
- func InVersionRange (versionRange string ) RequiredPackageOption {
43
- return func (r * RequiredPackageVariableSource ) error {
42
+ func InVersionRange (versionRange string ) Option {
43
+ return func (r * VariableSource ) error {
44
44
if versionRange != "" {
45
45
vr , err := semver .ParseRange (versionRange )
46
46
if err == nil {
@@ -55,8 +55,8 @@ func InVersionRange(versionRange string) RequiredPackageOption {
55
55
}
56
56
}
57
57
58
- func InChannel (channelName string ) RequiredPackageOption {
59
- return func (r * RequiredPackageVariableSource ) error {
58
+ func InChannel (channelName string ) Option {
59
+ return func (r * VariableSource ) error {
60
60
if channelName != "" {
61
61
r .channelName = channelName
62
62
r .predicates = append (r .predicates , predicates .InChannel (channelName ))
@@ -65,18 +65,18 @@ func InChannel(channelName string) RequiredPackageOption {
65
65
}
66
66
}
67
67
68
- type RequiredPackageVariableSource struct {
68
+ type VariableSource struct {
69
69
packageName string
70
70
versionRange string
71
71
channelName string
72
72
predicates []input.Predicate
73
73
}
74
74
75
- func NewRequiredPackage (packageName string , options ... RequiredPackageOption ) (* RequiredPackageVariableSource , error ) {
75
+ func NewRequiredPackage (packageName string , options ... Option ) (* VariableSource , error ) {
76
76
if packageName == "" {
77
77
return nil , fmt .Errorf ("package name must not be empty" )
78
78
}
79
- r := & RequiredPackageVariableSource {
79
+ r := & VariableSource {
80
80
packageName : packageName ,
81
81
predicates : []input.Predicate {predicates .WithPackageName (packageName )},
82
82
}
@@ -88,7 +88,7 @@ func NewRequiredPackage(packageName string, options ...RequiredPackageOption) (*
88
88
return r , nil
89
89
}
90
90
91
- func (r * RequiredPackageVariableSource ) GetVariables (ctx context.Context , entitySource input.EntitySource ) ([]deppy.Variable , error ) {
91
+ func (r * VariableSource ) GetVariables (ctx context.Context , entitySource input.EntitySource ) ([]deppy.Variable , error ) {
92
92
resultSet , err := entitySource .Filter (ctx , input .And (r .predicates ... ))
93
93
if err != nil {
94
94
return nil , err
@@ -106,7 +106,7 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context, entity
106
106
}, nil
107
107
}
108
108
109
- func (r * RequiredPackageVariableSource ) notFoundError () error {
109
+ func (r * VariableSource ) notFoundError () error {
110
110
// TODO: update this error message when/if we decide to support version ranges as opposed to fixing the version
111
111
// context: we originally wanted to support version ranges and take the highest version that satisfies the range
112
112
// during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range
0 commit comments