Skip to content

Commit

Permalink
config: unset config endpoint/unmanaged route (PROJQUAY-2049)
Browse files Browse the repository at this point in the history
Only sets status.configEditorEndpoint if cluster supports Routes and the
Route component is managed.
  • Loading branch information
ricardomaraschini authored and jonathankingfc committed Jan 25, 2022
1 parent c72d753 commit acc2122
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions apis/quay/v1/quayregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,26 @@ func EnsureRegistryEndpoint(ctx *quaycontext.QuayRegistryContext, quay *QuayRegi
return updatedQuay, quay.Status.RegistryEndpoint == updatedQuay.Status.RegistryEndpoint
}

// EnsureConfigEditorEndpoint sets the `status.configEditorEndpoint` field and returns `ok` if it was unchanged.
func EnsureConfigEditorEndpoint(ctx *quaycontext.QuayRegistryContext, quay *QuayRegistry) (*QuayRegistry, bool) {
updatedQuay := quay.DeepCopy()
// EnsureConfigEditorEndpoint sets the `status.configEditorEndpoint` field. If routes are
// not supported or route component is unmanaged this sets configEditorEndpoint to empty
// string.
func EnsureConfigEditorEndpoint(ctx *quaycontext.QuayRegistryContext, quay *QuayRegistry) {
if !ctx.SupportsRoutes {
quay.Status.ConfigEditorEndpoint = ""
return
}

if ctx.SupportsRoutes {
updatedQuay.Status.ConfigEditorEndpoint = "https://" + strings.Join([]string{
strings.Join([]string{quay.GetName(), "quay-config-editor", quay.GetNamespace()}, "-"),
ctx.ClusterHostname},
".")
if !ComponentIsManaged(quay.Spec.Components, ComponentRoute) {
quay.Status.ConfigEditorEndpoint = ""
return
}

return updatedQuay, quay.Status.ConfigEditorEndpoint == updatedQuay.Status.ConfigEditorEndpoint
quay.Status.ConfigEditorEndpoint = fmt.Sprintf(
"https://%s-quay-config-editor-%s.%s",
quay.GetName(),
quay.GetNamespace(),
ctx.ClusterHostname,
)
}

// Owns verifies if a QuayRegistry object owns provided Object.
Expand Down
2 changes: 1 addition & 1 deletion controllers/quay/quayregistry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (r *QuayRegistryReconciler) Reconcile(ctx context.Context, req ctrl.Request
}
}

updatedQuay, _ = v1.EnsureConfigEditorEndpoint(quayContext, updatedQuay)
v1.EnsureConfigEditorEndpoint(quayContext, updatedQuay)
updatedQuay.Status.ConfigEditorCredentialsSecret = configEditorCredentialsSecretFrom(deploymentObjects)

if c := v1.GetCondition(updatedQuay.Status.Conditions, v1.ConditionTypeRolloutBlocked); c != nil && c.Status == metav1.ConditionTrue && c.Reason == v1.ConditionReasonConfigInvalid {
Expand Down

0 comments on commit acc2122

Please sign in to comment.