@@ -19,6 +19,7 @@ package controllers
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "strings"
22
23
23
24
"github.com/go-logr/logr"
24
25
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
@@ -152,6 +153,12 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
152
153
return ctrl.Result {}, err
153
154
}
154
155
156
+ sourceType := rukpakv1alpha1 .SourceTypeImage
157
+ if strings .HasPrefix (bundleImage , "oci://" ) {
158
+ sourceType = rukpakv1alpha1 .SourceTypeOCIArtifact
159
+ bundleImage = strings .TrimPrefix (bundleImage , "oci://" )
160
+ }
161
+
155
162
// Now we can set the Resolved Condition, and the resolvedBundleSource field to the bundleImage value.
156
163
op .Status .ResolvedBundleResource = bundleImage
157
164
setResolvedStatusConditionSuccess (& op .Status .Conditions , fmt .Sprintf ("resolved to %q" , bundleImage ), op .GetGeneration ())
@@ -166,9 +173,10 @@ func (r *OperatorReconciler) reconcile(ctx context.Context, op *operatorsv1alpha
166
173
setInstalledStatusConditionFailed (& op .Status .Conditions , err .Error (), op .GetGeneration ())
167
174
return ctrl.Result {}, err
168
175
}
176
+
169
177
// Ensure a BundleDeployment exists with its bundle source from the bundle
170
178
// image we just looked up in the solution.
171
- dep := r .generateExpectedBundleDeployment (* op , bundleImage , bundleProvisioner )
179
+ dep := r .generateExpectedBundleDeployment (* op , bundleImage , bundleProvisioner , sourceType )
172
180
if err := r .ensureBundleDeployment (ctx , dep ); err != nil {
173
181
// originally Reason: operatorsv1alpha1.ReasonInstallationFailed
174
182
op .Status .InstalledBundleResource = ""
@@ -261,7 +269,7 @@ func (r *OperatorReconciler) getBundleEntityFromSolution(solution *solver.Soluti
261
269
return nil , fmt .Errorf ("entity for package %q not found in solution" , packageName )
262
270
}
263
271
264
- func (r * OperatorReconciler ) generateExpectedBundleDeployment (o operatorsv1alpha1.Operator , bundlePath string , bundleProvisioner string ) * unstructured.Unstructured {
272
+ func (r * OperatorReconciler ) generateExpectedBundleDeployment (o operatorsv1alpha1.Operator , bundlePath string , bundleProvisioner string , sourceType rukpakv1alpha1. SourceType ) * unstructured.Unstructured {
265
273
// We use unstructured here to avoid problems of serializing default values when sending patches to the apiserver.
266
274
// If you use a typed object, any default values from that struct get serialized into the JSON patch, which could
267
275
// cause unrelated fields to be patched back to the default value even though that isn't the intention. Using an
@@ -281,9 +289,8 @@ func (r *OperatorReconciler) generateExpectedBundleDeployment(o operatorsv1alpha
281
289
"spec" : map [string ]interface {}{
282
290
"provisionerClassName" : bundleProvisioner ,
283
291
"source" : map [string ]interface {}{
284
- // TODO: Don't assume artifact type
285
- "type" : rukpakv1alpha1 .SourceTypeOCIArtifact ,
286
- string (rukpakv1alpha1 .SourceTypeOCIArtifact ): map [string ]interface {}{
292
+ "type" : sourceType ,
293
+ string (sourceType ): map [string ]interface {}{
287
294
"ref" : bundlePath ,
288
295
},
289
296
},
0 commit comments