@@ -90,6 +90,10 @@ func (r *ReconcilerJBSConfig) Reconcile(ctx context.Context, request reconcile.R
90
90
// The object is being deleted.
91
91
return reconcile.Result {}, r .handlePossibleRepositoryCleanup (ctx , & jbsConfig , log )
92
92
}
93
+ err , done := r .handleDeprecatedRegistryDefinition (ctx , & jbsConfig )
94
+ if done || err != nil {
95
+ return reconcile.Result {}, err
96
+ }
93
97
94
98
//TODO do we eventually want to allow more than one JBSConfig per namespace?
95
99
if jbsConfig .Name == v1alpha1 .JBSConfigName {
@@ -127,6 +131,32 @@ func (r *ReconcilerJBSConfig) Reconcile(ctx context.Context, request reconcile.R
127
131
return reconcile.Result {}, nil
128
132
}
129
133
134
+ func (r * ReconcilerJBSConfig ) handleDeprecatedRegistryDefinition (ctx context.Context , config * v1alpha1.JBSConfig ) (error , bool ) {
135
+ // If anything is set in the deprecated anonymous struct, copy it over to the new one.
136
+ // Note that e.g. config.Spec.ImageRegistry.Host is equivalent to config.Spec.Host due to the anonymous definition
137
+ // and is only explicit here for clarity.
138
+ if config .Spec .ImageRegistry .Host != "" || config .Spec .ImageRegistry .Port != "" ||
139
+ config .Spec .ImageRegistry .Owner != "" || config .Spec .ImageRegistry .Repository != "" || config .Spec .PrependTag != "" {
140
+
141
+ config .Spec .Registry .Host = config .Spec .ImageRegistry .Host
142
+ config .Spec .Registry .Port = config .Spec .ImageRegistry .Port
143
+ config .Spec .Registry .Owner = config .Spec .ImageRegistry .Owner
144
+ config .Spec .Registry .Repository = config .Spec .ImageRegistry .Repository
145
+ config .Spec .Registry .Insecure = config .Spec .ImageRegistry .Insecure
146
+ config .Spec .Registry .PrependTag = config .Spec .ImageRegistry .PrependTag
147
+
148
+ // Clear the old one
149
+ config .Spec .ImageRegistry .Host = ""
150
+ config .Spec .ImageRegistry .Port = ""
151
+ config .Spec .ImageRegistry .Owner = ""
152
+ config .Spec .ImageRegistry .Repository = ""
153
+ config .Spec .ImageRegistry .PrependTag = ""
154
+
155
+ return r .client .Update (ctx , config ), true
156
+ }
157
+ return nil , false
158
+ }
159
+
130
160
func (r * ReconcilerJBSConfig ) handlePossibleRepositoryCleanup (ctx context.Context , jbsConfig * v1alpha1.JBSConfig , log logr.Logger ) error {
131
161
if controllerutil .ContainsFinalizer (jbsConfig , ImageRepositoryFinalizer ) {
132
162
robotAccountName := generateRobotAccountName (jbsConfig )
0 commit comments