Skip to content

Commit 8d428a5

Browse files
authored
Bump Deppy to v0.3.0 (#566)
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
1 parent 8d74ce8 commit 8d428a5

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

cmd/manager/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,17 @@ func main() {
109109
cl := mgr.GetClient()
110110
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, &http.Client{Timeout: 10 * time.Second}))
111111

112+
resolver, err := solver.New()
113+
if err != nil {
114+
setupLog.Error(err, "unable to create a solver")
115+
os.Exit(1)
116+
}
117+
112118
if err = (&controllers.OperatorReconciler{
113119
Client: cl,
114120
BundleProvider: catalogClient,
115121
Scheme: mgr.GetScheme(),
116-
Resolver: solver.NewDeppySolver(),
122+
Resolver: resolver,
117123
}).SetupWithManager(mgr); err != nil {
118124
setupLog.Error(err, "unable to create controller", "controller", "Operator")
119125
os.Exit(1)

cmd/resolutioncli/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ func run(ctx context.Context, packageName, packageChannel, packageVersionRange,
144144
},
145145
})
146146

147-
resolver := solver.NewDeppySolver()
147+
resolver, err := solver.New()
148+
if err != nil {
149+
return err
150+
}
148151

149152
cl := clientBuilder.Build()
150153
catalogClient := newIndexRefClient(indexRef)
@@ -174,7 +177,7 @@ func run(ctx context.Context, packageName, packageChannel, packageVersionRange,
174177
return nil
175178
}
176179

177-
func resolve(resolver *solver.DeppySolver, variables []deppy.Variable, packageName string) (string, error) {
180+
func resolve(resolver *solver.Solver, variables []deppy.Variable, packageName string) (string, error) {
178181
solution, err := resolver.Solve(variables)
179182
if err != nil {
180183
return "", err
@@ -189,8 +192,8 @@ func resolve(resolver *solver.DeppySolver, variables []deppy.Variable, packageNa
189192
return bundle.Image, nil
190193
}
191194

192-
func bundleFromSolution(solution *solver.Solution, packageName string) (*catalogmetadata.Bundle, error) {
193-
for _, variable := range solution.SelectedVariables() {
195+
func bundleFromSolution(selection []deppy.Variable, packageName string) (*catalogmetadata.Bundle, error) {
196+
for _, variable := range selection {
194197
switch v := variable.(type) {
195198
case *olmvariables.BundleVariable:
196199
bundlePkgName := v.Bundle().Package

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/go-logr/logr v1.3.0
99
github.com/google/go-cmp v0.6.0
1010
github.com/operator-framework/catalogd v0.10.0
11-
github.com/operator-framework/deppy v0.2.0
11+
github.com/operator-framework/deppy v0.3.0
1212
github.com/operator-framework/operator-registry v1.33.0
1313
github.com/operator-framework/rukpak v0.16.0
1414
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
258258
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
259259
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
260260
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
261-
github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU=
261+
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
262262
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
263263
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
264264
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -273,8 +273,8 @@ github.com/operator-framework/api v0.19.0 h1:QU1CTJU+CufoeneA5rsNlP/uP96s8vDHWUY
273273
github.com/operator-framework/api v0.19.0/go.mod h1:SCCslqke6AVOJ5JM+NqNE1CHuAgJLScsL66pnPaSMXs=
274274
github.com/operator-framework/catalogd v0.10.0 h1:T207IQfQCcd3f31bDPCgfJcwEvmaPGV8BotqIzIvnRo=
275275
github.com/operator-framework/catalogd v0.10.0/go.mod h1:xIeR5f/Spr5rHnLp0yOi0AYetWcHvBAx9n+K3S/va2A=
276-
github.com/operator-framework/deppy v0.2.0 h1:BYdCAKli+ofFdnHPkpUKI9DygHL2A32CaDbEJk4jz6U=
277-
github.com/operator-framework/deppy v0.2.0/go.mod h1:3blHej0Hj0M17Ru2q3QrhN9OwB5/MMmFkWUmiInqs6A=
276+
github.com/operator-framework/deppy v0.3.0 h1:W8wpF0ehcTAdH2WfMyqMPI5Ja0Qv8M5FMO5cXgJvEQ8=
277+
github.com/operator-framework/deppy v0.3.0/go.mod h1:EHDxZz8fKGvuymCng3G/Ou7wuX14GaLr0cmf2u29Oog=
278278
github.com/operator-framework/operator-registry v1.33.0 h1:rFvYf6vLdXSUhoePhg8w1S5FHgyFraiNLXDwl47epck=
279279
github.com/operator-framework/operator-registry v1.33.0/go.mod h1:1V/m2m7iH/o5ROEuMxWa/yhj4ExaPGT6V/ncGS+m6Js=
280280
github.com/operator-framework/rukpak v0.16.0 h1:d6iI7lYJbR5fHqw3vnAudB5SevAQ2dnQI7C6iOZyXJU=

internal/controllers/operator_controller.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type OperatorReconciler struct {
5656
client.Client
5757
BundleProvider BundleProvider
5858
Scheme *runtime.Scheme
59-
Resolver *solver.DeppySolver
59+
Resolver *solver.Solver
6060
}
6161

6262
//+kubebuilder:rbac:groups=operators.operatorframework.io,resources=operators,verbs=get;list;watch
@@ -144,7 +144,7 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
144144
}
145145

146146
// run resolution
147-
solution, err := r.Resolver.Solve(vars)
147+
selection, err := r.Resolver.Solve(vars)
148148
if err != nil {
149149
op.Status.InstalledBundleResource = ""
150150
setInstalledStatusConditionUnknown(&op.Status.Conditions, "installation has not been attempted as resolution failed", op.GetGeneration())
@@ -153,17 +153,9 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
153153
return ctrl.Result{}, err
154154
}
155155

156-
if err := solution.Error(); err != nil {
157-
op.Status.InstalledBundleResource = ""
158-
setInstalledStatusConditionUnknown(&op.Status.Conditions, "installation has not been attempted as resolution is unsatisfiable", op.GetGeneration())
159-
op.Status.ResolvedBundleResource = ""
160-
setResolvedStatusConditionFailed(&op.Status.Conditions, err.Error(), op.GetGeneration())
161-
return ctrl.Result{}, err
162-
}
163-
164156
// lookup the bundle in the solution that corresponds to the
165157
// Operator's desired package name.
166-
bundle, err := r.bundleFromSolution(solution, op.Spec.PackageName)
158+
bundle, err := r.bundleFromSolution(selection, op.Spec.PackageName)
167159
if err != nil {
168160
op.Status.InstalledBundleResource = ""
169161
setInstalledStatusConditionUnknown(&op.Status.Conditions, "installation has not been attempted as resolution failed", op.GetGeneration())
@@ -275,8 +267,8 @@ func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alph
275267
}
276268
}
277269

278-
func (r *OperatorReconciler) bundleFromSolution(solution *solver.Solution, packageName string) (*catalogmetadata.Bundle, error) {
279-
for _, variable := range solution.SelectedVariables() {
270+
func (r *OperatorReconciler) bundleFromSolution(selection []deppy.Variable, packageName string) (*catalogmetadata.Bundle, error) {
271+
for _, variable := range selection {
280272
switch v := variable.(type) {
281273
case *olmvariables.BundleVariable:
282274
bundlePkgName := v.Bundle().Package

internal/controllers/suite_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ func newClient(t *testing.T) client.Client {
4545
}
4646

4747
func newClientAndReconciler(t *testing.T) (client.Client, *controllers.OperatorReconciler) {
48+
resolver, err := solver.New()
49+
require.NoError(t, err)
50+
4851
cl := newClient(t)
4952
fakeCatalogClient := testutil.NewFakeCatalogClient(testBundleList)
5053
reconciler := &controllers.OperatorReconciler{
5154
Client: cl,
5255
BundleProvider: &fakeCatalogClient,
5356
Scheme: sch,
54-
Resolver: solver.NewDeppySolver(),
57+
Resolver: resolver,
5558
}
5659
return cl, reconciler
5760
}

0 commit comments

Comments
 (0)