From fea0231240dbe0839adbc3e365031436950b193e Mon Sep 17 00:00:00 2001 From: craig Date: Fri, 18 Oct 2024 20:41:55 +0100 Subject: [PATCH 1/2] update to latest dnsrecord types Signed-off-by: craig rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 15506a7d2..084b69211 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/google/uuid v1.6.0 github.com/kuadrant/authorino v0.18.0 github.com/kuadrant/authorino-operator v0.11.1 - github.com/kuadrant/dns-operator v0.0.0-20241018131559-f2ce8b6aaaef + github.com/kuadrant/dns-operator v0.0.0-20241018153635-382130801432 github.com/kuadrant/limitador-operator v0.9.0 github.com/kuadrant/policy-machinery v0.5.0 github.com/martinlindhe/base36 v1.1.1 diff --git a/go.sum b/go.sum index 8fb8ff898..ae6860ff7 100644 --- a/go.sum +++ b/go.sum @@ -260,6 +260,8 @@ github.com/kuadrant/authorino-operator v0.11.1 h1:jndTZhiHMU+2Dk0NU+KP2+MUSfvclr github.com/kuadrant/authorino-operator v0.11.1/go.mod h1:TeFFdX477vUTMushCojaHpvwPLga4DpErGI2oQbqFIs= github.com/kuadrant/dns-operator v0.0.0-20241018131559-f2ce8b6aaaef h1:6P2pC1kOPcrT/22N23Mr3xr3CTHmQQkj3jmOlUEJvO0= github.com/kuadrant/dns-operator v0.0.0-20241018131559-f2ce8b6aaaef/go.mod h1:LGG4R3KEz93Ep0CV1/tziCmRk+VtojWUHR9mXkOHZks= +github.com/kuadrant/dns-operator v0.0.0-20241018153635-382130801432 h1:M5I5+xzYJipFlyxB0ISV3Lk3qT6WzWT5H5eZCr8cbwE= +github.com/kuadrant/dns-operator v0.0.0-20241018153635-382130801432/go.mod h1:LGG4R3KEz93Ep0CV1/tziCmRk+VtojWUHR9mXkOHZks= github.com/kuadrant/limitador-operator v0.9.0 h1:hTQ6CFPayf/sL7cIzwWjCoU8uTn6fzWdsJgKbDlnFts= github.com/kuadrant/limitador-operator v0.9.0/go.mod h1:DQOlg9qFOcnWPrwO529JRCMLLOEXJQxkmOes952S/Hw= github.com/kuadrant/policy-machinery v0.5.0 h1:hTllNYswhEOFrS/uj8kY4a4wq2W1xL2hagHeftn9TTY= From 44e19845302c0ada19038773737f3a1b194c737a Mon Sep 17 00:00:00 2001 From: craig Date: Fri, 18 Oct 2024 21:06:07 +0100 Subject: [PATCH 2/2] v1 dnspolicy and tlspolicy api Signed-off-by: craig rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED --- Makefile | 2 +- api/{v1alpha1 => v1}/dnspolicy_types.go | 6 +-- api/{v1alpha1 => v1}/groupversion_info.go | 4 +- api/{v1alpha1 => v1}/tlspolicy_types.go | 2 +- api/{v1alpha1 => v1}/topology.go | 2 +- api/{v1alpha1 => v1}/zz_generated.deepcopy.go | 26 +++++------ ...adrant-operator.clusterserviceversion.yaml | 44 +++++-------------- bundle/manifests/kuadrant.io_dnspolicies.yaml | 2 +- bundle/manifests/kuadrant.io_tlspolicies.yaml | 2 +- .../templates/manifests.yaml | 4 +- config/crd/bases/kuadrant.io_dnspolicies.yaml | 2 +- config/crd/bases/kuadrant.io_tlspolicies.yaml | 2 +- .../samples/kuadrant_v1alpha1_dnspolicy.yaml | 13 ------ .../samples/kuadrant_v1alpha1_tlspolicy.yaml | 14 ------ config/samples/kustomization.yaml | 10 ++--- controllers/dns_helper.go | 9 ++-- controllers/dns_helper_test.go | 20 ++++----- controllers/dnspolicy_controller.go | 12 ++--- controllers/dnspolicy_dnsrecords.go | 14 +++--- controllers/dnspolicy_status.go | 16 +++---- controllers/dnspolicy_status_test.go | 1 - controllers/state_of_the_world.go | 20 ++++----- controllers/target_status_controller.go | 10 ++--- controllers/test_common.go | 4 +- controllers/tls_workflow.go | 10 ++--- controllers/tlspolicies_validator.go | 12 ++--- controllers/tlspolicy_certmanager.go | 7 ++- .../tlspolicy_certmanager_certificates.go | 22 +++++----- controllers/tlspolicy_controller.go | 12 ++--- controllers/tlspolicy_status_updater.go | 20 ++++----- controllers/tlspolicy_status_updater_test.go | 42 +++++++++--------- doc/dns.md | 4 +- doc/dnshealthchecks.md | 2 +- .../dns-excluding-specific-addresses.md | 2 +- doc/user-guides/gateway-dns.md | 2 +- ...re-protect-connect-single-multi-cluster.md | 2 +- doc/user-guides/secure-protect-connect.md | 4 +- .../dnspolicy/dnspolicy-bad-strategy.yaml | 12 ----- .../dnspolicy/dnspolicy-exclude-address.yaml | 8 ++-- .../dnspolicy/dnspolicy-healthchecks.yaml | 2 +- examples/dnspolicy/dnspolicy.yaml | 2 +- main.go | 4 +- ...nspolicy_controller_single_cluster_test.go | 1 - .../dnspolicy/dnspolicy_controller_test.go | 1 - .../target_status_controller_test.go | 24 +++++----- .../tlspolicy/tlspolicy_controller_test.go | 1 - tests/commons.go | 6 +-- 47 files changed, 188 insertions(+), 255 deletions(-) rename api/{v1alpha1 => v1}/dnspolicy_types.go (99%) rename api/{v1alpha1 => v1}/groupversion_info.go (97%) rename api/{v1alpha1 => v1}/tlspolicy_types.go (99%) rename api/{v1alpha1 => v1}/topology.go (99%) rename api/{v1alpha1 => v1}/zz_generated.deepcopy.go (94%) delete mode 100644 config/samples/kuadrant_v1alpha1_dnspolicy.yaml delete mode 100644 config/samples/kuadrant_v1alpha1_tlspolicy.yaml delete mode 100644 examples/dnspolicy/dnspolicy-bad-strategy.yaml diff --git a/Makefile b/Makefile index 4e5f19429..9233a3116 100644 --- a/Makefile +++ b/Makefile @@ -296,7 +296,7 @@ endef .PHONY: manifests manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) crd paths="./api/v1alpha1;./api/v1beta1;./api/v1beta2;./api/v1beta3" output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) crd paths="./api/v1;./api/v1beta1;./api/v1beta2;./api/v1beta3" output:crd:artifacts:config=config/crd/bases $(CONTROLLER_GEN) rbac:roleName=manager-role webhook paths="./..." .PHONY: dependencies-manifests diff --git a/api/v1alpha1/dnspolicy_types.go b/api/v1/dnspolicy_types.go similarity index 99% rename from api/v1alpha1/dnspolicy_types.go rename to api/v1/dnspolicy_types.go index 2ca52fd3f..b7d7ef54c 100644 --- a/api/v1alpha1/dnspolicy_types.go +++ b/api/v1/dnspolicy_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "context" @@ -280,9 +280,9 @@ func (p *DNSPolicy) WithTargetGateway(gwName string) *DNSPolicy { func (p *DNSPolicy) WithHealthCheckFor(endpoint string, port int, protocol string, failureThreshold int) *DNSPolicy { return p.WithHealthCheck(dnsv1alpha1.HealthCheckSpec{ Path: endpoint, - Port: &port, + Port: port, Protocol: dnsv1alpha1.Protocol(protocol), - FailureThreshold: &failureThreshold, + FailureThreshold: failureThreshold, }) } diff --git a/api/v1alpha1/groupversion_info.go b/api/v1/groupversion_info.go similarity index 97% rename from api/v1alpha1/groupversion_info.go rename to api/v1/groupversion_info.go index 783effe11..f13a32f39 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1/groupversion_info.go @@ -17,7 +17,7 @@ limitations under the License. // Package v1alpha1 contains API Schema definitions for the kuadrant.io v1alpha1 API group // +kubebuilder:object:generate=true // +groupName=kuadrant.io -package v1alpha1 +package v1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "kuadrant.io", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "kuadrant.io", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/v1alpha1/tlspolicy_types.go b/api/v1/tlspolicy_types.go similarity index 99% rename from api/v1alpha1/tlspolicy_types.go rename to api/v1/tlspolicy_types.go index ebf168a85..cbc172efd 100644 --- a/api/v1alpha1/tlspolicy_types.go +++ b/api/v1/tlspolicy_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "context" diff --git a/api/v1alpha1/topology.go b/api/v1/topology.go similarity index 99% rename from api/v1alpha1/topology.go rename to api/v1/topology.go index 0ab5156bf..45d6321c1 100644 --- a/api/v1alpha1/topology.go +++ b/api/v1/topology.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 // Contains of this file allow the DNSPolicy and TLSPolicy to adhere to the machinery.Policy interface diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go similarity index 94% rename from api/v1alpha1/zz_generated.deepcopy.go rename to api/v1/zz_generated.deepcopy.go index 53a868b6c..1371baae0 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -18,12 +18,12 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" - apiv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" - "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/kuadrant/dns-operator/api/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -33,12 +33,12 @@ func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { out.IssuerRef = in.IssuerRef if in.Duration != nil { in, out := &in.Duration, &out.Duration - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } if in.RenewBefore != nil { in, out := &in.RenewBefore, &out.RenewBefore - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } if in.Usages != nil { @@ -133,7 +133,7 @@ func (in *DNSPolicySpec) DeepCopyInto(out *DNSPolicySpec) { out.TargetRef = in.TargetRef if in.HealthCheck != nil { in, out := &in.HealthCheck, &out.HealthCheck - *out = new(apiv1alpha1.HealthCheckSpec) + *out = new(v1alpha1.HealthCheckSpec) (*in).DeepCopyInto(*out) } if in.LoadBalancing != nil { @@ -143,7 +143,7 @@ func (in *DNSPolicySpec) DeepCopyInto(out *DNSPolicySpec) { } if in.ProviderRefs != nil { in, out := &in.ProviderRefs, &out.ProviderRefs - *out = make([]apiv1alpha1.ProviderRef, len(*in)) + *out = make([]v1alpha1.ProviderRef, len(*in)) copy(*out, *in) } if in.ExcludeAddresses != nil { @@ -168,27 +168,27 @@ func (in *DNSPolicyStatus) DeepCopyInto(out *DNSPolicyStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.HealthCheck != nil { in, out := &in.HealthCheck, &out.HealthCheck - *out = new(apiv1alpha1.HealthCheckStatus) + *out = new(v1alpha1.HealthCheckStatus) (*in).DeepCopyInto(*out) } if in.RecordConditions != nil { in, out := &in.RecordConditions, &out.RecordConditions - *out = make(map[string][]v1.Condition, len(*in)) + *out = make(map[string][]metav1.Condition, len(*in)) for key, val := range *in { - var outVal []v1.Condition + var outVal []metav1.Condition if val == nil { (*out)[key] = nil } else { inVal := (*in)[key] in, out := &inVal, &outVal - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -304,7 +304,7 @@ func (in *TLSPolicyStatus) DeepCopyInto(out *TLSPolicyStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml b/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml index 93eccaa51..055a2c9fa 100644 --- a/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml +++ b/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml @@ -5,34 +5,18 @@ metadata: alm-examples: |- [ { - "apiVersion": "kuadrant.io/v1alpha1", + "apiVersion": "kuadrant.io/v1", "kind": "DNSPolicy", "metadata": { "name": "dnspolicy-sample" }, "spec": { "healthCheck": { - "endpoint": "/", - "protocol": "HTTP" - }, - "targetRef": { - "group": "gateway.networking.k8s.io", - "kind": "Gateway", - "name": "example-gateway" - } - } - }, - { - "apiVersion": "kuadrant.io/v1alpha1", - "kind": "TLSPolicy", - "metadata": { - "name": "tlspolicy-sample" - }, - "spec": { - "issuerRef": { - "group": "cert-manager.io", - "kind": "ClusterIssuer", - "name": "self-signed-ca" + "failureThreshold": 5, + "interval": "10s", + "path": "/", + "port": 443, + "protocol": "HTTPS" }, "targetRef": { "group": "gateway.networking.k8s.io", @@ -106,7 +90,7 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/kuadrant/kuadrant-operator:latest - createdAt: "2024-10-18T15:08:50Z" + createdAt: "2024-10-18T20:16:38Z" description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system operators.operatorframework.io/builder: operator-sdk-v1.32.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 @@ -124,12 +108,9 @@ spec: kind: AuthPolicy name: authpolicies.kuadrant.io version: v1beta2 - - description: DNSPolicy configures how North-South based traffic should be balanced - and reach the gateways - displayName: DNSPolicy - kind: DNSPolicy + - kind: DNSPolicy name: dnspolicies.kuadrant.io - version: v1alpha1 + version: v1 - description: Kuadrant configures installations of Kuadrant Service Protection components displayName: Kuadrant @@ -142,12 +123,9 @@ spec: kind: RateLimitPolicy name: ratelimitpolicies.kuadrant.io version: v1beta3 - - description: TLSPolicy provides tls for gateway listeners by managing the lifecycle - of tls certificates - displayName: TLSPolicy - kind: TLSPolicy + - kind: TLSPolicy name: tlspolicies.kuadrant.io - version: v1alpha1 + version: v1 description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system displayName: Kuadrant Operator icon: diff --git a/bundle/manifests/kuadrant.io_dnspolicies.yaml b/bundle/manifests/kuadrant.io_dnspolicies.yaml index 42dfb30db..739b7f5f2 100644 --- a/bundle/manifests/kuadrant.io_dnspolicies.yaml +++ b/bundle/manifests/kuadrant.io_dnspolicies.yaml @@ -41,7 +41,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: DNSPolicy is the Schema for the dnspolicies API diff --git a/bundle/manifests/kuadrant.io_tlspolicies.yaml b/bundle/manifests/kuadrant.io_tlspolicies.yaml index 7635d670a..53b08274f 100644 --- a/bundle/manifests/kuadrant.io_tlspolicies.yaml +++ b/bundle/manifests/kuadrant.io_tlspolicies.yaml @@ -41,7 +41,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: TLSPolicy is the Schema for the tlspolicies API diff --git a/charts/kuadrant-operator/templates/manifests.yaml b/charts/kuadrant-operator/templates/manifests.yaml index 969d0f0ba..d339d2c65 100644 --- a/charts/kuadrant-operator/templates/manifests.yaml +++ b/charts/kuadrant-operator/templates/manifests.yaml @@ -13243,7 +13243,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: DNSPolicy is the Schema for the dnspolicies API @@ -14423,7 +14423,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: TLSPolicy is the Schema for the tlspolicies API diff --git a/config/crd/bases/kuadrant.io_dnspolicies.yaml b/config/crd/bases/kuadrant.io_dnspolicies.yaml index ab686e3a6..2f33fe477 100644 --- a/config/crd/bases/kuadrant.io_dnspolicies.yaml +++ b/config/crd/bases/kuadrant.io_dnspolicies.yaml @@ -40,7 +40,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: DNSPolicy is the Schema for the dnspolicies API diff --git a/config/crd/bases/kuadrant.io_tlspolicies.yaml b/config/crd/bases/kuadrant.io_tlspolicies.yaml index a26086554..d16a068cf 100644 --- a/config/crd/bases/kuadrant.io_tlspolicies.yaml +++ b/config/crd/bases/kuadrant.io_tlspolicies.yaml @@ -40,7 +40,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v1alpha1 + name: v1 schema: openAPIV3Schema: description: TLSPolicy is the Schema for the tlspolicies API diff --git a/config/samples/kuadrant_v1alpha1_dnspolicy.yaml b/config/samples/kuadrant_v1alpha1_dnspolicy.yaml deleted file mode 100644 index 10dc274ce..000000000 --- a/config/samples/kuadrant_v1alpha1_dnspolicy.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: kuadrant.io/v1alpha1 -kind: DNSPolicy -metadata: - name: dnspolicy-sample -spec: - targetRef: - name: example-gateway - group: gateway.networking.k8s.io - kind: Gateway - healthCheck: - endpoint: / - protocol: HTTP diff --git a/config/samples/kuadrant_v1alpha1_tlspolicy.yaml b/config/samples/kuadrant_v1alpha1_tlspolicy.yaml deleted file mode 100644 index 89dc838d0..000000000 --- a/config/samples/kuadrant_v1alpha1_tlspolicy.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -apiVersion: kuadrant.io/v1alpha1 -kind: TLSPolicy -metadata: - name: tlspolicy-sample -spec: - targetRef: - name: example-gateway - group: gateway.networking.k8s.io - kind: Gateway - issuerRef: - group: cert-manager.io - kind: ClusterIssuer - name: self-signed-ca diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index ea729496b..f5214c82e 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,8 +1,8 @@ ## Append samples you want in your CSV to this file as resources ## resources: -- kuadrant_v1beta1_kuadrant.yaml -- kuadrant_v1beta2_authpolicy.yaml -- kuadrant_v1beta3_ratelimitpolicy.yaml -- kuadrant_v1alpha1_dnspolicy.yaml -- kuadrant_v1alpha1_tlspolicy.yaml + - kuadrant_v1beta1_kuadrant.yaml + - kuadrant_v1beta2_authpolicy.yaml + - kuadrant_v1beta3_ratelimitpolicy.yaml + - kuadrant_v1_dnspolicy.yaml + - kuadrant_v1_tlspolicy.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/controllers/dns_helper.go b/controllers/dns_helper.go index 152194945..5038d3c65 100644 --- a/controllers/dns_helper.go +++ b/controllers/dns_helper.go @@ -12,8 +12,7 @@ import ( kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" "github.com/kuadrant/dns-operator/pkg/builder" - - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" ) const ( @@ -26,7 +25,7 @@ type dnsHelper struct { client.Client } -func commonDNSRecordLabels(gwKey client.ObjectKey, p *v1alpha1.DNSPolicy) map[string]string { +func commonDNSRecordLabels(gwKey client.ObjectKey, p *v1.DNSPolicy) map[string]string { commonLabels := map[string]string{} for k, v := range policyDNSRecordLabels(p) { commonLabels[k] = v @@ -37,7 +36,7 @@ func commonDNSRecordLabels(gwKey client.ObjectKey, p *v1alpha1.DNSPolicy) map[st return commonLabels } -func policyDNSRecordLabels(p *v1alpha1.DNSPolicy) map[string]string { +func policyDNSRecordLabels(p *v1.DNSPolicy) map[string]string { return map[string]string{ p.DirectReferenceAnnotationName(): p.Name, fmt.Sprintf("%s-namespace", p.DirectReferenceAnnotationName()): p.Namespace, @@ -117,7 +116,7 @@ func (g GatewayWrapper) GetAddresses() []builder.TargetAddress { return addresses } -func (g *GatewayWrapper) RemoveExcludedStatusAddresses(p *v1alpha1.DNSPolicy) error { +func (g *GatewayWrapper) RemoveExcludedStatusAddresses(p *v1.DNSPolicy) error { g.excludedAddresses = p.Spec.ExcludeAddresses newAddresses := []gatewayapiv1.GatewayStatusAddress{} for _, address := range g.Gateway.Status.Addresses { diff --git a/controllers/dns_helper_test.go b/controllers/dns_helper_test.go index 39e26bb70..5a07581f6 100644 --- a/controllers/dns_helper_test.go +++ b/controllers/dns_helper_test.go @@ -5,7 +5,7 @@ import ( gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" "github.com/kuadrant/kuadrant-operator/controllers" ) @@ -15,7 +15,7 @@ func TestRemoveExcludedStatusAddresses(t *testing.T) { testCases := []struct { Name string Gateway *gatewayapiv1.Gateway - DNSPolicy *v1alpha1.DNSPolicy + DNSPolicy *v1.DNSPolicy Validate func(t *testing.T, g *gatewayapiv1.GatewayStatus) ExpectErr bool }{ @@ -35,8 +35,8 @@ func TestRemoveExcludedStatusAddresses(t *testing.T) { }, }, }, - DNSPolicy: &v1alpha1.DNSPolicy{ - Spec: v1alpha1.DNSPolicySpec{ + DNSPolicy: &v1.DNSPolicy{ + Spec: v1.DNSPolicySpec{ ExcludeAddresses: []string{ "1.1.1.1", }, @@ -69,8 +69,8 @@ func TestRemoveExcludedStatusAddresses(t *testing.T) { }, }, }, - DNSPolicy: &v1alpha1.DNSPolicy{ - Spec: v1alpha1.DNSPolicySpec{ + DNSPolicy: &v1.DNSPolicy{ + Spec: v1.DNSPolicySpec{ ExcludeAddresses: []string{}, }, }, @@ -100,8 +100,8 @@ func TestRemoveExcludedStatusAddresses(t *testing.T) { }, }, }, - DNSPolicy: &v1alpha1.DNSPolicy{ - Spec: v1alpha1.DNSPolicySpec{ + DNSPolicy: &v1.DNSPolicy{ + Spec: v1.DNSPolicySpec{ ExcludeAddresses: []string{ "1.1.0.0/16", "10.0.0.1/32", @@ -139,8 +139,8 @@ func TestRemoveExcludedStatusAddresses(t *testing.T) { }, }, }, - DNSPolicy: &v1alpha1.DNSPolicy{ - Spec: v1alpha1.DNSPolicySpec{ + DNSPolicy: &v1.DNSPolicy{ + Spec: v1.DNSPolicySpec{ ExcludeAddresses: []string{ "1.1.0.0/161", "example.com", diff --git a/controllers/dnspolicy_controller.go b/controllers/dnspolicy_controller.go index 749c6efc6..5f88ee5a9 100644 --- a/controllers/dnspolicy_controller.go +++ b/controllers/dnspolicy_controller.go @@ -33,7 +33,7 @@ import ( kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" kuadrantgatewayapi "github.com/kuadrant/kuadrant-operator/pkg/library/gatewayapi" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" "github.com/kuadrant/kuadrant-operator/pkg/library/mappers" @@ -64,7 +64,7 @@ func (r *DNSPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( log.Info("Reconciling DNSPolicy") ctx = crlog.IntoContext(ctx, log) - previous := &v1alpha1.DNSPolicy{} + previous := &v1.DNSPolicy{} if err := r.Client().Get(ctx, req.NamespacedName, previous); err != nil { log.Info("error getting dns policy", "error", err) return ctrl.Result{}, client.IgnoreNotFound(err) @@ -125,7 +125,7 @@ func (r *DNSPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return statusResult, statusErr } -func (r *DNSPolicyReconciler) reconcileResources(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy, targetNetworkObject client.Object) error { +func (r *DNSPolicyReconciler) reconcileResources(ctx context.Context, dnsPolicy *v1.DNSPolicy, targetNetworkObject client.Object) error { // reconcile based on gateway diffs gatewayDiffObj, err := reconcilers.ComputeGatewayDiffs(ctx, r.Client(), dnsPolicy, targetNetworkObject) if err != nil { @@ -149,7 +149,7 @@ func (r *DNSPolicyReconciler) reconcileResources(ctx context.Context, dnsPolicy return nil } -func (r *DNSPolicyReconciler) deleteResources(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy, targetNetworkObject client.Object) error { +func (r *DNSPolicyReconciler) deleteResources(ctx context.Context, dnsPolicy *v1.DNSPolicy, targetNetworkObject client.Object) error { // delete based on gateway diffs if err := r.deleteDNSRecords(ctx, dnsPolicy); err != nil { return err @@ -182,14 +182,14 @@ func (r *DNSPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { } gatewayEventMapper := mappers.NewGatewayEventMapper( - v1alpha1.NewDNSPolicyType(), + v1.NewDNSPolicyType(), mappers.WithLogger(r.Logger().WithName("gateway.mapper")), mappers.WithClient(mgr.GetClient()), ) r.dnsHelper = dnsHelper{Client: r.Client()} ctrlr := ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.DNSPolicy{}). + For(&v1.DNSPolicy{}). Owns(&kuadrantdnsv1alpha1.DNSRecord{}). Watches(&gatewayapiv1.Gateway{}, handler.EnqueueRequestsFromMapFunc(gatewayEventMapper.Map)) return ctrlr.Complete(r) diff --git a/controllers/dnspolicy_dnsrecords.go b/controllers/dnspolicy_dnsrecords.go index 6c542505a..0e95b415e 100644 --- a/controllers/dnspolicy_dnsrecords.go +++ b/controllers/dnspolicy_dnsrecords.go @@ -16,7 +16,7 @@ import ( kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" "github.com/kuadrant/dns-operator/pkg/builder" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" reconcilerutils "github.com/kuadrant/kuadrant-operator/pkg/library/reconcilers" "github.com/kuadrant/kuadrant-operator/pkg/library/utils" ) @@ -26,7 +26,7 @@ var ( ErrNoAddresses = fmt.Errorf("no valid status addresses to use on gateway") ) -func (r *DNSPolicyReconciler) reconcileDNSRecords(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy, gwDiffObj *reconcilerutils.GatewayDiffs) error { +func (r *DNSPolicyReconciler) reconcileDNSRecords(ctx context.Context, dnsPolicy *v1.DNSPolicy, gwDiffObj *reconcilerutils.GatewayDiffs) error { log := crlog.FromContext(ctx) log.V(3).Info("reconciling dns records") @@ -47,7 +47,7 @@ func (r *DNSPolicyReconciler) reconcileDNSRecords(ctx context.Context, dnsPolicy return nil } -func (r *DNSPolicyReconciler) reconcileGatewayDNSRecords(ctx context.Context, gateway *gatewayapiv1.Gateway, dnsPolicy *v1alpha1.DNSPolicy) error { +func (r *DNSPolicyReconciler) reconcileGatewayDNSRecords(ctx context.Context, gateway *gatewayapiv1.Gateway, dnsPolicy *v1.DNSPolicy) error { log := crlog.FromContext(ctx) clusterID, err := utils.GetClusterUID(ctx, r.Client()) if err != nil { @@ -131,7 +131,7 @@ func (r *DNSPolicyReconciler) reconcileGatewayDNSRecords(ctx context.Context, ga return nil } -func (r *DNSPolicyReconciler) desiredDNSRecord(gateway *gatewayapiv1.Gateway, clusterID string, dnsPolicy *v1alpha1.DNSPolicy, targetListener gatewayapiv1.Listener) (*kuadrantdnsv1alpha1.DNSRecord, error) { +func (r *DNSPolicyReconciler) desiredDNSRecord(gateway *gatewayapiv1.Gateway, clusterID string, dnsPolicy *v1.DNSPolicy, targetListener gatewayapiv1.Listener) (*kuadrantdnsv1alpha1.DNSRecord, error) { rootHost := string(*targetListener.Hostname) var healthCheckSpec *kuadrantdnsv1alpha1.HealthCheckSpec @@ -170,11 +170,11 @@ func (r *DNSPolicyReconciler) desiredDNSRecord(gateway *gatewayapiv1.Gateway, cl return dnsRecord, nil } -func (r *DNSPolicyReconciler) deleteGatewayDNSRecords(ctx context.Context, gateway *gatewayapiv1.Gateway, dnsPolicy *v1alpha1.DNSPolicy) error { +func (r *DNSPolicyReconciler) deleteGatewayDNSRecords(ctx context.Context, gateway *gatewayapiv1.Gateway, dnsPolicy *v1.DNSPolicy) error { return r.deleteDNSRecordsWithLabels(ctx, commonDNSRecordLabels(client.ObjectKeyFromObject(gateway), dnsPolicy), dnsPolicy.Namespace) } -func (r *DNSPolicyReconciler) deleteDNSRecords(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy) error { +func (r *DNSPolicyReconciler) deleteDNSRecords(ctx context.Context, dnsPolicy *v1.DNSPolicy) error { return r.deleteDNSRecordsWithLabels(ctx, policyDNSRecordLabels(dnsPolicy), dnsPolicy.Namespace) } @@ -215,7 +215,7 @@ func dnsRecordBasicMutator(existingObj, desiredObj client.Object) (bool, error) return true, nil } -func buildEndpoints(clusterID, hostname string, gateway *gatewayapiv1.Gateway, policy *v1alpha1.DNSPolicy) ([]*externaldns.Endpoint, error) { +func buildEndpoints(clusterID, hostname string, gateway *gatewayapiv1.Gateway, policy *v1.DNSPolicy) ([]*externaldns.Endpoint, error) { endpointBuilder := builder.NewEndpointsBuilder(NewGatewayWrapper(gateway), hostname) if policy.Spec.LoadBalancing != nil { diff --git a/controllers/dnspolicy_status.go b/controllers/dnspolicy_status.go index 6c1147232..57f9b9ff3 100644 --- a/controllers/dnspolicy_status.go +++ b/controllers/dnspolicy_status.go @@ -34,14 +34,14 @@ import ( kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" "github.com/kuadrant/kuadrant-operator/pkg/library/utils" ) var NegativePolarityConditions []string -func (r *DNSPolicyReconciler) reconcileStatus(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy, specErr error) (ctrl.Result, error) { +func (r *DNSPolicyReconciler) reconcileStatus(ctx context.Context, dnsPolicy *v1.DNSPolicy, specErr error) (ctrl.Result, error) { newStatus := r.calculateStatus(ctx, dnsPolicy, specErr) equalStatus := equality.Semantic.DeepEqual(newStatus, dnsPolicy.Status) @@ -71,7 +71,7 @@ func (r *DNSPolicyReconciler) reconcileStatus(ctx context.Context, dnsPolicy *v1 return ctrl.Result{}, nil } -func (r *DNSPolicyReconciler) emitConditionMetrics(dnsPolicy *v1alpha1.DNSPolicy) { +func (r *DNSPolicyReconciler) emitConditionMetrics(dnsPolicy *v1.DNSPolicy) { readyStatus := meta.FindStatusCondition(dnsPolicy.Status.Conditions, ReadyConditionType) if readyStatus == nil { dnsPolicyReady.WithLabelValues(dnsPolicy.Name, dnsPolicy.Namespace, "true").Set(0) @@ -88,8 +88,8 @@ func (r *DNSPolicyReconciler) emitConditionMetrics(dnsPolicy *v1alpha1.DNSPolicy } } -func (r *DNSPolicyReconciler) calculateStatus(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy, specErr error) *v1alpha1.DNSPolicyStatus { - newStatus := &v1alpha1.DNSPolicyStatus{ +func (r *DNSPolicyReconciler) calculateStatus(ctx context.Context, dnsPolicy *v1.DNSPolicy, specErr error) *v1.DNSPolicyStatus { + newStatus := &v1.DNSPolicyStatus{ // Copy initial conditions. Otherwise, status will always be updated Conditions: slices.Clone(dnsPolicy.Status.Conditions), ObservedGeneration: dnsPolicy.Status.ObservedGeneration, @@ -131,7 +131,7 @@ func (r *DNSPolicyReconciler) calculateStatus(ctx context.Context, dnsPolicy *v1 return newStatus } -func (r *DNSPolicyReconciler) filteredRecordList(ctx context.Context, dnsPolicy *v1alpha1.DNSPolicy) (*kuadrantdnsv1alpha1.DNSRecordList, error) { +func (r *DNSPolicyReconciler) filteredRecordList(ctx context.Context, dnsPolicy *v1.DNSPolicy) (*kuadrantdnsv1alpha1.DNSRecordList, error) { recordsList := &kuadrantdnsv1alpha1.DNSRecordList{} if err := r.Client().List(ctx, recordsList, &client.ListOptions{Namespace: dnsPolicy.Namespace}); err != nil { return nil, err @@ -148,7 +148,7 @@ func (r *DNSPolicyReconciler) filteredRecordList(ctx context.Context, dnsPolicy return recordsList, nil } -func (r *DNSPolicyReconciler) enforcedCondition(recordsList *kuadrantdnsv1alpha1.DNSRecordList, dnsPolicy *v1alpha1.DNSPolicy) *metav1.Condition { +func (r *DNSPolicyReconciler) enforcedCondition(recordsList *kuadrantdnsv1alpha1.DNSRecordList, dnsPolicy *v1.DNSPolicy) *metav1.Condition { // there are no controlled DNS records present if len(recordsList.Items) == 0 { cond := kuadrant.EnforcedCondition(dnsPolicy, nil, true) @@ -180,7 +180,7 @@ func (r *DNSPolicyReconciler) enforcedCondition(recordsList *kuadrantdnsv1alpha1 return kuadrant.EnforcedCondition(dnsPolicy, nil, true) } -func propagateRecordConditions(records *kuadrantdnsv1alpha1.DNSRecordList, policyStatus *v1alpha1.DNSPolicyStatus) { +func propagateRecordConditions(records *kuadrantdnsv1alpha1.DNSRecordList, policyStatus *v1.DNSPolicyStatus) { //reset conditions policyStatus.RecordConditions = map[string][]metav1.Condition{} diff --git a/controllers/dnspolicy_status_test.go b/controllers/dnspolicy_status_test.go index bdc9d59cc..a0bd93780 100644 --- a/controllers/dnspolicy_status_test.go +++ b/controllers/dnspolicy_status_test.go @@ -12,7 +12,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" ) diff --git a/controllers/state_of_the_world.go b/controllers/state_of_the_world.go index 945216ca9..a4a8c1349 100644 --- a/controllers/state_of_the_world.go +++ b/controllers/state_of_the_world.go @@ -28,7 +28,7 @@ import ( ctrlruntimepredicate "sigs.k8s.io/controller-runtime/pkg/predicate" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1" kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2" kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3" @@ -60,16 +60,16 @@ func NewPolicyMachineryController(manager ctrlruntime.Manager, client *dynamic.D controller.WithPredicates(&ctrlruntimepredicate.TypedGenerationChangedPredicate[*kuadrantv1beta1.Kuadrant]{}), )), controller.WithRunnable("dnspolicy watcher", controller.Watch( - &kuadrantv1alpha1.DNSPolicy{}, - kuadrantv1alpha1.DNSPoliciesResource, + &kuadrantv1.DNSPolicy{}, + kuadrantv1.DNSPoliciesResource, metav1.NamespaceAll, - controller.WithPredicates(&ctrlruntimepredicate.TypedGenerationChangedPredicate[*kuadrantv1alpha1.DNSPolicy]{}), + controller.WithPredicates(&ctrlruntimepredicate.TypedGenerationChangedPredicate[*kuadrantv1.DNSPolicy]{}), )), controller.WithRunnable("tlspolicy watcher", controller.Watch( - &kuadrantv1alpha1.TLSPolicy{}, - kuadrantv1alpha1.TLSPoliciesResource, + &kuadrantv1.TLSPolicy{}, + kuadrantv1.TLSPoliciesResource, metav1.NamespaceAll, - controller.WithPredicates(&ctrlruntimepredicate.TypedGenerationChangedPredicate[*kuadrantv1alpha1.TLSPolicy]{}), + controller.WithPredicates(&ctrlruntimepredicate.TypedGenerationChangedPredicate[*kuadrantv1.TLSPolicy]{}), )), controller.WithRunnable("authpolicy watcher", controller.Watch( &kuadrantv1beta2.AuthPolicy{}, @@ -102,8 +102,8 @@ func NewPolicyMachineryController(manager ctrlruntime.Manager, client *dynamic.D metav1.NamespaceAll, )), controller.WithPolicyKinds( - kuadrantv1alpha1.DNSPolicyGroupKind, - kuadrantv1alpha1.TLSPolicyGroupKind, + kuadrantv1.DNSPolicyGroupKind, + kuadrantv1.TLSPolicyGroupKind, kuadrantv1beta2.AuthPolicyGroupKind, kuadrantv1beta3.RateLimitPolicyGroupKind, ), @@ -319,7 +319,7 @@ func (b *BootOptionsBuilder) Reconciler() controller.ReconcileFunc { func certManagerControllerOpts() []controller.ControllerOption { isCertificateOwnedByTLSPolicy := func(c *certmanagerv1.Certificate) bool { - return isObjectOwnedByGroupKind(c, kuadrantv1alpha1.TLSPolicyGroupKind) + return isObjectOwnedByGroupKind(c, kuadrantv1.TLSPolicyGroupKind) } return []controller.ControllerOption{ diff --git a/controllers/target_status_controller.go b/controllers/target_status_controller.go index 799a73131..c61eb0382 100644 --- a/controllers/target_status_controller.go +++ b/controllers/target_status_controller.go @@ -38,7 +38,7 @@ import ( gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2" kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3" "github.com/kuadrant/kuadrant-operator/pkg/library/fieldindexers" @@ -82,8 +82,8 @@ func (r *TargetStatusReconciler) Reconcile(eventCtx context.Context, req ctrl.Re func (r *TargetStatusReconciler) reconcileResources(ctx context.Context, gw *gatewayapiv1.Gateway) error { policyKinds := map[kuadrantgatewayapi.Policy]client.ObjectList{ &kuadrantv1beta2.AuthPolicy{TypeMeta: ctrl.TypeMeta{Kind: "AuthPolicy"}}: &kuadrantv1beta2.AuthPolicyList{}, - &kuadrantv1alpha1.DNSPolicy{TypeMeta: ctrl.TypeMeta{Kind: "DNSPolicy"}}: &kuadrantv1alpha1.DNSPolicyList{}, - &kuadrantv1alpha1.TLSPolicy{TypeMeta: ctrl.TypeMeta{Kind: "TLSPolicy"}}: &kuadrantv1alpha1.TLSPolicyList{}, + &kuadrantv1.DNSPolicy{TypeMeta: ctrl.TypeMeta{Kind: "DNSPolicy"}}: &kuadrantv1.DNSPolicyList{}, + &kuadrantv1.TLSPolicy{TypeMeta: ctrl.TypeMeta{Kind: "TLSPolicy"}}: &kuadrantv1.TLSPolicyList{}, &kuadrantv1beta3.RateLimitPolicy{TypeMeta: ctrl.TypeMeta{Kind: "RateLimitPolicy"}}: &kuadrantv1beta3.RateLimitPolicyList{}, } @@ -383,7 +383,7 @@ func (r *TargetStatusReconciler) SetupWithManager(mgr ctrl.Manager) error { builder.WithPredicates(policyStatusChangedPredicate), ). Watches( - &kuadrantv1alpha1.DNSPolicy{}, + &kuadrantv1.DNSPolicy{}, handler.EnqueueRequestsFromMapFunc(policyToParentGatewaysEventMapper.Map), builder.WithPredicates(policyStatusChangedPredicate), ). @@ -393,7 +393,7 @@ func (r *TargetStatusReconciler) SetupWithManager(mgr ctrl.Manager) error { builder.WithPredicates(policyStatusChangedPredicate), ). Watches( - &kuadrantv1alpha1.TLSPolicy{}, + &kuadrantv1.TLSPolicy{}, handler.EnqueueRequestsFromMapFunc(policyToParentGatewaysEventMapper.Map), builder.WithPredicates(policyStatusChangedPredicate), ). diff --git a/controllers/test_common.go b/controllers/test_common.go index 43d355ab9..836f04fcd 100644 --- a/controllers/test_common.go +++ b/controllers/test_common.go @@ -51,7 +51,7 @@ import ( limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1" maistraapis "github.com/kuadrant/kuadrant-operator/api/external/maistra" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1" kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2" kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3" @@ -292,7 +292,7 @@ func BootstrapScheme() *runtime.Scheme { sb := runtime.NewSchemeBuilder( scheme.AddToScheme, kuadrantdnsv1alpha1.AddToScheme, - kuadrantv1alpha1.AddToScheme, + kuadrantv1.AddToScheme, kuadrantv1beta1.AddToScheme, kuadrantv1beta2.AddToScheme, kuadrantv1beta3.AddToScheme, diff --git a/controllers/tls_workflow.go b/controllers/tls_workflow.go index 627fa1896..7fb8ae603 100644 --- a/controllers/tls_workflow.go +++ b/controllers/tls_workflow.go @@ -10,7 +10,7 @@ import ( "k8s.io/client-go/dynamic" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" ) const ( @@ -80,7 +80,7 @@ func LinkListenerToCertificateFunc(objs controller.Store) machinery.LinkFunc { func LinkGatewayToIssuerFunc(objs controller.Store) machinery.LinkFunc { gateways := lo.Map(objs.FilterByGroupKind(machinery.GatewayGroupKind), controller.ObjectAs[*gwapiv1.Gateway]) - tlsPolicies := lo.Map(objs.FilterByGroupKind(kuadrantv1alpha1.TLSPolicyGroupKind), controller.ObjectAs[*kuadrantv1alpha1.TLSPolicy]) + tlsPolicies := lo.Map(objs.FilterByGroupKind(kuadrantv1.TLSPolicyGroupKind), controller.ObjectAs[*kuadrantv1.TLSPolicy]) return machinery.LinkFunc{ From: machinery.GatewayGroupKind, @@ -91,7 +91,7 @@ func LinkGatewayToIssuerFunc(objs controller.Store) machinery.LinkFunc { // Policies linked to Issuer // Issuer must be in the same namespace as the policy - linkedPolicies := lo.Filter(tlsPolicies, func(p *kuadrantv1alpha1.TLSPolicy, index int) bool { + linkedPolicies := lo.Filter(tlsPolicies, func(p *kuadrantv1.TLSPolicy, index int) bool { return p.Spec.IssuerRef.Name == issuer.GetName() && p.GetNamespace() == issuer.GetNamespace() && p.Spec.IssuerRef.Kind == certmanagerv1.IssuerKind }) @@ -119,7 +119,7 @@ func LinkGatewayToIssuerFunc(objs controller.Store) machinery.LinkFunc { func LinkGatewayToClusterIssuerFunc(objs controller.Store) machinery.LinkFunc { gateways := lo.Map(objs.FilterByGroupKind(machinery.GatewayGroupKind), controller.ObjectAs[*gwapiv1.Gateway]) - tlsPolicies := lo.Map(objs.FilterByGroupKind(kuadrantv1alpha1.TLSPolicyGroupKind), controller.ObjectAs[*kuadrantv1alpha1.TLSPolicy]) + tlsPolicies := lo.Map(objs.FilterByGroupKind(kuadrantv1.TLSPolicyGroupKind), controller.ObjectAs[*kuadrantv1.TLSPolicy]) return machinery.LinkFunc{ From: machinery.GatewayGroupKind, @@ -129,7 +129,7 @@ func LinkGatewayToClusterIssuerFunc(objs controller.Store) machinery.LinkFunc { clusterIssuer := o.Object.(*certmanagerv1.ClusterIssuer) // Policies linked to ClusterIssuer - linkedPolicies := lo.Filter(tlsPolicies, func(p *kuadrantv1alpha1.TLSPolicy, index int) bool { + linkedPolicies := lo.Filter(tlsPolicies, func(p *kuadrantv1.TLSPolicy, index int) bool { return p.Spec.IssuerRef.Name == clusterIssuer.GetName() && p.Spec.IssuerRef.Kind == certmanagerv1.ClusterIssuerKind }) diff --git a/controllers/tlspolicies_validator.go b/controllers/tlspolicies_validator.go index 368395caf..f9d0fd614 100644 --- a/controllers/tlspolicies_validator.go +++ b/controllers/tlspolicies_validator.go @@ -10,7 +10,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/utils/ptr" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" ) @@ -28,8 +28,8 @@ func (t *ValidateTLSPoliciesValidatorReconciler) Subscription() *controller.Subs return &controller.Subscription{ Events: []controller.ResourceEventMatcher{ {Kind: &machinery.GatewayGroupKind}, - {Kind: &kuadrantv1alpha1.TLSPolicyGroupKind, EventType: ptr.To(controller.CreateEvent)}, - {Kind: &kuadrantv1alpha1.TLSPolicyGroupKind, EventType: ptr.To(controller.UpdateEvent)}, + {Kind: &kuadrantv1.TLSPolicyGroupKind, EventType: ptr.To(controller.CreateEvent)}, + {Kind: &kuadrantv1.TLSPolicyGroupKind, EventType: ptr.To(controller.UpdateEvent)}, {Kind: &CertManagerCertificateKind}, {Kind: &CertManagerIssuerKind}, {Kind: &CertManagerClusterIssuerKind}, @@ -42,8 +42,8 @@ func (t *ValidateTLSPoliciesValidatorReconciler) Validate(ctx context.Context, _ logger := controller.LoggerFromContext(ctx).WithName("ValidateTLSPolicyTask").WithName("Reconcile") // Get all TLS Policies - policies := lo.FilterMap(topology.Policies().Items(), func(item machinery.Policy, index int) (*kuadrantv1alpha1.TLSPolicy, bool) { - p, ok := item.(*kuadrantv1alpha1.TLSPolicy) + policies := lo.FilterMap(topology.Policies().Items(), func(item machinery.Policy, index int) (*kuadrantv1.TLSPolicy, bool) { + p, ok := item.(*kuadrantv1.TLSPolicy) return p, ok }) @@ -64,7 +64,7 @@ func (t *ValidateTLSPoliciesValidatorReconciler) Validate(ctx context.Context, _ // Policies are already linked to their targets, if is target ref length and length of targetables by this policy is the same if len(p.GetTargetRefs()) != len(topology.Targetables().Children(p)) { logger.V(1).Info("tls policy cannot find target ref", "name", p.Name, "namespace", p.Namespace) - isPolicyValidErrorMap[p.GetLocator()] = kuadrant.NewErrTargetNotFound(p.Kind(), p.GetTargetRef(), apierrors.NewNotFound(kuadrantv1alpha1.TLSPoliciesResource.GroupResource(), p.GetName())) + isPolicyValidErrorMap[p.GetLocator()] = kuadrant.NewErrTargetNotFound(p.Kind(), p.GetTargetRef(), apierrors.NewNotFound(kuadrantv1.TLSPoliciesResource.GroupResource(), p.GetName())) continue } diff --git a/controllers/tlspolicy_certmanager.go b/controllers/tlspolicy_certmanager.go index c9cf53ded..9e3e2e939 100644 --- a/controllers/tlspolicy_certmanager.go +++ b/controllers/tlspolicy_certmanager.go @@ -5,13 +5,12 @@ import ( "fmt" certmanv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" - - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" ) // https://cert-manager.io/docs/usage/gateway/#supported-annotations @@ -67,7 +66,7 @@ func validateGatewayListenerBlock(path *field.Path, l gatewayapiv1.Listener, ing // translatePolicy updates the Certificate spec using the TLSPolicy spec // converted from https://github.com/cert-manager/cert-manager/blob/master/pkg/controller/certificate-shim/helper.go#L63 -func translatePolicy(crt *certmanv1.Certificate, tlsPolicy v1alpha1.TLSPolicySpec) { +func translatePolicy(crt *certmanv1.Certificate, tlsPolicy v1.TLSPolicySpec) { if tlsPolicy.CommonName != "" { crt.Spec.CommonName = tlsPolicy.CommonName } @@ -116,7 +115,7 @@ func translatePolicy(crt *certmanv1.Certificate, tlsPolicy v1alpha1.TLSPolicySpe } // validateIssuer validates that the issuer specified exists -func validateIssuer(ctx context.Context, k8sClient client.Client, policy *v1alpha1.TLSPolicy) error { +func validateIssuer(ctx context.Context, k8sClient client.Client, policy *v1.TLSPolicy) error { var issuer client.Object issuerNamespace := "" switch policy.Spec.IssuerRef.Kind { diff --git a/controllers/tlspolicy_certmanager_certificates.go b/controllers/tlspolicy_certmanager_certificates.go index fcce87f80..67929cbb0 100644 --- a/controllers/tlspolicy_certmanager_certificates.go +++ b/controllers/tlspolicy_certmanager_certificates.go @@ -16,11 +16,11 @@ import ( crlog "sigs.k8s.io/controller-runtime/pkg/log" gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" reconcilerutils "github.com/kuadrant/kuadrant-operator/pkg/library/reconcilers" ) -func (r *TLSPolicyReconciler) reconcileCertificates(ctx context.Context, tlsPolicy *v1alpha1.TLSPolicy, gwDiffObj *reconcilerutils.GatewayDiffs) error { +func (r *TLSPolicyReconciler) reconcileCertificates(ctx context.Context, tlsPolicy *v1.TLSPolicy, gwDiffObj *reconcilerutils.GatewayDiffs) error { log := crlog.FromContext(ctx) log.V(3).Info("reconciling certificates") @@ -45,7 +45,7 @@ func (r *TLSPolicyReconciler) reconcileCertificates(ctx context.Context, tlsPoli return nil } -func (r *TLSPolicyReconciler) createOrUpdateGatewayCertificates(ctx context.Context, tlspolicy *v1alpha1.TLSPolicy, expectedCertificates []*certmanv1.Certificate) error { +func (r *TLSPolicyReconciler) createOrUpdateGatewayCertificates(ctx context.Context, tlspolicy *v1.TLSPolicy, expectedCertificates []*certmanv1.Certificate) error { //create or update all expected Certificates for idx := range expectedCertificates { cert := expectedCertificates[idx] @@ -60,11 +60,11 @@ func (r *TLSPolicyReconciler) createOrUpdateGatewayCertificates(ctx context.Cont return nil } -func (r *TLSPolicyReconciler) deleteGatewayCertificates(ctx context.Context, gateway *gatewayapiv1.Gateway, tlsPolicy *v1alpha1.TLSPolicy) error { +func (r *TLSPolicyReconciler) deleteGatewayCertificates(ctx context.Context, gateway *gatewayapiv1.Gateway, tlsPolicy *v1.TLSPolicy) error { return r.deleteCertificatesWithLabels(ctx, commonTLSCertificateLabels(client.ObjectKeyFromObject(gateway), tlsPolicy), tlsPolicy.Namespace) } -func (r *TLSPolicyReconciler) deleteCertificates(ctx context.Context, tlsPolicy *v1alpha1.TLSPolicy) error { +func (r *TLSPolicyReconciler) deleteCertificates(ctx context.Context, tlsPolicy *v1.TLSPolicy) error { return r.deleteCertificatesWithLabels(ctx, policyTLSCertificateLabels(tlsPolicy), tlsPolicy.Namespace) } @@ -83,7 +83,7 @@ func (r *TLSPolicyReconciler) deleteCertificatesWithLabels(ctx context.Context, return nil } -func (r *TLSPolicyReconciler) deleteUnexpectedCertificates(ctx context.Context, expectedCertificates []*certmanv1.Certificate, gateway *gatewayapiv1.Gateway, tlsPolicy *v1alpha1.TLSPolicy) error { +func (r *TLSPolicyReconciler) deleteUnexpectedCertificates(ctx context.Context, expectedCertificates []*certmanv1.Certificate, gateway *gatewayapiv1.Gateway, tlsPolicy *v1.TLSPolicy) error { // remove any certificates for this gateway and TLSPolicy that are no longer expected existingCertificates := &certmanv1.CertificateList{} dnsLabels := commonTLSCertificateLabels(client.ObjectKeyFromObject(gateway), tlsPolicy) @@ -103,7 +103,7 @@ func (r *TLSPolicyReconciler) deleteUnexpectedCertificates(ctx context.Context, return nil } -func expectedCertificatesForGateway(ctx context.Context, gateway *gatewayapiv1.Gateway, tlsPolicy *v1alpha1.TLSPolicy) []*certmanv1.Certificate { +func expectedCertificatesForGateway(ctx context.Context, gateway *gatewayapiv1.Gateway, tlsPolicy *v1.TLSPolicy) []*certmanv1.Certificate { log := crlog.FromContext(ctx) tlsHosts := make(map[corev1.ObjectReference][]string) @@ -136,7 +136,7 @@ func expectedCertificatesForGateway(ctx context.Context, gateway *gatewayapiv1.G return certs } -func expectedCertificatesForListener(l *machinery.Listener, tlsPolicy *v1alpha1.TLSPolicy) []*certmanv1.Certificate { +func expectedCertificatesForListener(l *machinery.Listener, tlsPolicy *v1.TLSPolicy) []*certmanv1.Certificate { tlsHosts := make(map[corev1.ObjectReference][]string) hostname := "*" @@ -165,7 +165,7 @@ func expectedCertificatesForListener(l *machinery.Listener, tlsPolicy *v1alpha1. return certs } -func buildCertManagerCertificate(gateway *gatewayapiv1.Gateway, tlsPolicy *v1alpha1.TLSPolicy, secretRef corev1.ObjectReference, hosts []string) *certmanv1.Certificate { +func buildCertManagerCertificate(gateway *gatewayapiv1.Gateway, tlsPolicy *v1.TLSPolicy, secretRef corev1.ObjectReference, hosts []string) *certmanv1.Certificate { tlsCertLabels := commonTLSCertificateLabels(client.ObjectKeyFromObject(gateway), tlsPolicy) crt := &certmanv1.Certificate{ @@ -188,7 +188,7 @@ func buildCertManagerCertificate(gateway *gatewayapiv1.Gateway, tlsPolicy *v1alp return crt } -func commonTLSCertificateLabels(gwKey client.ObjectKey, p *v1alpha1.TLSPolicy) map[string]string { +func commonTLSCertificateLabels(gwKey client.ObjectKey, p *v1.TLSPolicy) map[string]string { common := map[string]string{} for k, v := range policyTLSCertificateLabels(p) { common[k] = v @@ -199,7 +199,7 @@ func commonTLSCertificateLabels(gwKey client.ObjectKey, p *v1alpha1.TLSPolicy) m return common } -func policyTLSCertificateLabels(p *v1alpha1.TLSPolicy) map[string]string { +func policyTLSCertificateLabels(p *v1.TLSPolicy) map[string]string { return map[string]string{ p.DirectReferenceAnnotationName(): p.Name, fmt.Sprintf("%s-namespace", p.DirectReferenceAnnotationName()): p.Namespace, diff --git a/controllers/tlspolicy_controller.go b/controllers/tlspolicy_controller.go index 723d0e263..53d185d4f 100644 --- a/controllers/tlspolicy_controller.go +++ b/controllers/tlspolicy_controller.go @@ -30,7 +30,7 @@ import ( crlog "sigs.k8s.io/controller-runtime/pkg/log" gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" - "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + v1 "github.com/kuadrant/kuadrant-operator/api/v1" kuadrantgatewayapi "github.com/kuadrant/kuadrant-operator/pkg/library/gatewayapi" "github.com/kuadrant/kuadrant-operator/pkg/library/mappers" "github.com/kuadrant/kuadrant-operator/pkg/library/reconcilers" @@ -58,7 +58,7 @@ func (r *TLSPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( log.Info("Reconciling TLSPolicy") ctx = crlog.IntoContext(ctx, log) - previous := &v1alpha1.TLSPolicy{} + previous := &v1.TLSPolicy{} if err := r.Client().Get(ctx, req.NamespacedName, previous); err != nil { if err := client.IgnoreNotFound(err); err == nil { return ctrl.Result{}, nil @@ -112,7 +112,7 @@ func (r *TLSPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return ctrl.Result{}, specErr } -func (r *TLSPolicyReconciler) reconcileResources(ctx context.Context, tlsPolicy *v1alpha1.TLSPolicy, targetNetworkObject client.Object) error { +func (r *TLSPolicyReconciler) reconcileResources(ctx context.Context, tlsPolicy *v1.TLSPolicy, targetNetworkObject client.Object) error { err := validateIssuer(ctx, r.Client(), tlsPolicy) if err != nil { return err @@ -141,7 +141,7 @@ func (r *TLSPolicyReconciler) reconcileResources(ctx context.Context, tlsPolicy return nil } -func (r *TLSPolicyReconciler) deleteResources(ctx context.Context, tlsPolicy *v1alpha1.TLSPolicy, targetNetworkObject client.Object) error { +func (r *TLSPolicyReconciler) deleteResources(ctx context.Context, tlsPolicy *v1.TLSPolicy, targetNetworkObject client.Object) error { // delete based on gateway diffs gatewayDiffObj, err := reconcilers.ComputeGatewayDiffs(ctx, r.Client(), tlsPolicy, targetNetworkObject) if err != nil { @@ -184,13 +184,13 @@ func (r *TLSPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { } gatewayEventMapper := mappers.NewGatewayEventMapper( - v1alpha1.NewTLSPolicyType(), + v1.NewTLSPolicyType(), mappers.WithLogger(r.Logger().WithName("gateway.mapper")), mappers.WithClient(mgr.GetClient()), ) return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.TLSPolicy{}). + For(&v1.TLSPolicy{}). Owns(&certmanagerv1.Certificate{}). Watches(&gatewayapiv1.Gateway{}, handler.EnqueueRequestsFromMapFunc(gatewayEventMapper.Map)). Complete(r) diff --git a/controllers/tlspolicy_status_updater.go b/controllers/tlspolicy_status_updater.go index 98c1c6d1d..280c0113c 100644 --- a/controllers/tlspolicy_status_updater.go +++ b/controllers/tlspolicy_status_updater.go @@ -19,7 +19,7 @@ import ( "k8s.io/utils/ptr" gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" "github.com/kuadrant/kuadrant-operator/pkg/library/utils" ) @@ -36,8 +36,8 @@ func (t *TLSPolicyStatusUpdaterReconciler) Subscription() *controller.Subscripti return &controller.Subscription{ Events: []controller.ResourceEventMatcher{ {Kind: &machinery.GatewayGroupKind}, - {Kind: &kuadrantv1alpha1.TLSPolicyGroupKind, EventType: ptr.To(controller.CreateEvent)}, - {Kind: &kuadrantv1alpha1.TLSPolicyGroupKind, EventType: ptr.To(controller.UpdateEvent)}, + {Kind: &kuadrantv1.TLSPolicyGroupKind, EventType: ptr.To(controller.CreateEvent)}, + {Kind: &kuadrantv1.TLSPolicyGroupKind, EventType: ptr.To(controller.UpdateEvent)}, {Kind: &CertManagerCertificateKind}, {Kind: &CertManagerIssuerKind}, {Kind: &CertManagerClusterIssuerKind}, @@ -49,8 +49,8 @@ func (t *TLSPolicyStatusUpdaterReconciler) Subscription() *controller.Subscripti func (t *TLSPolicyStatusUpdaterReconciler) UpdateStatus(ctx context.Context, _ []controller.ResourceEvent, topology *machinery.Topology, _ error, s *sync.Map) error { logger := controller.LoggerFromContext(ctx).WithName("TLSPolicyStatusUpdaterReconciler").WithName("Reconcile") - policies := lo.FilterMap(topology.Policies().Items(), func(item machinery.Policy, index int) (*kuadrantv1alpha1.TLSPolicy, bool) { - p, ok := item.(*kuadrantv1alpha1.TLSPolicy) + policies := lo.FilterMap(topology.Policies().Items(), func(item machinery.Policy, index int) (*kuadrantv1.TLSPolicy, bool) { + p, ok := item.(*kuadrantv1.TLSPolicy) return p, ok }) @@ -68,7 +68,7 @@ func (t *TLSPolicyStatusUpdaterReconciler) UpdateStatus(ctx context.Context, _ [ continue } - newStatus := &kuadrantv1alpha1.TLSPolicyStatus{ + newStatus := &kuadrantv1.TLSPolicyStatus{ // Copy initial conditions. Otherwise, status will always be updated Conditions: slices.Clone(policy.Status.Conditions), ObservedGeneration: policy.Status.ObservedGeneration, @@ -94,7 +94,7 @@ func (t *TLSPolicyStatusUpdaterReconciler) UpdateStatus(ctx context.Context, _ [ newStatus.ObservedGeneration = policy.Generation policy.Status = *newStatus - resource := t.Client.Resource(kuadrantv1alpha1.TLSPoliciesResource).Namespace(policy.GetNamespace()) + resource := t.Client.Resource(kuadrantv1.TLSPoliciesResource).Namespace(policy.GetNamespace()) un, err := controller.Destruct(policy) if err != nil { logger.Error(err, "unable to destruct policy") @@ -110,7 +110,7 @@ func (t *TLSPolicyStatusUpdaterReconciler) UpdateStatus(ctx context.Context, _ [ return nil } -func (t *TLSPolicyStatusUpdaterReconciler) enforcedCondition(ctx context.Context, tlsPolicy *kuadrantv1alpha1.TLSPolicy, topology *machinery.Topology) *metav1.Condition { +func (t *TLSPolicyStatusUpdaterReconciler) enforcedCondition(ctx context.Context, tlsPolicy *kuadrantv1.TLSPolicy, topology *machinery.Topology) *metav1.Condition { if err := t.isIssuerReady(ctx, tlsPolicy, topology); err != nil { return kuadrant.EnforcedCondition(tlsPolicy, kuadrant.NewErrUnknown(tlsPolicy.Kind(), err), false) } @@ -122,7 +122,7 @@ func (t *TLSPolicyStatusUpdaterReconciler) enforcedCondition(ctx context.Context return kuadrant.EnforcedCondition(tlsPolicy, nil, true) } -func (t *TLSPolicyStatusUpdaterReconciler) isIssuerReady(ctx context.Context, tlsPolicy *kuadrantv1alpha1.TLSPolicy, topology *machinery.Topology) error { +func (t *TLSPolicyStatusUpdaterReconciler) isIssuerReady(ctx context.Context, tlsPolicy *kuadrantv1.TLSPolicy, topology *machinery.Topology) error { logger := controller.LoggerFromContext(ctx).WithName("TLSPolicyStatusUpdaterReconciler").WithName("isIssuerReady") // Get all gateways @@ -189,7 +189,7 @@ func (t *TLSPolicyStatusUpdaterReconciler) isIssuerReady(ctx context.Context, tl } func (t *TLSPolicyStatusUpdaterReconciler) isCertificatesReady(p machinery.Policy, topology *machinery.Topology) error { - tlsPolicy, ok := p.(*kuadrantv1alpha1.TLSPolicy) + tlsPolicy, ok := p.(*kuadrantv1.TLSPolicy) if !ok { return errors.New("invalid policy") } diff --git a/controllers/tlspolicy_status_updater_test.go b/controllers/tlspolicy_status_updater_test.go index f43199e21..af79f7c34 100644 --- a/controllers/tlspolicy_status_updater_test.go +++ b/controllers/tlspolicy_status_updater_test.go @@ -19,7 +19,7 @@ import ( gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - kuadrantv1alpha1 "github.com/kuadrant/kuadrant-operator/api/v1alpha1" + kuadrantv1 "github.com/kuadrant/kuadrant-operator/api/v1" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" ) @@ -32,8 +32,8 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { gwName = "kuadrant-gateway" ) - policyFactory := func(mutateFn ...func(policy *kuadrantv1alpha1.TLSPolicy)) *kuadrantv1alpha1.TLSPolicy { - p := &kuadrantv1alpha1.TLSPolicy{ + policyFactory := func(mutateFn ...func(policy *kuadrantv1.TLSPolicy)) *kuadrantv1.TLSPolicy { + p := &kuadrantv1.TLSPolicy{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns, Name: tlsPolicyName, @@ -41,10 +41,10 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { }, TypeMeta: metav1.TypeMeta{ Kind: "TLSPolicy", - APIVersion: kuadrantv1alpha1.GroupVersion.String(), + APIVersion: kuadrantv1.GroupVersion.String(), }, - Spec: kuadrantv1alpha1.TLSPolicySpec{ - CertificateSpec: kuadrantv1alpha1.CertificateSpec{ + Spec: kuadrantv1.TLSPolicySpec{ + CertificateSpec: kuadrantv1.CertificateSpec{ IssuerRef: certmanmetav1.ObjectReference{ Name: issuerName, Kind: certmanv1.IssuerKind, @@ -64,7 +64,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { return p } - withClusterIssuerMutater := func(p *kuadrantv1alpha1.TLSPolicy) { + withClusterIssuerMutater := func(p *kuadrantv1.TLSPolicy) { p.Spec.CertificateSpec.IssuerRef.Kind = certmanv1.ClusterIssuerKind } @@ -212,7 +212,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { } } - topologyOpts := func(policy *kuadrantv1alpha1.TLSPolicy, additionalOps ...machinery.GatewayAPITopologyOptionsFunc) []machinery.GatewayAPITopologyOptionsFunc { + topologyOpts := func(policy *kuadrantv1.TLSPolicy, additionalOps ...machinery.GatewayAPITopologyOptionsFunc) []machinery.GatewayAPITopologyOptionsFunc { store := make(controller.Store) gw := gwFactory() store[string(gw.UID)] = gw @@ -234,8 +234,8 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { } type args struct { - tlsPolicy *kuadrantv1alpha1.TLSPolicy - topology func(*kuadrantv1alpha1.TLSPolicy) *machinery.Topology + tlsPolicy *kuadrantv1.TLSPolicy + topology func(*kuadrantv1.TLSPolicy) *machinery.Topology } tests := []struct { name string @@ -246,7 +246,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "unable to get issuer", args: args{ tlsPolicy: policyFactory(), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { topology, _ := machinery.NewGatewayAPITopology( topologyOpts(p)..., ) @@ -264,7 +264,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "unable to get cluster issuer", args: args{ tlsPolicy: policyFactory(withClusterIssuerMutater), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { topology, _ := machinery.NewGatewayAPITopology( topologyOpts(p)..., ) @@ -282,7 +282,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "issuer not ready", args: args{ tlsPolicy: policyFactory(), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(p, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory(issuerNotReadyMutater)}, )) @@ -301,7 +301,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "issuer has no ready condition", args: args{ tlsPolicy: policyFactory(), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(p, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory(func(issuer *certmanv1.Issuer) { issuer.Status.Conditions = []certmanv1.IssuerCondition{} @@ -322,7 +322,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "cluster issuer not ready", args: args{ tlsPolicy: policyFactory(withClusterIssuerMutater), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(p, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: clusterIssuerFactory(clusterIssuerNotReadyMutater)}, )) @@ -341,7 +341,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "cluster issuer has no ready condition", args: args{ tlsPolicy: policyFactory(withClusterIssuerMutater), - topology: func(p *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(p *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(p, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: clusterIssuerFactory(func(issuer *certmanv1.ClusterIssuer) { issuer.Status.Conditions = []certmanv1.IssuerCondition{} @@ -362,7 +362,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "no valid gateways found", args: args{ tlsPolicy: policyFactory(), - topology: func(_ *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(_ *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(policyFactory(), machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory()}, )) @@ -381,7 +381,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "unable to get certificate", args: args{ tlsPolicy: policyFactory(), - topology: func(policy *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(policy *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(policy, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory()}, )) @@ -400,7 +400,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "certificate is not ready", args: args{ tlsPolicy: policyFactory(), - topology: func(policy *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(policy *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(policy, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory()}, &controller.RuntimeObject{Object: certificateFactory(certificateNotReadyMutater)}, @@ -420,7 +420,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "certificate has no ready condition", args: args{ tlsPolicy: policyFactory(), - topology: func(policy *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(policy *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(policy, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory()}, &controller.RuntimeObject{Object: certificateFactory(func(certificate *certmanv1.Certificate) { @@ -442,7 +442,7 @@ func TestTLSPolicyStatusTask_enforcedCondition(t *testing.T) { name: "is enforced", args: args{ tlsPolicy: policyFactory(), - topology: func(policy *kuadrantv1alpha1.TLSPolicy) *machinery.Topology { + topology: func(policy *kuadrantv1.TLSPolicy) *machinery.Topology { opts := topologyOpts(policy, machinery.WithGatewayAPITopologyObjects( &controller.RuntimeObject{Object: issuerFactory()}, &controller.RuntimeObject{Object: certificateFactory()}, diff --git a/doc/dns.md b/doc/dns.md index d784cb524..bb60c7a4a 100644 --- a/doc/dns.md +++ b/doc/dns.md @@ -22,7 +22,7 @@ The `DNSPolicy` spec includes the following parts: #### High-level example and field definition ```yaml -apiVersion: kuadrant.io/v1alpha1 +apiVersion: kuadrant.io/v1 kind: DNSPolicy metadata: name: my-dns-policy @@ -162,7 +162,7 @@ When a DNSPolicy targets a Gateway, the policy will be enforced on all gateway l Target a Gateway by setting the `spec.targetRef` field of the DNSPolicy as follows: ```yaml -apiVersion: kuadrant.io/v1beta2 +apiVersion: kuadrant.io/v1 kind: DNSPolicy metadata: name: diff --git a/doc/dnshealthchecks.md b/doc/dnshealthchecks.md index 48141c461..6d490aa74 100644 --- a/doc/dnshealthchecks.md +++ b/doc/dnshealthchecks.md @@ -15,7 +15,7 @@ To configure a DNS health check, you need to specify the `healthCheck` section o * `FailureThreshold`: How many times we can tolerate a failure on this endpoint, before removing the related DNS entry. ```bash -apiVersion: kuadrant.io/v1alpha1 +apiVersion: kuadrant.io/v1 kind: DNSPolicy metadata: name: prod-web diff --git a/doc/user-guides/dns-excluding-specific-addresses.md b/doc/user-guides/dns-excluding-specific-addresses.md index 6fe2b91c1..1e2d6597b 100644 --- a/doc/user-guides/dns-excluding-specific-addresses.md +++ b/doc/user-guides/dns-excluding-specific-addresses.md @@ -9,7 +9,7 @@ To prevent a gateway address being published to the DNS provider, you can set th Below is an example of a DNSPolicy excluding a hostname: ``` -apiVersion: kuadrant.io/v1alpha1 +apiVersion: kuadrant.io/v1 kind: DNSPolicy metadata: name: prod-web diff --git a/doc/user-guides/gateway-dns.md b/doc/user-guides/gateway-dns.md index c4f592595..078cffee2 100644 --- a/doc/user-guides/gateway-dns.md +++ b/doc/user-guides/gateway-dns.md @@ -89,7 +89,7 @@ prod-web istio 172.18.200.1 True 25s Create a Kuadrant `DNSPolicy` to configure DNS: ```shell kubectl -n my-gateways apply -f - <