Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route: Check for routes only if the component is managed (PROJQUAY-6007) #853

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ bin
tmp
cover.out
kubeconfig
.DS_Store
.DS_Store
.vscode
.idea
9 changes: 9 additions & 0 deletions apis/quay/v1/quayregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ func ComponentIsManaged(components []Component, name ComponentKind) bool {
return false
}

func ComponentIsExplicitlyDefined(components []Component, name ComponentKind) bool {
for _, c := range components {
if c.Kind == name {
return true
}
}
return false
}

// RequiredComponent returns whether the given component is required for Quay or not.
func RequiredComponent(component ComponentKind) bool {
for _, c := range requiredComponents {
Expand Down
17 changes: 17 additions & 0 deletions controllers/quay/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ func (r *QuayRegistryReconciler) checkRoutesAvailable(
// NOTE: The `route` component is unique because we allow users to set the
// `SERVER_HOSTNAME` field instead of controlling the entire fieldgroup. This
// value is then passed to the created `Route` using a Kustomize variable.

// REFACTOR: The below `qctx` obj setting the hostname should be put in a separate function.
var config map[string]interface{}
if err := yaml.Unmarshal(bundle.Data["config.yaml"], &config); err != nil {
return fmt.Errorf("unable to parse config.yaml: %w", err)
Expand All @@ -206,6 +208,21 @@ func (r *QuayRegistryReconciler) checkRoutesAvailable(
qctx.ServerHostname = fieldGroup.ServerHostname
}

// for _, c := range quay.Spec.Components {
// if c.Kind == v1.ComponentRoute {
// // return c.Managed
// fmt.Println()
// }
// }

routeExplicitlyDefined := v1.ComponentIsExplicitlyDefined(quay.Spec.Components, v1.ComponentRoute)

// If route is unmanaged, skip routes check
routeManaged := v1.ComponentIsManaged(quay.Spec.Components, v1.ComponentRoute)
if routeExplicitlyDefined && !routeManaged {
return nil
}

fakeRoute := v1.EnsureOwnerReference(
quay,
&routev1.Route{
Expand Down