@@ -40,7 +40,10 @@ import (
4040 platformv1alpha1 "github.com/timflannagan/platform-operators/api/v1alpha1"
4141)
4242
43- const channelName = "4.12"
43+ const (
44+ channelName = "4.12"
45+ plainProvisionerID = "core.rukpak.io/plain"
46+ )
4447
4548// PlatformOperatorReconciler reconciles a PlatformOperator object
4649type PlatformOperatorReconciler struct {
@@ -102,8 +105,27 @@ func (r *PlatformOperatorReconciler) Reconcile(ctx context.Context, req ctrl.Req
102105 return ctrl.Result {}, client .IgnoreNotFound (err )
103106 }
104107
108+ css := & operatorsv1alpha1.CatalogSourceList {}
109+ if err := r .List (ctx , css ); err != nil {
110+ log .Error (err , "failed to list the catalogsource resources in the cluster" )
111+ return ctrl.Result {}, err
112+ }
113+ if len (css .Items ) == 0 {
114+ log .Info ("unable to query catalog content as no catalogsources are available" )
115+ return ctrl.Result {}, nil
116+ }
117+ // TODO(tflannag): properly handle multiple catalogsources in a cluster
118+ cs := css .Items [0 ]
119+
120+ log .Info ("creating registry client from catalogsource" )
121+ rc , err := registryClient .NewClient (cs .Spec .Address )
122+ if err != nil {
123+ log .Error (err , "failed to create registry client from catalogsource" , "name" , cs .GetName (), "namespace" , cs .GetNamespace (), "address" , cs .Spec .Address )
124+ return ctrl.Result {}, err
125+ }
126+
105127 log .Info ("listing bundles from context" )
106- it , err := r . RegistryClient .ListBundles (ctx )
128+ it , err := rc .ListBundles (ctx )
107129 if err != nil {
108130 log .Error (err , "failed to list bundles in the platform operators catalog source" )
109131 return ctrl.Result {}, err
@@ -153,22 +175,19 @@ func (r *PlatformOperatorReconciler) ensureBundleInstance(ctx context.Context, p
153175
154176 _ , err := controllerutil .CreateOrUpdate (ctx , r .Client , bi , func () error {
155177 bi .SetOwnerReferences ([]metav1.OwnerReference {* controllerRef })
156- bi .Spec = * buildBundleInstance (bi . GetName (), bundle .BundlePath )
178+ bi .Spec = * buildBundleInstance (bundle .BundlePath )
157179 return nil
158180 })
159181 return err
160182}
161183
162184// createBundleInstance is responsible for taking a name and image to create an embedded BundleInstance
163- func buildBundleInstance (name , image string ) * rukpakv1alpha1.BundleInstanceSpec {
185+ func buildBundleInstance (image string ) * rukpakv1alpha1.BundleInstanceSpec {
164186 return & rukpakv1alpha1.BundleInstanceSpec {
165- ProvisionerClassName : "core.rukpak.io/plain" ,
187+ ProvisionerClassName : plainProvisionerID ,
166188 Template : & rukpakv1alpha1.BundleTemplate {
167- ObjectMeta : metav1.ObjectMeta {
168- Labels : map [string ]string {"app" : name },
169- },
170189 Spec : rukpakv1alpha1.BundleSpec {
171- ProvisionerClassName : "core.rukpak.io/plain" ,
190+ ProvisionerClassName : plainProvisionerID ,
172191 Source : rukpakv1alpha1.BundleSource {
173192 Type : rukpakv1alpha1 .SourceTypeImage ,
174193 Image : & rukpakv1alpha1.ImageSource {
0 commit comments