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

GatewayClass Supported features #1010

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions controller/gatewayclass/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,32 @@
return ctrl.Result{}, nil
}

if !gwc.IsAccepted() {
oldGwc := gwc.DeepCopy()
oldGwc := gwc.DeepCopy()

k8sutils.SetCondition(
k8sutils.NewConditionWithGeneration(
consts.ConditionType(gatewayv1.GatewayClassConditionStatusAccepted),
metav1.ConditionTrue,
consts.ConditionReason(gatewayv1.GatewayClassReasonAccepted),
"the gatewayclass has been accepted by the operator",
gwc.GetGeneration(),
),
gwc,
)
if err := r.Status().Patch(ctx, gwc.GatewayClass, client.MergeFrom(oldGwc)); err != nil {
if k8serrors.IsConflict(err) {
log.Debug(logger, "conflict found when updating GatewayClass, retrying")
return ctrl.Result{
Requeue: true,
RequeueAfter: controller.RequeueWithoutBackoff,
}, nil
}
return ctrl.Result{}, fmt.Errorf("failed patching GatewayClass: %w", err)
k8sutils.SetCondition(
k8sutils.NewConditionWithGeneration(
consts.ConditionType(gatewayv1.GatewayClassConditionStatusAccepted),
metav1.ConditionTrue,
consts.ConditionReason(gatewayv1.GatewayClassReasonAccepted),
"the gatewayclass has been accepted by the operator",
gwc.GetGeneration(),
),
gwc,
)

if err := setSupportedFeatures(ctx, r.Client, gwc.GatewayClass); err != nil {

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / build

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / envtest-tests

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / envtest-tests

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / unit-tests

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / unit-tests

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / lint

not enough arguments in call to setSupportedFeatures

Check failure on line 71 in controller/gatewayclass/controller.go

View workflow job for this annotation

GitHub Actions / lint

not enough arguments in call to setSupportedFeatures
return ctrl.Result{}, fmt.Errorf("failed setting supported features: %w", err)
}

if err := r.Status().Patch(ctx, gwc.GatewayClass, client.MergeFrom(oldGwc)); err != nil {
if k8serrors.IsConflict(err) {
log.Debug(logger, "conflict found when updating GatewayClass, retrying")
return ctrl.Result{
Requeue: true,
RequeueAfter: controller.RequeueWithoutBackoff,
}, nil
}
return ctrl.Result{}, fmt.Errorf("failed patching GatewayClass: %w", err)
}

return ctrl.Result{}, nil
Expand Down
28 changes: 28 additions & 0 deletions controller/gatewayclass/controller_reconciler_utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package gatewayclass

import (
"context"

"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

operatorv1beta1 "github.com/kong/gateway-operator/api/v1beta1"
"github.com/kong/gateway-operator/pkg/consts"
k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes"
)

func setSupportedFeatures(ctx context.Context, client client.Client, gwc *gatewayv1.GatewayClass, gatewayConfig *operatorv1beta1.GatewayConfiguration) error {
flavor := getRouterFlavor(gatewayConfig)

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

declared and not used: flavor

Check failure on line 15 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

declared and not used: flavor
gwc.Status.SupportedFeatures = []gatewayv1.SupportedFeature{}
}

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

missing return

Check failure on line 17 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

missing return

func getRouterFlavor(gatewayConfig *operatorv1beta1.GatewayConfiguration) consts.RouterFlavor {
if gatewayConfig == nil ||
gatewayConfig.Spec.ControlPlaneOptions == nil ||
gatewayConfig.Spec.ControlPlaneOptions.Deployment.PodTemplateSpec == nil {
return consts.RouterFlavorExpressions
}

k8sutils.GetEnvValueFromContainer(ctx, k8sutils.GetPodContainerByName(&gatewayConfig.Spec.ControlPlaneOptions.Deployment.PodTemplateSpec.Spec, consts.ControlPlaneControllerContainerName, gatewayConfig.Namespace, gatewayConfig.Name), consts.RouterFlavorEnvVar, consts.RouterFlavorExpressions)

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: consts.RouterFlavorEnvVar

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

undefined: ctx

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

too many arguments in call to k8sutils.GetPodContainerByName

Check failure on line 26 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

undefined: consts.RouterFlavorEnvVar
return *gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / build

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=true)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (traditional_compatible)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / conformance-tests (expressions)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-bluegreen (WEBHOOK_ENABLED=false)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=true)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / envtest-tests

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests-provision-dataplane-fail

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / CRDs-validation

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / integration-tests (WEBHOOK_ENABLED=false)

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / unit-tests

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor)

Check failure on line 27 in controller/gatewayclass/controller_reconciler_utils.go

View workflow job for this annotation

GitHub Actions / lint

gatewayConfig.Spec.ControlPlaneOptions.RouterFlavor undefined (type *"github.com/kong/gateway-operator/api/v1beta1".ControlPlaneOptions has no field or method RouterFlavor) (typecheck)
}
15 changes: 15 additions & 0 deletions pkg/consts/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,20 @@ const (
ControlPlaneAdmissionWebhookVolumeMountPath = "/admission-webhook"
)

// -----------------------------------------------------------------------------
// Consts - Router flavor parameters
// -----------------------------------------------------------------------------

// RouterFlavor represents the flavor of the Kong router.
// ref: https://docs.konghq.com/gateway/latest/reference/configuration/#router_flavor
type RouterFlavor string

const (
// RouterFlavorTraditionalCompatible is the traditional compatible router flavor.
RouterFlavorTraditionalCompatible RouterFlavor = "traditional_compatible"
// RouterFlavorExpressions is the expressions router flavor.
RouterFlavorExpressions RouterFlavor = "expressions"
)

// TODO: https://github.com/Kong/gateway-operator/issues/141
// Extract as constants all the Env var Keys used to configure the ControlPlane.
35 changes: 35 additions & 0 deletions pkg/gatewayapi/supportedfeatures.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package gatewayapi

import (
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/gateway-api/pkg/features"
)

var (
TraditionalCompatibleRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// add here the traditional compatible router specific features
)

ExpressionsRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// extended
features.SupportHTTPRouteMethodMatching,
features.SupportHTTPRouteQueryParamMatching,
)
)

var (
commonSupportedFeatures = sets.New(
// core features
features.SupportHTTPRoute,
features.SupportGateway,
features.SupportReferenceGrant,

// Gateway extended
features.SupportGatewayPort8080,

// HTTPRoute extended
features.SupportHTTPRouteResponseHeaderModification,
features.SupportHTTPRoutePathRewrite,
features.SupportHTTPRouteHostRewrite,
)
)
32 changes: 3 additions & 29 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
gwtypes "github.com/kong/gateway-operator/internal/types"
"github.com/kong/gateway-operator/modules/manager/metadata"
"github.com/kong/gateway-operator/pkg/consts"
gatewayapipkg "github.com/kong/gateway-operator/pkg/gatewayapi"
testutils "github.com/kong/gateway-operator/pkg/utils/test"
"github.com/kong/gateway-operator/pkg/vars"
)
Expand All @@ -36,33 +37,6 @@ var skippedTestsForTraditionalCompatibleRouter = []string{
tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName,
}

var (
commonSupportedFeatures = sets.New(
// core features
features.SupportHTTPRoute,
features.SupportGateway,
features.SupportReferenceGrant,

// Gateway extended
features.SupportGatewayPort8080,

// HTTPRoute extended
features.SupportHTTPRouteResponseHeaderModification,
features.SupportHTTPRoutePathRewrite,
features.SupportHTTPRouteHostRewrite,
)

traditionalCompatibleRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// add here the traditional compatible router specific features
)

expressionsRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// extended
features.SupportHTTPRouteMethodMatching,
features.SupportHTTPRouteQueryParamMatching,
)
)

type ConformanceConfig struct {
KongRouterFlavor RouterFlavor
}
Expand All @@ -83,11 +57,11 @@ func TestGatewayConformance(t *testing.T) {
case RouterFlavorTraditionalCompatible:
skippedTests = skippedTestsForTraditionalCompatibleRouter
config.KongRouterFlavor = RouterFlavorTraditionalCompatible
supportedFeatures = traditionalCompatibleRouterSupportedFeatures
supportedFeatures = gatewayapipkg.TraditionalCompatibleRouterSupportedFeatures
case RouterFlavorExpressions:
skippedTests = skippedTestsForExpressionsRouter
config.KongRouterFlavor = RouterFlavorExpressions
supportedFeatures = expressionsRouterSupportedFeatures
supportedFeatures = gatewayapipkg.ExpressionsRouterSupportedFeatures
default:
t.Fatalf("unsupported KongRouterFlavor: %s", rf)
}
Expand Down
23 changes: 7 additions & 16 deletions test/conformance/router_flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,22 @@ package conformance
import (
"os"
"testing"
)

// RouterFlavor represents the flavor of the Kong router.
// ref: https://docs.konghq.com/gateway/latest/reference/configuration/#router_flavor
type RouterFlavor string

const (
// RouterFlavorTraditionalCompatible is the traditional compatible router flavor.
RouterFlavorTraditionalCompatible RouterFlavor = "traditional_compatible"
// RouterFlavorExpressions is the expressions router flavor.
RouterFlavorExpressions RouterFlavor = "expressions"
"github.com/kong/gateway-operator/pkg/consts"
)

// KongRouterFlavor returns router mode of Kong in tests. Currently supports:
// - `traditional_compatible`
// - `expressions`
func KongRouterFlavor(t *testing.T) RouterFlavor {
func KongRouterFlavor(t *testing.T) consts.RouterFlavor {
rf := os.Getenv("TEST_KONG_ROUTER_FLAVOR")
switch {
case rf == "":
return RouterFlavorTraditionalCompatible
case rf == string(RouterFlavorTraditionalCompatible):
return RouterFlavorTraditionalCompatible
case rf == string(RouterFlavorExpressions):
return RouterFlavorExpressions
return consts.RouterFlavorTraditionalCompatible
case rf == string(consts.RouterFlavorTraditionalCompatible):
return consts.RouterFlavorTraditionalCompatible
case rf == string(consts.RouterFlavorExpressions):
return consts.RouterFlavorExpressions
case rf == "traditional":
t.Logf("Kong router flavor 'traditional' is deprecated, please use 'traditional_compatible' instead")
t.FailNow()
Expand Down
Loading