diff --git a/controller/konnect/conditions/conditions.go b/controller/konnect/conditions/conditions.go deleted file mode 100644 index deaab9c9a..000000000 --- a/controller/konnect/conditions/conditions.go +++ /dev/null @@ -1,161 +0,0 @@ -package conditions - -// TODO(pmalek): move this to Konnect API directory so that it's part of the API contract. -// https://github.com/Kong/kubernetes-configuration/issues/14 - -const ( - // KonnectEntityProgrammedConditionType is the type of the condition that - // indicates whether the entity has been programmed in Konnect. - KonnectEntityProgrammedConditionType = "Programmed" - - // KonnectEntityProgrammedReasonProgrammed is the reason for the Programmed condition. - // It is set when the entity has been programmed in Konnect. - KonnectEntityProgrammedReasonProgrammed = "Programmed" - // KonnectEntityProgrammedReasonKonnectAPIOpFailed is the reason for the Programmed condition. - // It is set when the entity has failed to be programmed in Konnect. - KonnectEntityProgrammedReasonKonnectAPIOpFailed = "KonnectAPIOpFailed" - // KonnectEntityProgrammedReasonFailedToResolveConsumerGroupRefs is the reason for the Programmed condition. - // It is set when one or more KongConsumerGroup references could not be resolved. - KonnectEntityProgrammedReasonFailedToResolveConsumerGroupRefs = "FailedToResolveConsumerGroupRefs" - // KonnectEntityProgrammedReasonFailedToReconcileConsumerGroupsWithKonnect is the reason for the Programmed condition. - // It is set when one or more KongConsumerGroup references could not be reconciled with Konnect. - KonnectEntityProgrammedReasonFailedToReconcileConsumerGroupsWithKonnect = "FailedToReconcileConsumerGroupsWithKonnect" - - // KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers - // is the reason for the Programmed condition. It is set when the control plane - // group members could not be set. - KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers = "FailedToSetControlPlaneGroupMembers" -) - -const ( - // KonnectEntityAPIAuthConfigurationResolvedRefConditionType is the type of the - // condition that indicates whether the APIAuth configuration reference is - // valid and points to an existing APIAuth configuration. - KonnectEntityAPIAuthConfigurationResolvedRefConditionType = "APIAuthResolvedRef" - - // KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef is the reason - // used with the APIAuthResolvedRef condition type indicating that the APIAuth - // configuration reference has been resolved. - KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef = "ResolvedRef" - // KonnectEntityAPIAuthConfigurationResolvedRefReasonRefNotFound is the reason - // used with the APIAuthResolvedRef condition type indicating that the APIAuth - // configuration reference could not be resolved. - KonnectEntityAPIAuthConfigurationResolvedRefReasonRefNotFound = "RefNotFound" - // KonnectEntityAPIAuthConfigurationResolvedRefReasonRefNotFound is the reason - // used with the APIAuthResolvedRef condition type indicating that the APIAuth - // configuration reference is invalid and could not be resolved. - // Condition message can contain more information about the error. - KonnectEntityAPIAuthConfigurationResolvedRefReasonRefInvalid = "RefInvalid" -) - -const ( - // KonnectEntityAPIAuthConfigurationValidConditionType is the type of the - // condition that indicates whether the referenced APIAuth configuration is - // valid. - KonnectEntityAPIAuthConfigurationValidConditionType = "APIAuthValid" - - // KonnectEntityAPIAuthConfigurationReasonValid is the reason used with the - // APIAuthRefValid condition type indicating that the APIAuth configuration - // referenced by the entity is valid. - KonnectEntityAPIAuthConfigurationReasonValid = "Valid" - // KonnectEntityAPIAuthConfigurationReasonInvalid is the reason used with the - // APIAuthRefValid condition type indicating that the APIAuth configuration - // referenced by the entity is invalid. - KonnectEntityAPIAuthConfigurationReasonInvalid = "Invalid" -) - -const ( - // ControlPlaneRefValidConditionType is the type of the condition that indicates - // whether the ControlPlane reference is valid and points to an existing - // ControlPlane. - ControlPlaneRefValidConditionType = "ControlPlaneRefValid" - - // ControlPlaneRefReasonValid is the reason used with the ControlPlaneRefValid - // condition type indicating that the ControlPlane reference is valid. - ControlPlaneRefReasonValid = "Valid" - // ControlPlaneRefReasonInvalid is the reason used with the ControlPlaneRefValid - // condition type indicating that the ControlPlane reference is invalid. - ControlPlaneRefReasonInvalid = "Invalid" -) - -const ( - // KongServiceRefValidConditionType is the type of the condition that indicates - // whether the KongService reference is valid and points to an existing - // KongService. - KongServiceRefValidConditionType = "KongServiceRefValid" - - // KongServiceRefReasonValid is the reason used with the KongServiceRefValid - // condition type indicating that the KongService reference is valid. - KongServiceRefReasonValid = "Valid" - // KongServiceRefReasonInvalid is the reason used with the KongServiceRefValid - // condition type indicating that the KongService reference is invalid. - KongServiceRefReasonInvalid = "Invalid" -) - -const ( - // KongConsumerRefValidConditionType is the type of the condition that indicates - // whether the KongConsumer reference is valid and points to an existing - // KongConsumer. - KongConsumerRefValidConditionType = "KongConsumerRefValid" - - // KongConsumerRefReasonValid is the reason used with the KongConsumerRefValid - // condition type indicating that the KongConsumer reference is valid. - KongConsumerRefReasonValid = "Valid" - // KongConsumerRefReasonInvalid is the reason used with the KongConsumerRefValid - // condition type indicating that the KongConsumer reference is invalid. - KongConsumerRefReasonInvalid = "Invalid" -) - -const ( - // KongConsumerGroupRefsValidConditionType is the type of the condition that indicates - // whether the KongConsumerGroups referenced by the entity are valid and all point to - // existing KongConsumerGroups. - KongConsumerGroupRefsValidConditionType = "KongConsumerGroupRefsValid" - - // KongConsumerGroupRefsReasonValid is the reason used with the KongConsumerGroupRefsValid - // condition type indicating that all KongConsumerGroup references are valid. - KongConsumerGroupRefsReasonValid = "Valid" - // KongConsumerGroupRefsReasonInvalid is the reason used with the KongConsumerGroupRefsValid - // condition type indicating that one or more KongConsumerGroup references are invalid. - KongConsumerGroupRefsReasonInvalid = "Invalid" -) - -const ( - // KongUpstreamRefValidConditionType is the type of the condition that indicates - // whether the KongUpstream reference is valid and points to an existing KongUpstream. - KongUpstreamRefValidConditionType = "KongUpstreamRefValid" - - // KongUpstreamRefReasonValid is the reason used with the KongUpstreamRefValid - // condition type indicating that the KongUpstream reference is valid. - KongUpstreamRefReasonValid = "Valid" - // KongUpstreamRefReasonInvalid is the reason used with the KongUpstreamRefValid - // condition type indicating that the KongUpstream reference is invalid. - KongUpstreamRefReasonInvalid = "Invalid" -) - -const ( - // KeySetRefValidConditionType is the type of the condition that indicates - // whether the KeySet reference is valid and points to an existing - // KeySet. - KeySetRefValidConditionType = "KeySetRefValid" - - // KeySetRefReasonValid is the reason used with the KeySetRefValid - // condition type indicating that the KeySet reference is valid. - KeySetRefReasonValid = "Valid" - // KeySetRefReasonInvalid is the reason used with the KeySetRefValid - // condition type indicating that the KeySet reference is invalid. - KeySetRefReasonInvalid = "Invalid" -) - -const ( - // KongCertificateRefValidConditionType is the type of the condition that indicates - // whether the KongCertificate reference is valid and points to an existing KongCertificate - KongCertificateRefValidConditionType = "KongCertificateRefValid" - - // KongCertificateRefReasonValid is the reason used with the KongCertificateRefValid - // condition type indicating that the KongCertificate reference is valid. - KongCertificateRefReasonValid = "Valid" - // KongCertificateRefReasonInvalid is the reason used with the KongCertificateRefValid - // condition type indicating that the KongCertificate reference is invalid. - KongCertificateRefReasonInvalid = "Invalid" -) diff --git a/controller/konnect/ops/conditions.go b/controller/konnect/ops/conditions.go index a442acead..88bbb74dc 100644 --- a/controller/konnect/ops/conditions.go +++ b/controller/konnect/ops/conditions.go @@ -3,9 +3,10 @@ package ops import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/pkg/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" + + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) type entityType interface { @@ -22,7 +23,7 @@ func SetKonnectEntityProgrammedCondition( _setKonnectEntityProgrammedConditon( obj, metav1.ConditionTrue, - conditions.KonnectEntityProgrammedReasonProgrammed, + konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, "", ) } @@ -50,7 +51,7 @@ func _setKonnectEntityProgrammedConditon( ) { k8sutils.SetCondition( k8sutils.NewConditionWithGeneration( - conditions.KonnectEntityProgrammedConditionType, + konnectv1alpha1.KonnectEntityProgrammedConditionType, status, reason, msg, diff --git a/controller/konnect/ops/ops.go b/controller/konnect/ops/ops.go index c9238e776..2188eb1d6 100644 --- a/controller/konnect/ops/ops.go +++ b/controller/konnect/ops/ops.go @@ -10,7 +10,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" "github.com/kong/gateway-operator/controller/pkg/log" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -173,7 +172,7 @@ func shouldUpdate[ now time.Time, ) (bool, ctrl.Result) { var ( - condProgrammed, ok = k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, ent) + condProgrammed, ok = k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, ent) timeFromLastUpdate = time.Since(condProgrammed.LastTransitionTime.Time) ) @@ -181,7 +180,7 @@ func shouldUpdate[ // the configured sync period, requeue after the remaining time. if ok && condProgrammed.Status == metav1.ConditionTrue && - condProgrammed.Reason == conditions.KonnectEntityProgrammedReasonProgrammed && + condProgrammed.Reason == konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed && condProgrammed.ObservedGeneration == ent.GetObjectMeta().GetGeneration() && timeFromLastUpdate <= syncPeriod { requeueAfter := syncPeriod - timeFromLastUpdate diff --git a/controller/konnect/ops/ops_controlplane.go b/controller/konnect/ops/ops_controlplane.go index 2c9bd7fa0..5a7fa9984 100644 --- a/controller/konnect/ops/ops_controlplane.go +++ b/controller/konnect/ops/ops_controlplane.go @@ -15,8 +15,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/kong/gateway-operator/controller/konnect/conditions" - konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) @@ -42,7 +40,7 @@ func createControlPlane( cp.Status.SetKonnectID(*resp.ControlPlane.ID) if err := setGroupMembers(ctx, cl, cp, sdkGroups); err != nil { - SetKonnectEntityProgrammedConditionFalse(cp, conditions.KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers, err.Error()) + SetKonnectEntityProgrammedConditionFalse(cp, konnectv1alpha1.KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers, err.Error()) return err } @@ -133,7 +131,7 @@ func updateControlPlane( cp.Status.SetKonnectID(*resp.ControlPlane.ID) if err := setGroupMembers(ctx, cl, cp, sdkGroups); err != nil { - SetKonnectEntityProgrammedConditionFalse(cp, conditions.KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers, err.Error()) + SetKonnectEntityProgrammedConditionFalse(cp, konnectv1alpha1.KonnectGatewayControlPlaneProgrammedReasonFailedToSetControlPlaneGroupMembers, err.Error()) return err } diff --git a/controller/konnect/ops/ops_controlplane_test.go b/controller/konnect/ops/ops_controlplane_test.go index 6a3a9c1a4..bc72af8a0 100644 --- a/controller/konnect/ops/ops_controlplane_test.go +++ b/controller/konnect/ops/ops_controlplane_test.go @@ -19,7 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/modules/manager/scheme" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -65,10 +64,10 @@ func TestCreateControlPlane(t *testing.T) { }, assertions: func(t *testing.T, cp *konnectv1alpha1.KonnectGatewayControlPlane) { assert.Equal(t, "12345", cp.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, cp.GetGeneration(), cond.ObservedGeneration) }, }, @@ -106,7 +105,7 @@ func TestCreateControlPlane(t *testing.T) { }, assertions: func(t *testing.T, cp *konnectv1alpha1.KonnectGatewayControlPlane) { assert.Equal(t, "", cp.Status.GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToCreate", cond.Reason) @@ -312,10 +311,10 @@ func TestUpdateControlPlane(t *testing.T) { }, assertions: func(t *testing.T, cp *konnectv1alpha1.KonnectGatewayControlPlane) { assert.Equal(t, "12345", cp.Status.GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, cp.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, @@ -365,7 +364,7 @@ func TestUpdateControlPlane(t *testing.T) { }, assertions: func(t *testing.T, cp *konnectv1alpha1.KonnectGatewayControlPlane) { assert.Equal(t, "12345", cp.Status.GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToUpdate", cond.Reason) @@ -433,10 +432,10 @@ func TestUpdateControlPlane(t *testing.T) { }, assertions: func(t *testing.T, cp *konnectv1alpha1.KonnectGatewayControlPlane) { assert.Equal(t, "12345", cp.Status.GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, cp.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, diff --git a/controller/konnect/ops/ops_kongconsumer.go b/controller/konnect/ops/ops_kongconsumer.go index 6f4bac68a..1962b0736 100644 --- a/controller/konnect/ops/ops_kongconsumer.go +++ b/controller/konnect/ops/ops_kongconsumer.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/pkg/log" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" configurationv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func createConsumer( @@ -44,7 +44,7 @@ func createConsumer( // Can't adopt it as it will cause conflicts between the controller // that created that entity and already manages it, hm if errWrap := wrapErrIfKonnectOpFailed(err, CreateOp, consumer); errWrap != nil { - SetKonnectEntityProgrammedConditionFalse(consumer, conditions.KonnectEntityProgrammedReasonKonnectAPIOpFailed, errWrap.Error()) + SetKonnectEntityProgrammedConditionFalse(consumer, konnectv1alpha1.KonnectEntityProgrammedReasonKonnectAPIOpFailed, errWrap.Error()) return errWrap } @@ -89,7 +89,7 @@ func updateConsumer( // Can't adopt it as it will cause conflicts between the controller // that created that entity and already manages it, hm if errWrap := wrapErrIfKonnectOpFailed(err, UpdateOp, consumer); errWrap != nil { - SetKonnectEntityProgrammedConditionFalse(consumer, conditions.KonnectEntityProgrammedReasonKonnectAPIOpFailed, errWrap.Error()) + SetKonnectEntityProgrammedConditionFalse(consumer, konnectv1alpha1.KonnectEntityProgrammedReasonKonnectAPIOpFailed, errWrap.Error()) return errWrap } @@ -126,14 +126,14 @@ func handleConsumerGroupAssignments( populateConsumerGroupRefsValidCondition(invalidConsumerGroups, consumer) if err != nil { - SetKonnectEntityProgrammedConditionFalse(consumer, conditions.KonnectEntityProgrammedReasonFailedToResolveConsumerGroupRefs, err.Error()) + SetKonnectEntityProgrammedConditionFalse(consumer, konnectv1alpha1.KonnectEntityProgrammedReasonFailedToResolveConsumerGroupRefs, err.Error()) return err } // Reconcile the ConsumerGroups assigned to the KongConsumer in Konnect (list the actual ConsumerGroups, calculate the // difference, and add/remove the Consumer from the ConsumerGroups accordingly). if err := reconcileConsumerGroupsWithKonnect(ctx, desiredConsumerGroupsIDs, cgSDK, cpID, consumer); err != nil { - SetKonnectEntityProgrammedConditionFalse(consumer, conditions.KonnectEntityProgrammedReasonFailedToReconcileConsumerGroupsWithKonnect, err.Error()) + SetKonnectEntityProgrammedConditionFalse(consumer, konnectv1alpha1.KonnectEntityProgrammedReasonFailedToReconcileConsumerGroupsWithKonnect, err.Error()) return err } return nil @@ -221,9 +221,9 @@ func populateConsumerGroupRefsValidCondition(invalidConsumerGroups []invalidCons } k8sutils.SetCondition( k8sutils.NewConditionWithGeneration( - conditions.KongConsumerGroupRefsValidConditionType, + konnectv1alpha1.KongConsumerGroupRefsValidConditionType, metav1.ConditionFalse, - conditions.KongConsumerGroupRefsReasonInvalid, + konnectv1alpha1.KongConsumerGroupRefsReasonInvalid, fmt.Sprintf("Invalid ConsumerGroup references: %s", strings.Join(reasons, ", ")), consumer.GetGeneration(), ), @@ -232,9 +232,9 @@ func populateConsumerGroupRefsValidCondition(invalidConsumerGroups []invalidCons } else { k8sutils.SetCondition( k8sutils.NewConditionWithGeneration( - conditions.KongConsumerGroupRefsValidConditionType, + konnectv1alpha1.KongConsumerGroupRefsValidConditionType, metav1.ConditionTrue, - conditions.KongConsumerGroupRefsReasonValid, + konnectv1alpha1.KongConsumerGroupRefsReasonValid, "", consumer.GetGeneration(), ), diff --git a/controller/konnect/ops/ops_kongservice_test.go b/controller/konnect/ops/ops_kongservice_test.go index 4e5b4a235..a43161e1a 100644 --- a/controller/konnect/ops/ops_kongservice_test.go +++ b/controller/konnect/ops/ops_kongservice_test.go @@ -14,7 +14,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8stypes "k8s.io/apimachinery/pkg/types" - "github.com/kong/gateway-operator/controller/konnect/conditions" konnectconsts "github.com/kong/gateway-operator/controller/konnect/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -70,10 +69,10 @@ func TestCreateKongService(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongService) { assert.Equal(t, "12345", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KongService") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) }, }, @@ -139,7 +138,7 @@ func TestCreateKongService(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongService) { assert.Equal(t, "", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToCreate", cond.Reason) @@ -348,10 +347,10 @@ func TestUpdateKongService(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongService) { assert.Equal(t, "123456789", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, @@ -402,7 +401,7 @@ func TestUpdateKongService(t *testing.T) { // TODO: When we fail to update a KongService, do we want to clear // the Konnect ID from the status? Probably not. // assert.Equal(t, "", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToUpdate", cond.Reason) @@ -468,10 +467,10 @@ func TestUpdateKongService(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongService) { assert.Equal(t, "123456789", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, diff --git a/controller/konnect/ops/ops_kongupstream_test.go b/controller/konnect/ops/ops_kongupstream_test.go index 78a4387e5..2ae2f73b0 100644 --- a/controller/konnect/ops/ops_kongupstream_test.go +++ b/controller/konnect/ops/ops_kongupstream_test.go @@ -14,7 +14,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8stypes "k8s.io/apimachinery/pkg/types" - "github.com/kong/gateway-operator/controller/konnect/conditions" konnectconsts "github.com/kong/gateway-operator/controller/konnect/consts" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -68,10 +67,10 @@ func TestCreateKongUpstream(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongUpstream) { assert.Equal(t, "12345", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KongUpstream") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) }, }, @@ -135,7 +134,7 @@ func TestCreateKongUpstream(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongUpstream) { assert.Equal(t, "", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToCreate", cond.Reason) @@ -344,10 +343,10 @@ func TestUpdateKongUpstream(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongUpstream) { assert.Equal(t, "123456789", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, @@ -398,7 +397,7 @@ func TestUpdateKongUpstream(t *testing.T) { // TODO: When we fail to update a KongUpstream, do we want to clear // the Konnect ID from the status? Probably not. // assert.Equal(t, "", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToUpdate", cond.Reason) @@ -464,10 +463,10 @@ func TestUpdateKongUpstream(t *testing.T) { }, assertions: func(t *testing.T, svc *configurationv1alpha1.KongUpstream) { assert.Equal(t, "123456789", svc.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, svc) require.True(t, ok, "Programmed condition not set on KonnectGatewayControlPlane") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, svc.GetGeneration(), cond.ObservedGeneration) assert.Equal(t, "", cond.Message) }, diff --git a/controller/konnect/ops/ops_kongvault_test.go b/controller/konnect/ops/ops_kongvault_test.go index ec95c2158..2be1cc5d3 100644 --- a/controller/konnect/ops/ops_kongvault_test.go +++ b/controller/konnect/ops/ops_kongvault_test.go @@ -15,7 +15,6 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/kong/gateway-operator/controller/konnect/conditions" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -72,10 +71,10 @@ func TestCreateKongVault(t *testing.T) { }, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { assert.Equal(t, "12345", vault.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, vault) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, vault) require.True(t, ok, "Programmed condition not set on KongVault") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, vault.GetGeneration(), cond.ObservedGeneration) }, }, @@ -138,7 +137,7 @@ func TestCreateKongVault(t *testing.T) { expectedErr: true, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { assert.Equal(t, "", vault.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, vault) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, vault) require.True(t, ok, "Programmed condition not set on KongVault") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToCreate", cond.Reason) @@ -214,10 +213,10 @@ func TestUpdateKongVault(t *testing.T) { }, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { assert.Equal(t, "12345", vault.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, vault) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, vault) require.True(t, ok, "Programmed condition not set on KongVault") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, vault.GetGeneration(), cond.ObservedGeneration) }, }, @@ -259,7 +258,7 @@ func TestUpdateKongVault(t *testing.T) { }, expectedErr: true, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, vault) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, vault) require.True(t, ok, "Programmed condition not set on KongVault") assert.Equal(t, metav1.ConditionFalse, cond.Status) assert.Equal(t, "FailedToUpdate", cond.Reason) @@ -314,10 +313,10 @@ func TestUpdateKongVault(t *testing.T) { }, assertions: func(t *testing.T, vault *configurationv1alpha1.KongVault) { assert.Equal(t, "12345", vault.GetKonnectStatus().GetKonnectID()) - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, vault) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, vault) require.True(t, ok, "Programmed condition not set on KongVault") assert.Equal(t, metav1.ConditionTrue, cond.Status) - assert.Equal(t, conditions.KonnectEntityProgrammedReasonProgrammed, cond.Reason) + assert.Equal(t, konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, cond.Reason) assert.Equal(t, vault.GetGeneration(), cond.ObservedGeneration) }, }, diff --git a/controller/konnect/reconciler_certificateref.go b/controller/konnect/reconciler_certificateref.go index 9f3916c82..382652085 100644 --- a/controller/konnect/reconciler_certificateref.go +++ b/controller/konnect/reconciler_certificateref.go @@ -12,7 +12,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -53,9 +52,9 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongCertificateRefValidConditionType, + konnectv1alpha1.KongCertificateRefValidConditionType, metav1.ConditionFalse, - conditions.KongCertificateRefReasonInvalid, + konnectv1alpha1.KongCertificateRefReasonInvalid, err.Error(), ); errStatus != nil || res.Requeue { return res, errStatus @@ -77,14 +76,14 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con } // requeue it if referenced KongCertificate is not programmed yet so we cannot do the following work. - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cert) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cert) if !ok || cond.Status != metav1.ConditionTrue { ent.SetKonnectID("") if res, err := updateStatusWithCondition( ctx, cl, ent, - conditions.KongCertificateRefValidConditionType, + konnectv1alpha1.KongCertificateRefValidConditionType, metav1.ConditionFalse, - conditions.KongCertificateRefReasonInvalid, + konnectv1alpha1.KongCertificateRefReasonInvalid, fmt.Sprintf("Referenced KongCertificate %s is not programmed yet", nn), ); err != nil || res.Requeue { return ctrl.Result{}, err @@ -114,9 +113,9 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongCertificateRefValidConditionType, + konnectv1alpha1.KongCertificateRefValidConditionType, metav1.ConditionTrue, - conditions.KongCertificateRefReasonValid, + konnectv1alpha1.KongCertificateRefReasonValid, fmt.Sprintf("Referenced KongCertificate %s programmed", nn), ); errStatus != nil || res.Requeue { return res, errStatus @@ -136,9 +135,9 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, err.Error(), ); errStatus != nil || res.Requeue { return res, errStatus @@ -155,13 +154,13 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con return ctrl.Result{}, err } - cond, ok = k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok = k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) if !ok || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != cp.GetGeneration() { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, fmt.Sprintf("Referenced ControlPlane %s is not programmed yet", nn), ); errStatus != nil || res.Requeue { return res, errStatus @@ -176,9 +175,9 @@ func handleKongCertificateRef[T constraints.SupportedKonnectEntityType, TEnt con if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionTrue, - conditions.ControlPlaneRefReasonValid, + konnectv1alpha1.ControlPlaneRefReasonValid, fmt.Sprintf("Referenced ControlPlane %s is programmed", nn), ); errStatus != nil || res.Requeue { return res, errStatus diff --git a/controller/konnect/reconciler_certificateref_test.go b/controller/konnect/reconciler_certificateref_test.go index f5ef373dd..c5b9b4ee4 100644 --- a/controller/konnect/reconciler_certificateref_test.go +++ b/controller/konnect/reconciler_certificateref_test.go @@ -14,7 +14,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -59,7 +58,7 @@ var testKongCertOK = &configurationv1alpha1.KongCertificate{ }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -74,7 +73,7 @@ var testKongCertNotProgrammed = &configurationv1alpha1.KongCertificate{ Status: configurationv1alpha1.KongCertificateStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionFalse, }, }, @@ -95,7 +94,7 @@ var testKongCertNoControlPlaneRef = &configurationv1alpha1.KongCertificate{ Status: configurationv1alpha1.KongCertificateStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -133,7 +132,7 @@ var testKongCertificateControlPlaneRefNotFound = &configurationv1alpha1.KongCert }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -162,7 +161,7 @@ var testKongCertControlPlaneRefNotProgrammed = &configurationv1alpha1.KongCertif }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -193,12 +192,12 @@ func TestHandleCertificateRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongSNI) (bool, string){ func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongSNI does not have KongCertificateRefValid condition set to True" }, func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongSNI does not have ControlPlaneRefValid condition set to True" }, func(ks *configurationv1alpha1.KongSNI) (bool, string) { @@ -226,7 +225,7 @@ func TestHandleCertificateRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongSNI) (bool, string){ func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongCertificateRefValidConditionType && c.Status == metav1.ConditionFalse + return c.Type == konnectv1alpha1.KongCertificateRefValidConditionType && c.Status == metav1.ConditionFalse }), "KongSNI does not have KongCertificateRefValid condition set to False" }, }, @@ -252,7 +251,7 @@ func TestHandleCertificateRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongSNI) (bool, string){ func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.GetConditions(), func(c metav1.Condition) bool { - return c.Type == conditions.KongCertificateRefValidConditionType && c.Status == metav1.ConditionFalse && + return c.Type == konnectv1alpha1.KongCertificateRefValidConditionType && c.Status == metav1.ConditionFalse && c.Message == fmt.Sprintf("Referenced KongCertificate %s/%s is not programmed yet", testKongCertNotProgrammed.Namespace, testKongCertNotProgrammed.Name) }), "KongSNI does not have KongCertificateRefValid condition set to False" @@ -281,7 +280,7 @@ func TestHandleCertificateRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongSNI) (bool, string){ func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongSNI does not have KongCertificateRefValid condition set to True" }, }, @@ -349,12 +348,12 @@ func TestHandleCertificateRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongSNI) (bool, string){ func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongCertificateRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongSNI does not have KongCertificateRefValid condition set to True" }, func(ks *configurationv1alpha1.KongSNI) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionFalse + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionFalse }), "KongSNI does not have ControlPlaneRefValid condition set to False" }, }, diff --git a/controller/konnect/reconciler_generic.go b/controller/konnect/reconciler_generic.go index 759ce5f7d..c6005858d 100644 --- a/controller/konnect/reconciler_generic.go +++ b/controller/konnect/reconciler_generic.go @@ -17,7 +17,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/controller/pkg/log" @@ -336,9 +335,9 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( if k8serrors.IsNotFound(err) { if res, err := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefReasonRefNotFound, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefReasonRefNotFound, fmt.Sprintf("Referenced KonnectAPIAuthConfiguration %s not found", apiAuthRef), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -349,9 +348,9 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( if res, err := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefReasonRefInvalid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefReasonRefInvalid, fmt.Sprintf("KonnectAPIAuthConfiguration reference %s is invalid: %v", apiAuthRef, err), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -361,15 +360,15 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( } // Update the status if the reference is resolved and it's not as expected. - if cond, present := k8sutils.GetCondition(conditions.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, ent); !present || + if cond, present := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, ent); !present || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != ent.GetGeneration() || - cond.Reason != conditions.KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef { + cond.Reason != konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef { if res, err := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefConditionType, metav1.ConditionTrue, - conditions.KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationResolvedRefReasonResolvedRef, fmt.Sprintf("KonnectAPIAuthConfiguration reference %s is resolved", apiAuthRef), ); err != nil || !res.IsZero() { return res, err @@ -378,17 +377,17 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( } // Check if the referenced APIAuthConfiguration is valid. - if cond, present := k8sutils.GetCondition(conditions.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !present || + if cond, present := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !present || cond.Status != metav1.ConditionTrue || - cond.Reason != conditions.KonnectEntityAPIAuthConfigurationReasonValid { + cond.Reason != konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid { // If it's invalid then set the "APIAuthValid" status condition on // the entity to False with "Invalid" reason. if res, err := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationReasonInvalid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonInvalid, conditionMessageReferenceKonnectAPIAuthConfigurationInvalid(apiAuthRef), ); err != nil || !res.IsZero() { return res, err @@ -400,17 +399,17 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( // If the referenced APIAuthConfiguration is valid, set the "APIAuthValid" // condition to True with "Valid" reason. // Only perform the update if the condition is not as expected. - if cond, present := k8sutils.GetCondition(conditions.KonnectEntityAPIAuthConfigurationValidConditionType, ent); !present || + if cond, present := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, ent); !present || cond.Status != metav1.ConditionTrue || - cond.Reason != conditions.KonnectEntityAPIAuthConfigurationReasonValid || + cond.Reason != konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid || cond.ObservedGeneration != ent.GetGeneration() || cond.Message != conditionMessageReferenceKonnectAPIAuthConfigurationValid(apiAuthRef) { if res, err := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionTrue, - conditions.KonnectEntityAPIAuthConfigurationReasonValid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid, conditionMessageReferenceKonnectAPIAuthConfigurationValid(apiAuthRef), ); err != nil || !res.IsZero() { return res, err @@ -422,9 +421,9 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( if err != nil { if res, errStatus := updateStatusWithCondition( ctx, r.Client, &apiAuth, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationReasonInvalid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -457,9 +456,9 @@ func (r *KonnectEntityReconciler[T, TEnt]) Reconcile( if err := ops.Delete[T, TEnt](ctx, sdk, r.Client, ent); err != nil { if res, errStatus := updateStatusWithCondition( ctx, r.Client, ent, - conditions.KonnectEntityProgrammedConditionType, + konnectv1alpha1.KonnectEntityProgrammedConditionType, metav1.ConditionFalse, - conditions.KonnectEntityProgrammedReasonKonnectAPIOpFailed, + konnectv1alpha1.KonnectEntityProgrammedReasonKonnectAPIOpFailed, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -794,9 +793,9 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr if err := cl.Get(ctx, nn, &consumer); err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongConsumerRefValidConditionType, + konnectv1alpha1.KongConsumerRefValidConditionType, metav1.ConditionFalse, - conditions.KongConsumerRefReasonInvalid, + konnectv1alpha1.KongConsumerRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -817,14 +816,14 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr } } - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, &consumer) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, &consumer) if !ok || cond.Status != metav1.ConditionTrue { ent.SetKonnectID("") if res, err := updateStatusWithCondition( ctx, cl, ent, - conditions.KongConsumerRefValidConditionType, + konnectv1alpha1.KongConsumerRefValidConditionType, metav1.ConditionFalse, - conditions.KongConsumerRefReasonInvalid, + konnectv1alpha1.KongConsumerRefReasonInvalid, fmt.Sprintf("Referenced KongConsumer %s is not programmed yet", nn), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -857,9 +856,9 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongConsumerRefValidConditionType, + konnectv1alpha1.KongConsumerRefValidConditionType, metav1.ConditionTrue, - conditions.KongConsumerRefReasonValid, + konnectv1alpha1.KongConsumerRefReasonValid, fmt.Sprintf("Referenced KongConsumer %s programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -876,9 +875,9 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -892,13 +891,13 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr return ctrl.Result{}, err } - cond, ok = k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok = k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) if !ok || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != cp.GetGeneration() { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, fmt.Sprintf("Referenced ControlPlane %s is not programmed yet", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -913,9 +912,9 @@ func handleKongConsumerRef[T constraints.SupportedKonnectEntityType, TEnt constr if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionTrue, - conditions.ControlPlaneRefReasonValid, + konnectv1alpha1.ControlPlaneRefReasonValid, fmt.Sprintf("Referenced ControlPlane %s is programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -1022,9 +1021,9 @@ func handleControlPlaneRef[T constraints.SupportedKonnectEntityType, TEnt constr if err := cl.Get(ctx, nn, &cp); err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -1038,13 +1037,13 @@ func handleControlPlaneRef[T constraints.SupportedKonnectEntityType, TEnt constr return ctrl.Result{}, err } - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, &cp) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, &cp) if !ok || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != cp.GetGeneration() { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, fmt.Sprintf("Referenced ControlPlane %s is not programmed yet", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -1086,9 +1085,9 @@ func handleControlPlaneRef[T constraints.SupportedKonnectEntityType, TEnt constr if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionTrue, - conditions.ControlPlaneRefReasonValid, + konnectv1alpha1.ControlPlaneRefReasonValid, fmt.Sprintf("Referenced ControlPlane %s is programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus diff --git a/controller/konnect/reconciler_keysetref.go b/controller/konnect/reconciler_keysetref.go index 35414852c..a0fc00e59 100644 --- a/controller/konnect/reconciler_keysetref.go +++ b/controller/konnect/reconciler_keysetref.go @@ -13,7 +13,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -36,9 +35,9 @@ func handleKongKeySetRef[T constraints.SupportedKonnectEntityType, TEnt constrai // Reset the KeySetID in the status and set the condition to True. key.Status.Konnect.KeySetID = "" if res, err := updateStatusWithCondition(ctx, cl, key, - conditions.KeySetRefValidConditionType, + konnectv1alpha1.KeySetRefValidConditionType, metav1.ConditionTrue, - conditions.KeySetRefReasonValid, + konnectv1alpha1.KeySetRefReasonValid, "KeySetRef is unset", ); err != nil || !res.IsZero() { return res, fmt.Errorf("failed to update status: %w", err) @@ -73,9 +72,9 @@ func handleKongKeySetRef[T constraints.SupportedKonnectEntityType, TEnt constrai if err := cl.Get(ctx, nn, &keySet); err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KeySetRefValidConditionType, + konnectv1alpha1.KeySetRefValidConditionType, metav1.ConditionFalse, - conditions.KeySetRefReasonInvalid, + konnectv1alpha1.KeySetRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -101,13 +100,13 @@ func handleKongKeySetRef[T constraints.SupportedKonnectEntityType, TEnt constrai } // Verify that the KongKeySet is programmed. - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, &keySet) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, &keySet) if !ok || cond.Status != metav1.ConditionTrue { if res, err := updateStatusWithCondition( ctx, cl, ent, - conditions.KeySetRefValidConditionType, + konnectv1alpha1.KeySetRefValidConditionType, metav1.ConditionFalse, - conditions.KeySetRefReasonInvalid, + konnectv1alpha1.KeySetRefReasonInvalid, fmt.Sprintf("Referenced KongKeySet %s is not programmed yet", nn), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -136,9 +135,9 @@ func handleKongKeySetRef[T constraints.SupportedKonnectEntityType, TEnt constrai if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KeySetRefValidConditionType, + konnectv1alpha1.KeySetRefValidConditionType, metav1.ConditionTrue, - conditions.KeySetRefReasonValid, + konnectv1alpha1.KeySetRefReasonValid, fmt.Sprintf("Referenced KongKeySet %s programmed", nn), ); errStatus != nil || res.Requeue { return res, errStatus diff --git a/controller/konnect/reconciler_keysetref_test.go b/controller/konnect/reconciler_keysetref_test.go index e55dddda1..41b01e03f 100644 --- a/controller/konnect/reconciler_keysetref_test.go +++ b/controller/konnect/reconciler_keysetref_test.go @@ -14,7 +14,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -85,7 +84,7 @@ func TestHandleKeySetRef(t *testing.T) { }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, ObservedGeneration: 1, LastTransitionTime: metav1.Now(), @@ -124,7 +123,7 @@ func TestHandleKeySetRef(t *testing.T) { keySetRefConditionIs = func(expectedStatus metav1.ConditionStatus) func(key *configurationv1alpha1.KongKey) (ok bool, message string) { return func(key *configurationv1alpha1.KongKey) (ok bool, message string) { containsCondition := lo.ContainsBy(key.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KeySetRefValidConditionType && + return condition.Type == konnectv1alpha1.KeySetRefValidConditionType && condition.Status == expectedStatus }) if !containsCondition { diff --git a/controller/konnect/reconciler_konnectapiauth.go b/controller/konnect/reconciler_konnectapiauth.go index 9e2201ccf..5c49829cf 100644 --- a/controller/konnect/reconciler_konnectapiauth.go +++ b/controller/konnect/reconciler_konnectapiauth.go @@ -17,7 +17,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/controller/pkg/log" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -119,9 +118,9 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( if err != nil { if res, errStatus := updateStatusWithCondition( ctx, r.client, &apiAuth, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationReasonInvalid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -150,9 +149,9 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( respOrg, err := sdk.GetMeSDK().GetOrganizationsMe(ctx, sdkkonnectops.WithServerURL("https://"+apiAuth.Spec.ServerURL)) if err != nil { logger.Error(err, "failed to get organization info from Konnect") - if cond, ok := k8sutils.GetCondition(conditions.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !ok || + if cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !ok || cond.Status != metav1.ConditionFalse || - cond.Reason != conditions.KonnectEntityAPIAuthConfigurationReasonInvalid || + cond.Reason != konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonInvalid || cond.ObservedGeneration != apiAuth.GetGeneration() || apiAuth.Status.OrganizationID != "" || apiAuth.Status.ServerURL != apiAuth.Spec.ServerURL { @@ -162,9 +161,9 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( res, errUpdate := updateStatusWithCondition( ctx, r.client, &apiAuth, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionFalse, - conditions.KonnectEntityAPIAuthConfigurationReasonInvalid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonInvalid, err.Error(), ) if errUpdate != nil || !res.IsZero() { @@ -187,10 +186,10 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( } condMessage = fmt.Sprintf("Token from Secret %s is valid", nn) } - if cond, ok := k8sutils.GetCondition(conditions.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !ok || + if cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, &apiAuth); !ok || cond.Status != metav1.ConditionTrue || cond.Message != condMessage || - cond.Reason != conditions.KonnectEntityAPIAuthConfigurationReasonValid || + cond.Reason != konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid || cond.ObservedGeneration != apiAuth.GetGeneration() || apiAuth.Status.OrganizationID != *respOrg.MeOrganization.ID || apiAuth.Status.ServerURL != apiAuth.Spec.ServerURL { @@ -200,9 +199,9 @@ func (r *KonnectAPIAuthConfigurationReconciler) Reconcile( res, err := updateStatusWithCondition( ctx, r.client, &apiAuth, - conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, metav1.ConditionTrue, - conditions.KonnectEntityAPIAuthConfigurationReasonValid, + konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid, condMessage, ) if err != nil || !res.IsZero() { diff --git a/controller/konnect/reconciler_serviceref.go b/controller/konnect/reconciler_serviceref.go index 8487d70af..3d2e1ac41 100644 --- a/controller/konnect/reconciler_serviceref.go +++ b/controller/konnect/reconciler_serviceref.go @@ -12,7 +12,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -58,9 +57,9 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra if err := cl.Get(ctx, nn, &svc); err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongServiceRefValidConditionType, + konnectv1alpha1.KongServiceRefValidConditionType, metav1.ConditionFalse, - conditions.KongServiceRefReasonInvalid, + konnectv1alpha1.KongServiceRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -77,14 +76,14 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra } } - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, &svc) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, &svc) if !ok || cond.Status != metav1.ConditionTrue { ent.SetKonnectID("") if res, err := updateStatusWithCondition( ctx, cl, ent, - conditions.KongServiceRefValidConditionType, + konnectv1alpha1.KongServiceRefValidConditionType, metav1.ConditionFalse, - conditions.KongServiceRefReasonInvalid, + konnectv1alpha1.KongServiceRefReasonInvalid, fmt.Sprintf("Referenced KongService %s is not programmed yet", nn), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -115,9 +114,9 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongServiceRefValidConditionType, + konnectv1alpha1.KongServiceRefValidConditionType, metav1.ConditionTrue, - conditions.KongServiceRefReasonValid, + konnectv1alpha1.KongServiceRefReasonValid, fmt.Sprintf("Referenced KongService %s programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -134,9 +133,9 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -150,13 +149,13 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra return ctrl.Result{}, err } - cond, ok = k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok = k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) if !ok || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != cp.GetGeneration() { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, fmt.Sprintf("Referenced ControlPlane %s is not programmed yet", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -174,9 +173,9 @@ func handleKongServiceRef[T constraints.SupportedKonnectEntityType, TEnt constra if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionTrue, - conditions.ControlPlaneRefReasonValid, + konnectv1alpha1.ControlPlaneRefReasonValid, fmt.Sprintf("Referenced ControlPlane %s is programmed", client.ObjectKeyFromObject(cp)), ); errStatus != nil || !res.IsZero() { return res, errStatus diff --git a/controller/konnect/reconciler_serviceref_test.go b/controller/konnect/reconciler_serviceref_test.go index 2c4fead1f..2eb84e4a1 100644 --- a/controller/konnect/reconciler_serviceref_test.go +++ b/controller/konnect/reconciler_serviceref_test.go @@ -13,7 +13,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -54,7 +53,7 @@ var testKongServiceOK = &configurationv1alpha1.KongService{ }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -83,7 +82,7 @@ var testKongServiceWithCPRefUnprogrammed = &configurationv1alpha1.KongService{ }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -98,7 +97,7 @@ var testKongServiceNotProgrammed = &configurationv1alpha1.KongService{ Status: configurationv1alpha1.KongServiceStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionFalse, }, }, @@ -141,12 +140,12 @@ func TestHandleServiceRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongRoute) (bool, string){ func(ks *configurationv1alpha1.KongRoute) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongRoute does not have ControlPlaneRefValid condition set to True" }, func(ks *configurationv1alpha1.KongRoute) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongServiceRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongServiceRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongRoute does not have KongServiceRefValid condition set to True" }, func(ks *configurationv1alpha1.KongRoute) (bool, string) { @@ -214,9 +213,9 @@ func TestHandleServiceRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongRoute) (bool, string){ func(ks *configurationv1alpha1.KongRoute) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongServiceRefValidConditionType && + return c.Type == konnectv1alpha1.KongServiceRefValidConditionType && c.Status == metav1.ConditionFalse && - c.Reason == conditions.KongServiceRefReasonInvalid + c.Reason == konnectv1alpha1.KongServiceRefReasonInvalid }), "KongRoute does not have KongServiceRefValid condition set to False" }, func(ks *configurationv1alpha1.KongRoute) (bool, string) { @@ -253,16 +252,16 @@ func TestHandleServiceRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongRoute) (bool, string){ func(ks *configurationv1alpha1.KongRoute) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionFalse && - c.Reason == conditions.ControlPlaneRefReasonInvalid + c.Reason == konnectv1alpha1.ControlPlaneRefReasonInvalid }), "KongRoute does not have ControlPlaneRef condition set to False" }, func(ks *configurationv1alpha1.KongRoute) (bool, string) { return lo.ContainsBy(ks.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongServiceRefValidConditionType && + return c.Type == konnectv1alpha1.KongServiceRefValidConditionType && c.Status == metav1.ConditionTrue && - c.Reason == conditions.KongServiceRefReasonValid + c.Reason == konnectv1alpha1.KongServiceRefReasonValid }), "KongRoute does not have KongServiceRefValid condition set to True" }, func(ks *configurationv1alpha1.KongRoute) (bool, string) { diff --git a/controller/konnect/reconciler_upstreamref.go b/controller/konnect/reconciler_upstreamref.go index bfe43c78f..e196a102d 100644 --- a/controller/konnect/reconciler_upstreamref.go +++ b/controller/konnect/reconciler_upstreamref.go @@ -12,7 +12,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" @@ -55,9 +54,9 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongUpstreamRefValidConditionType, + konnectv1alpha1.KongUpstreamRefValidConditionType, metav1.ConditionFalse, - conditions.KongUpstreamRefReasonInvalid, + konnectv1alpha1.KongUpstreamRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -79,14 +78,14 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr } // requeue it if referenced KongUpstream is not programmed yet so we cannot do the following work. - cond, ok := k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, kongUpstream) + cond, ok := k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, kongUpstream) if !ok || cond.Status != metav1.ConditionTrue { ent.SetKonnectID("") if res, err := updateStatusWithCondition( ctx, cl, ent, - conditions.KongUpstreamRefValidConditionType, + konnectv1alpha1.KongUpstreamRefValidConditionType, metav1.ConditionFalse, - conditions.KongUpstreamRefReasonInvalid, + konnectv1alpha1.KongUpstreamRefReasonInvalid, fmt.Sprintf("Referenced KongUpstream %s is not programmed yet", nn), ); err != nil || !res.IsZero() { return ctrl.Result{}, err @@ -116,9 +115,9 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.KongUpstreamRefValidConditionType, + konnectv1alpha1.KongUpstreamRefValidConditionType, metav1.ConditionTrue, - conditions.KongUpstreamRefReasonValid, + konnectv1alpha1.KongUpstreamRefReasonValid, fmt.Sprintf("Referenced KongUpstream %s programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -138,9 +137,9 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr if err != nil { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, err.Error(), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -157,13 +156,13 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr return ctrl.Result{}, err } - cond, ok = k8sutils.GetCondition(conditions.KonnectEntityProgrammedConditionType, cp) + cond, ok = k8sutils.GetCondition(konnectv1alpha1.KonnectEntityProgrammedConditionType, cp) if !ok || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != cp.GetGeneration() { if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionFalse, - conditions.ControlPlaneRefReasonInvalid, + konnectv1alpha1.ControlPlaneRefReasonInvalid, fmt.Sprintf("Referenced ControlPlane %s is not programmed yet", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus @@ -178,9 +177,9 @@ func handleKongUpstreamRef[T constraints.SupportedKonnectEntityType, TEnt constr if res, errStatus := updateStatusWithCondition( ctx, cl, ent, - conditions.ControlPlaneRefValidConditionType, + konnectv1alpha1.ControlPlaneRefValidConditionType, metav1.ConditionTrue, - conditions.ControlPlaneRefReasonValid, + konnectv1alpha1.ControlPlaneRefReasonValid, fmt.Sprintf("Referenced ControlPlane %s is programmed", nn), ); errStatus != nil || !res.IsZero() { return res, errStatus diff --git a/controller/konnect/reconciler_upstreamref_test.go b/controller/konnect/reconciler_upstreamref_test.go index 9389361c2..e794a7e39 100644 --- a/controller/konnect/reconciler_upstreamref_test.go +++ b/controller/konnect/reconciler_upstreamref_test.go @@ -14,7 +14,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/constraints" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" @@ -58,7 +57,7 @@ var testKongUpstreamOK = &configurationv1alpha1.KongUpstream{ }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -73,7 +72,7 @@ var testKongUpstreamNotProgrammed = &configurationv1alpha1.KongUpstream{ Status: configurationv1alpha1.KongUpstreamStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionFalse, }, }, @@ -88,7 +87,7 @@ var testKongUpstreamNoControlPlaneRef = &configurationv1alpha1.KongUpstream{ Status: configurationv1alpha1.KongUpstreamStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -129,7 +128,7 @@ var testKongUpstreamControlPlaneRefNotFound = &configurationv1alpha1.KongUpstrea }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -161,7 +160,7 @@ var testKongUpstreamControlPlaneRefNotProgrammed = &configurationv1alpha1.KongUp }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -180,7 +179,7 @@ var testControlPlaneOK = &konnectv1alpha1.KonnectGatewayControlPlane{ }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, }, }, @@ -196,7 +195,7 @@ var testControlPlaneNotProgrammed = &konnectv1alpha1.KonnectGatewayControlPlane{ Status: konnectv1alpha1.KonnectGatewayControlPlaneStatus{ Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionFalse, }, }, @@ -229,12 +228,12 @@ func TestHandleUpstreamRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongTarget) (bool, string){ func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongTarget does not have KongUpstreamRefValid condition set to True" }, func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongTarget does not have ControlPlaneRefValid condition set to True" }, func(kt *configurationv1alpha1.KongTarget) (bool, string) { @@ -262,7 +261,7 @@ func TestHandleUpstreamRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongTarget) (bool, string){ func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionFalse + return c.Type == konnectv1alpha1.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionFalse }), "KongTarget does not have KongUpstreamRefValid condition set to False" }, }, @@ -286,7 +285,7 @@ func TestHandleUpstreamRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongTarget) (bool, string){ func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionFalse && + return c.Type == konnectv1alpha1.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionFalse && c.Message == fmt.Sprintf("Referenced KongUpstream %s/%s is not programmed yet", testKongUpstreamNotProgrammed.Namespace, testKongUpstreamNotProgrammed.Name) }), "KongTarget does not have KongUpstreamRefValid condition set to False" @@ -313,7 +312,7 @@ func TestHandleUpstreamRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongTarget) (bool, string){ func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongTarget does not have KongUpstreamRefValid condition set to True" }, }, @@ -377,12 +376,12 @@ func TestHandleUpstreamRef(t *testing.T) { updatedEntAssertions: []func(*configurationv1alpha1.KongTarget) (bool, string){ func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue + return c.Type == konnectv1alpha1.KongUpstreamRefValidConditionType && c.Status == metav1.ConditionTrue }), "KongTarget does not have KongUpstreamRefValid condition set to True" }, func(kt *configurationv1alpha1.KongTarget) (bool, string) { return lo.ContainsBy(kt.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionFalse + return c.Type == konnectv1alpha1.ControlPlaneRefValidConditionType && c.Status == metav1.ConditionFalse }), "KongTarget does not have ControlPlaneRefValid condition set to False" }, }, diff --git a/docs/api-reference.md b/docs/api-reference.md index ac66ab752..e8ab3d55a 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -3,6 +3,7 @@ ## Packages - [configuration.konghq.com/v1](#configurationkonghqcomv1) - [configuration.konghq.com/v1alpha1](#configurationkonghqcomv1alpha1) +- [configuration.konghq.com/v1beta1](#configurationkonghqcomv1beta1) - [gateway-operator.konghq.com/v1alpha1](#gateway-operatorkonghqcomv1alpha1) - [gateway-operator.konghq.com/v1beta1](#gateway-operatorkonghqcomv1beta1) - [konnect.konghq.com/v1alpha1](#konnectkonghqcomv1alpha1) @@ -80,6 +81,22 @@ KongConsumerSpec defines the specification of the KongConsumer. | `controlPlaneRef` _[ControlPlaneRef](#controlplaneref)_ | ControlPlaneRef is a reference to a ControlPlane this Consumer is associated with. | +_Appears in:_ +- [KongConsumer](#kongconsumer) + +#### KongConsumerStatus + + +KongConsumerStatus represents the current status of the KongConsumer resource. + + + +| Field | Description | +| --- | --- | +| `konnect` _[KonnectEntityStatusWithControlPlaneRef](#konnectentitystatuswithcontrolplaneref)_ | Konnect contains the Konnect entity status. | +| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#condition-v1-meta) array_ | Conditions describe the current conditions of the KongConsumer.

Known condition types are:

* "Programmed" | + + _Appears in:_ - [KongConsumer](#kongconsumer) @@ -1695,6 +1712,34 @@ _Appears in:_ - [KongPluginBindingTargets](#kongpluginbindingtargets) +## configuration.konghq.com/v1beta1 + +Package v1beta1 contains API Schema definitions for the configuration.konghq.com v1beta1 API group. + +- [KongConsumerGroup](#kongconsumergroup) +### KongConsumerGroup + + +KongConsumerGroup is the Schema for the kongconsumergroups API. + + + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `configuration.konghq.com/v1beta1` +| `kind` _string_ | `KongConsumerGroup` +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `spec` _[KongConsumerGroupSpec](#kongconsumergroupspec)_ | | +| `status` _[KongConsumerGroupStatus](#kongconsumergroupstatus)_ | Status represents the current status of the KongConsumerGroup resource. | + + + + + + +### Types + +In this section you will find types that the CRDs rely on. ## gateway-operator.konghq.com/v1alpha1 diff --git a/go.mod b/go.mod index 238459526..df4f690a0 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/go-logr/logr v1.4.2 github.com/google/go-containerregistry v0.20.2 github.com/google/uuid v1.6.0 - github.com/kong/kubernetes-configuration v0.0.28 + github.com/kong/kubernetes-configuration v0.0.29 github.com/kong/kubernetes-telemetry v0.1.5 github.com/kong/kubernetes-testing-framework v0.47.2 github.com/kong/semver/v4 v4.0.1 diff --git a/go.sum b/go.sum index 9436ed22b..2bcf2ad67 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,8 @@ github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2 github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kong/go-kong v0.59.1 h1:AJZtyCD+Zyqe/mF/m+x3/qN/GPVxAH7jq9zGJTHRfjc= github.com/kong/go-kong v0.59.1/go.mod h1:8Vt6HmtgLNgL/7bSwAlz3DIWqBtzG7qEt9+OnMiQOa0= -github.com/kong/kubernetes-configuration v0.0.28 h1:3W1YcKtpRS6wrtvvvJdVzp5UT14+HpEBqAPC3rOPHTo= -github.com/kong/kubernetes-configuration v0.0.28/go.mod h1:oAdPMWiWJ6qbMPPExUSj3c3YrI675JUIfsDcKWnGW0M= +github.com/kong/kubernetes-configuration v0.0.29 h1:NgjQyZ4PekXW0w4Qi+i/GP3HENWzHfIs3h+wMDWa91o= +github.com/kong/kubernetes-configuration v0.0.29/go.mod h1:oAdPMWiWJ6qbMPPExUSj3c3YrI675JUIfsDcKWnGW0M= github.com/kong/kubernetes-telemetry v0.1.5 h1:xHwU1q0IvfEYqpj03po73ZKbVarnFPUwzkoFkdVnr9w= github.com/kong/kubernetes-telemetry v0.1.5/go.mod h1:1UXyZ6N3e8Fl6YguToQ6tKNveonkhjSqxzY7HVW+Ba4= github.com/kong/kubernetes-testing-framework v0.47.2 h1:+2Z9anTpbV/hwNeN+NFQz53BMU+g3QJydkweBp3tULo= diff --git a/pkg/utils/kubernetes/reduce/filters.go b/pkg/utils/kubernetes/reduce/filters.go index 38751bc28..2f6597462 100644 --- a/pkg/utils/kubernetes/reduce/filters.go +++ b/pkg/utils/kubernetes/reduce/filters.go @@ -13,10 +13,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" operatorv1beta1 "github.com/kong/gateway-operator/api/v1beta1" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/pkg/consts" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) // FiltenNone filter nothing, that is it returns the same slice as provided. @@ -485,7 +485,7 @@ func filterKongPluginBindings(kpbs []configurationv1alpha1.KongPluginBinding) [] best := 0 for i, kpb := range kpbs { if lo.ContainsBy(kpb.Status.Conditions, func(c metav1.Condition) bool { - return c.Type == conditions.KonnectEntityProgrammedConditionType && + return c.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && c.Status == metav1.ConditionTrue }) { diff --git a/scripts/apidocs-gen/generate.sh b/scripts/apidocs-gen/generate.sh index cb278932f..772c12d20 100755 --- a/scripts/apidocs-gen/generate.sh +++ b/scripts/apidocs-gen/generate.sh @@ -27,6 +27,7 @@ KUBERNETES_CONFIGURATION_CRDS_CRDS_LOCAL_PATH="$(go env GOPATH)/pkg/mod/${KUBERN # NOTE: https://apple.stackexchange.com/questions/69223/how-to-replace-mac-os-x-utilities-with-gnu-core-utilities CP=cp if [[ $(uname -s) == "Darwin" ]]; then + HOMEBREW_PREFIX=$(brew --prefix) if gcp --version 2>&1 >/dev/null ; then CP=${HOMEBREW_PREFIX}/bin/gcp else diff --git a/test/envtest/konnect_entities_cacertificate_test.go b/test/envtest/konnect_entities_cacertificate_test.go index e2f683e7e..2f4d31b70 100644 --- a/test/envtest/konnect_entities_cacertificate_test.go +++ b/test/envtest/konnect_entities_cacertificate_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongCACertificate(t *testing.T) { @@ -73,7 +73,7 @@ func TestKongCACertificate(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongCACertificate's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_certificate_test.go b/test/envtest/konnect_entities_certificate_test.go index 4fd327051..dd8fcf509 100644 --- a/test/envtest/konnect_entities_certificate_test.go +++ b/test/envtest/konnect_entities_certificate_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongCertificate(t *testing.T) { @@ -73,7 +73,7 @@ func TestKongCertificate(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongCertificate's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_dataplaneclientcertificate_test.go b/test/envtest/konnect_entities_dataplaneclientcertificate_test.go index b12897483..e5d88ec01 100644 --- a/test/envtest/konnect_entities_dataplaneclientcertificate_test.go +++ b/test/envtest/konnect_entities_dataplaneclientcertificate_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongDataPlaneClientCertificate(t *testing.T) { @@ -77,7 +77,7 @@ func TestKongDataPlaneClientCertificate(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongDataPlaneClientCertificate's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_gatewaycontrolplane_test.go b/test/envtest/konnect_entities_gatewaycontrolplane_test.go index 1b68f51db..b17c71eb8 100644 --- a/test/envtest/konnect_entities_gatewaycontrolplane_test.go +++ b/test/envtest/konnect_entities_gatewaycontrolplane_test.go @@ -15,7 +15,6 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/test/helpers/deploy" @@ -214,7 +213,7 @@ var konnectGatewayControlPlaneTestCases = []konnectEntityReconcilerTestCase{ func conditionsContainProgrammedTrue(conds []metav1.Condition) bool { return lo.ContainsBy(conds, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }, ) diff --git a/test/envtest/konnect_entities_key_test.go b/test/envtest/konnect_entities_key_test.go index 908f699b1..a7a5aab7a 100644 --- a/test/envtest/konnect_entities_key_test.go +++ b/test/envtest/konnect_entities_key_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongKey(t *testing.T) { @@ -83,7 +83,7 @@ func TestKongKey(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongKey's Programmed condition should be true eventually") @@ -140,7 +140,7 @@ func TestKongKey(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KeySetRefValidConditionType && + return condition.Type == konnectv1alpha1.KeySetRefValidConditionType && condition.Status == metav1.ConditionFalse }) }, "KongKey's KeySetRefValid condition should be false eventually as the KongKeySet is not created yet") @@ -168,11 +168,11 @@ func TestKongKey(t *testing.T) { return false } programmed := lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) associated := lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KeySetRefValidConditionType && + return condition.Type == konnectv1alpha1.KeySetRefValidConditionType && condition.Status == metav1.ConditionTrue }) keySetIDPopulated := c.Status.Konnect != nil && c.Status.Konnect.KeySetID != "" diff --git a/test/envtest/konnect_entities_keyset_test.go b/test/envtest/konnect_entities_keyset_test.go index 1e9c82c66..f83d2a95f 100644 --- a/test/envtest/konnect_entities_keyset_test.go +++ b/test/envtest/konnect_entities_keyset_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongKeySet(t *testing.T) { @@ -78,7 +78,7 @@ func TestKongKeySet(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongKeySet's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_kongconsumer_test.go b/test/envtest/konnect_entities_kongconsumer_test.go index 9b18cdd53..f676a672a 100644 --- a/test/envtest/konnect_entities_kongconsumer_test.go +++ b/test/envtest/konnect_entities_kongconsumer_test.go @@ -15,13 +15,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" konnectops "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" configurationv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongConsumer(t *testing.T) { @@ -99,7 +99,7 @@ func TestKongConsumer(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongConsumer's Programmed condition should be true eventually") @@ -222,7 +222,7 @@ func TestKongConsumer(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongConsumer's Programmed condition should be true eventually") @@ -233,7 +233,7 @@ func TestKongConsumer(t *testing.T) { return false } return lo.ContainsBy(c.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongConsumerGroup's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_kongvault_test.go b/test/envtest/konnect_entities_kongvault_test.go index f25743552..0287ca341 100644 --- a/test/envtest/konnect_entities_kongvault_test.go +++ b/test/envtest/konnect_entities_kongvault_test.go @@ -15,12 +15,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" konnectops "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongVault(t *testing.T) { @@ -82,7 +82,7 @@ func TestKongVault(t *testing.T) { } return lo.ContainsBy(v.Status.Conditions, func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue }) }, "KongVault's Programmed condition should be true eventually") diff --git a/test/envtest/konnect_entities_sni_test.go b/test/envtest/konnect_entities_sni_test.go index 42d2bcf28..a42d749e8 100644 --- a/test/envtest/konnect_entities_sni_test.go +++ b/test/envtest/konnect_entities_sni_test.go @@ -16,13 +16,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" "github.com/kong/gateway-operator/controller/konnect/ops" "github.com/kong/gateway-operator/modules/manager/scheme" "github.com/kong/gateway-operator/test/helpers/deploy" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" - konnectalpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) func TestKongSNI(t *testing.T) { @@ -56,15 +55,15 @@ func TestKongSNI(t *testing.T) { t.Log("Creating KongCertificate and setting it to Programmed") createdCert := deploy.KongCertificateAttachedToCP(t, ctx, clientNamespaced, cp) createdCert.Status = configurationv1alpha1.KongCertificateStatus{ - Konnect: &konnectalpha1.KonnectEntityStatusWithControlPlaneRef{ + Konnect: &konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef{ KonnectEntityStatus: konnectEntityStatus("cert-12345"), ControlPlaneID: cp.Status.GetKonnectID(), }, Conditions: []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, - Reason: conditions.KonnectEntityProgrammedReasonProgrammed, + Reason: konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, ObservedGeneration: createdCert.GetGeneration(), LastTransitionTime: metav1.Now(), }, diff --git a/test/envtest/update_status.go b/test/envtest/update_status.go index 083f890a0..1eabeabf2 100644 --- a/test/envtest/update_status.go +++ b/test/envtest/update_status.go @@ -8,7 +8,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kong/gateway-operator/controller/konnect/conditions" k8sutils "github.com/kong/gateway-operator/pkg/utils/kubernetes" configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" @@ -135,9 +134,9 @@ func konnectEntityStatus(id string) konnectv1alpha1.KonnectEntityStatus { func programmedCondition(generation int64) metav1.Condition { return k8sutils.NewConditionWithGeneration( - conditions.KonnectEntityProgrammedConditionType, + konnectv1alpha1.KonnectEntityProgrammedConditionType, metav1.ConditionTrue, - conditions.KonnectEntityProgrammedReasonProgrammed, + konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, "", generation, ) diff --git a/test/helpers/deploy/deploy_resources.go b/test/helpers/deploy/deploy_resources.go index ca6e53316..055af50cd 100644 --- a/test/helpers/deploy/deploy_resources.go +++ b/test/helpers/deploy/deploy_resources.go @@ -13,8 +13,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kong/gateway-operator/controller/konnect/conditions" - configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" configurationv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" @@ -107,9 +105,9 @@ func KonnectAPIAuthConfigurationWithProgrammed( apiAuth := KonnectAPIAuthConfiguration(t, ctx, cl) apiAuth.Status.Conditions = []metav1.Condition{ { - Type: conditions.KonnectEntityAPIAuthConfigurationValidConditionType, + Type: konnectv1alpha1.KonnectEntityAPIAuthConfigurationValidConditionType, Status: metav1.ConditionTrue, - Reason: conditions.KonnectEntityAPIAuthConfigurationReasonValid, + Reason: konnectv1alpha1.KonnectEntityAPIAuthConfigurationReasonValid, ObservedGeneration: apiAuth.GetGeneration(), LastTransitionTime: metav1.Now(), }, @@ -169,9 +167,9 @@ func KonnectGatewayControlPlaneWithID( cp := KonnectGatewayControlPlane(t, ctx, cl, apiAuth, opts...) cp.Status.Conditions = []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, - Reason: conditions.KonnectEntityProgrammedReasonProgrammed, + Reason: konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, ObservedGeneration: cp.GetGeneration(), LastTransitionTime: metav1.Now(), }, @@ -271,9 +269,9 @@ func KongConsumerWithProgrammed( consumer.Status.Conditions = []metav1.Condition{ { - Type: conditions.KonnectEntityProgrammedConditionType, + Type: konnectv1alpha1.KonnectEntityProgrammedConditionType, Status: metav1.ConditionTrue, - Reason: conditions.KonnectEntityProgrammedReasonProgrammed, + Reason: konnectv1alpha1.KonnectEntityProgrammedReasonProgrammed, ObservedGeneration: consumer.GetGeneration(), LastTransitionTime: metav1.Now(), }, diff --git a/test/integration/test_konnect_entities.go b/test/integration/test_konnect_entities.go index f7d41ec35..07730ea01 100644 --- a/test/integration/test_konnect_entities.go +++ b/test/integration/test_konnect_entities.go @@ -15,7 +15,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/gateway-operator/controller/konnect" - "github.com/kong/gateway-operator/controller/konnect/conditions" testutils "github.com/kong/gateway-operator/pkg/utils/test" "github.com/kong/gateway-operator/test" "github.com/kong/gateway-operator/test/helpers" @@ -258,7 +257,7 @@ func assertKonnectEntityProgrammed( assert.NotEmpty(t, konnectStatus.GetServerURL()) assert.True(t, lo.ContainsBy(obj.GetConditions(), func(condition metav1.Condition) bool { - return condition.Type == conditions.KonnectEntityProgrammedConditionType && + return condition.Type == konnectv1alpha1.KonnectEntityProgrammedConditionType && condition.Status == metav1.ConditionTrue })) }