From d0e6a9075e3846ca134b137e0065aa94b62d2897 Mon Sep 17 00:00:00 2001 From: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> Date: Fri, 23 May 2025 17:16:37 +0200 Subject: [PATCH] chore(crd): move code to `apis/v1alpha1` (#5446) * chore(crd): move code to `api/v1alpha1` * fix license check * fix linter * remove obsolete exclusion on linter --- .golangci.yml | 1 - Makefile | 3 +- apis/api.go | 17 ++++ apis/v1alpha1/api.go | 20 ++++ apis/v1alpha1/dnsendpoint.go | 62 ++++++++++++ apis/v1alpha1/groupversion_info.go | 40 ++++++++ apis/v1alpha1/zz_generated.deepcopy.go | 110 ++++++++++++++++++++++ charts/external-dns/crds/dnsendpoint.yaml | 3 + config/crd/standard/dnsendpoint.yaml | 3 + endpoint/endpoint.go | 46 +-------- endpoint/zz_generated.deepcopy.go | 89 ----------------- source/crd.go | 24 ++--- source/crd_test.go | 10 +- 13 files changed, 275 insertions(+), 153 deletions(-) create mode 100644 apis/api.go create mode 100644 apis/v1alpha1/api.go create mode 100644 apis/v1alpha1/dnsendpoint.go create mode 100644 apis/v1alpha1/groupversion_info.go create mode 100644 apis/v1alpha1/zz_generated.deepcopy.go diff --git a/.golangci.yml b/.golangci.yml index b7498ef48..e96def4ef 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -95,7 +95,6 @@ formatters: exclusions: generated: lax paths: - - endpoint/zz_generated.deepcopy.go - third_party$ - builtin$ - examples$ diff --git a/Makefile b/Makefile index c0c15cd2f..0ec5f712d 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,8 @@ lint: licensecheck go-lint oas-lint #? crd: Generates CRD using controller-gen and copy it into chart .PHONY: crd crd: controller-gen-install - ${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > config/crd/standard/dnsendpoint.yaml + ${CONTROLLER_GEN} object crd:crdVersions=v1 paths="./endpoint/..." + ${CONTROLLER_GEN} object crd:crdVersions=v1 paths="./apis/..." output:crd:stdout > config/crd/standard/dnsendpoint.yaml cp -f config/crd/standard/dnsendpoint.yaml charts/external-dns/crds/dnsendpoint.yaml #? test: The verify target runs tasks similar to the CI tasks, but without code coverage diff --git a/apis/api.go b/apis/api.go new file mode 100644 index 000000000..a037bf3f3 --- /dev/null +++ b/apis/api.go @@ -0,0 +1,17 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apis diff --git a/apis/v1alpha1/api.go b/apis/v1alpha1/api.go new file mode 100644 index 000000000..127a77368 --- /dev/null +++ b/apis/v1alpha1/api.go @@ -0,0 +1,20 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the externaldns.k8s.io v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=externaldns.k8s.io +package v1alpha1 diff --git a/apis/v1alpha1/dnsendpoint.go b/apis/v1alpha1/dnsendpoint.go new file mode 100644 index 000000000..522bd1bee --- /dev/null +++ b/apis/v1alpha1/dnsendpoint.go @@ -0,0 +1,62 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "sigs.k8s.io/external-dns/endpoint" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DNSEndpoint is a contract that a user-specified CRD must implement to be used as a source for external-dns. +// The user-specified CRD should also have the status sub-resource. +// +k8s:openapi-gen=true +// +groupName=externaldns.k8s.io +// +kubebuilder:resource:path=dnsendpoints +// +kubebuilder:subresource:status +// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/external-dns/pull/2007" +// +versionName=v1alpha1 +type DNSEndpoint struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec DNSEndpointSpec `json:"spec,omitempty"` + Status DNSEndpointStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// DNSEndpointList is a list of DNSEndpoint objects +type DNSEndpointList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DNSEndpoint `json:"items"` +} + +// DNSEndpointSpec defines the desired state of DNSEndpoint +type DNSEndpointSpec struct { + Endpoints []*endpoint.Endpoint `json:"endpoints,omitempty"` +} + +// DNSEndpointStatus defines the observed state of DNSEndpoint +type DNSEndpointStatus struct { + // The generation observed by the external-dns controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} diff --git a/apis/v1alpha1/groupversion_info.go b/apis/v1alpha1/groupversion_info.go new file mode 100644 index 000000000..926c4bc92 --- /dev/null +++ b/apis/v1alpha1/groupversion_info.go @@ -0,0 +1,40 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the externaldns.k8s.io v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=externaldns.k8s.io +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "externaldns.k8s.io", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +func init() { + SchemeBuilder.Register(&DNSEndpoint{}, &DNSEndpointList{}) +} diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..e2f5bf1b8 --- /dev/null +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,110 @@ +//go:build !ignore_autogenerated + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/external-dns/endpoint" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DNSEndpoint) DeepCopyInto(out *DNSEndpoint) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpoint. +func (in *DNSEndpoint) DeepCopy() *DNSEndpoint { + if in == nil { + return nil + } + out := new(DNSEndpoint) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DNSEndpoint) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DNSEndpoint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointList. +func (in *DNSEndpointList) DeepCopy() *DNSEndpointList { + if in == nil { + return nil + } + out := new(DNSEndpointList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DNSEndpointList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DNSEndpointSpec) DeepCopyInto(out *DNSEndpointSpec) { + *out = *in + if in.Endpoints != nil { + in, out := &in.Endpoints, &out.Endpoints + *out = make([]*endpoint.Endpoint, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(endpoint.Endpoint) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointSpec. +func (in *DNSEndpointSpec) DeepCopy() *DNSEndpointSpec { + if in == nil { + return nil + } + out := new(DNSEndpointSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DNSEndpointStatus) DeepCopyInto(out *DNSEndpointStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointStatus. +func (in *DNSEndpointStatus) DeepCopy() *DNSEndpointStatus { + if in == nil { + return nil + } + out := new(DNSEndpointStatus) + in.DeepCopyInto(out) + return out +} diff --git a/charts/external-dns/crds/dnsendpoint.yaml b/charts/external-dns/crds/dnsendpoint.yaml index 88845aaae..83388d451 100644 --- a/charts/external-dns/crds/dnsendpoint.yaml +++ b/charts/external-dns/crds/dnsendpoint.yaml @@ -18,6 +18,9 @@ spec: - name: v1alpha1 schema: openAPIV3Schema: + description: |- + DNSEndpoint is a contract that a user-specified CRD must implement to be used as a source for external-dns. + The user-specified CRD should also have the status sub-resource. properties: apiVersion: description: |- diff --git a/config/crd/standard/dnsendpoint.yaml b/config/crd/standard/dnsendpoint.yaml index 88845aaae..83388d451 100644 --- a/config/crd/standard/dnsendpoint.yaml +++ b/config/crd/standard/dnsendpoint.yaml @@ -18,6 +18,9 @@ spec: - name: v1alpha1 schema: openAPIV3Schema: + description: |- + DNSEndpoint is a contract that a user-specified CRD must implement to be used as a source for external-dns. + The user-specified CRD should also have the status sub-resource. properties: apiVersion: description: |- diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index bbf67f641..86034fed6 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -24,8 +24,6 @@ import ( "strings" log "github.com/sirupsen/logrus" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -337,48 +335,6 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { return filtered } -// DNSEndpointSpec defines the desired state of DNSEndpoint -// +kubebuilder:object:generate=true -type DNSEndpointSpec struct { - Endpoints []*Endpoint `json:"endpoints,omitempty"` -} - -// DNSEndpointStatus defines the observed state of DNSEndpoint -type DNSEndpointStatus struct { - // The generation observed by the external-dns controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// DNSEndpoint is a contract that a user-specified CRD must implement to be used as a source for external-dns. -// The user-specified CRD should also have the status sub-resource. -// +k8s:openapi-gen=true -// +groupName=externaldns.k8s.io -// +kubebuilder:resource:path=dnsendpoints -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:metadata:annotations="api-approved.kubernetes.io=https://github.com/kubernetes-sigs/external-dns/pull/2007" -// +versionName=v1alpha1 - -type DNSEndpoint struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DNSEndpointSpec `json:"spec,omitempty"` - Status DNSEndpointStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true -// DNSEndpointList is a list of DNSEndpoint objects -type DNSEndpointList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []DNSEndpoint `json:"items"` -} - // RemoveDuplicates returns a slice holding the unique endpoints. // This function doesn't contemplate the Targets of an Endpoint // as part of the primary Key @@ -400,7 +356,7 @@ func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint { return result } -// Check endpoint if is it properly formatted according to RFC standards +// CheckEndpoint Check if endpoint is properly formatted according to RFC standards func (e *Endpoint) CheckEndpoint() bool { switch recordType := e.RecordType; recordType { case RecordTypeMX: diff --git a/endpoint/zz_generated.deepcopy.go b/endpoint/zz_generated.deepcopy.go index ec07dace1..e86498d37 100644 --- a/endpoint/zz_generated.deepcopy.go +++ b/endpoint/zz_generated.deepcopy.go @@ -4,95 +4,6 @@ package endpoint -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSEndpoint) DeepCopyInto(out *DNSEndpoint) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpoint. -func (in *DNSEndpoint) DeepCopy() *DNSEndpoint { - if in == nil { - return nil - } - out := new(DNSEndpoint) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DNSEndpoint) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]DNSEndpoint, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointList. -func (in *DNSEndpointList) DeepCopy() *DNSEndpointList { - if in == nil { - return nil - } - out := new(DNSEndpointList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DNSEndpointList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSEndpointSpec) DeepCopyInto(out *DNSEndpointSpec) { - *out = *in - if in.Endpoints != nil { - in, out := &in.Endpoints, &out.Endpoints - *out = make([]*Endpoint, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(Endpoint) - (*in).DeepCopyInto(*out) - } - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointSpec. -func (in *DNSEndpointSpec) DeepCopy() *DNSEndpointSpec { - if in == nil { - return nil - } - out := new(DNSEndpointSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Endpoint) DeepCopyInto(out *Endpoint) { *out = *in diff --git a/source/crd.go b/source/crd.go index d62805162..a603964dd 100644 --- a/source/crd.go +++ b/source/crd.go @@ -36,6 +36,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + apiv1alpha1 "sigs.k8s.io/external-dns/apis/v1alpha1" "sigs.k8s.io/external-dns/endpoint" ) @@ -53,8 +54,8 @@ type crdSource struct { func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error { scheme.AddKnownTypes(groupVersion, - &endpoint.DNSEndpoint{}, - &endpoint.DNSEndpointList{}, + &apiv1alpha1.DNSEndpoint{}, + &apiv1alpha1.DNSEndpointList{}, ) metav1.AddToGroupVersion(scheme, groupVersion) return nil @@ -129,7 +130,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi return sourceCrd.watch(context.TODO(), &lo) }, }, - &endpoint.DNSEndpoint{}, + &apiv1alpha1.DNSEndpoint{}, 0) sourceCrd.informer = &informer go informer.Run(wait.NeverStop) @@ -164,7 +165,7 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error endpoints := []*endpoint.Endpoint{} var ( - result *endpoint.DNSEndpointList + result *apiv1alpha1.DNSEndpointList err error ) @@ -174,7 +175,6 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error } result, err = cs.filterByAnnotations(result) - if err != nil { return nil, err } @@ -229,7 +229,7 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error return endpoints, nil } -func (cs *crdSource) setResourceLabel(crd *endpoint.DNSEndpoint, endpoints []*endpoint.Endpoint) { +func (cs *crdSource) setResourceLabel(crd *apiv1alpha1.DNSEndpoint, endpoints []*endpoint.Endpoint) { for _, ep := range endpoints { ep.Labels[endpoint.ResourceLabelKey] = fmt.Sprintf("crd/%s/%s", crd.Namespace, crd.Name) } @@ -244,8 +244,8 @@ func (cs *crdSource) watch(ctx context.Context, opts *metav1.ListOptions) (watch Watch(ctx) } -func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result *endpoint.DNSEndpointList, err error) { - result = &endpoint.DNSEndpointList{} +func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result *apiv1alpha1.DNSEndpointList, err error) { + result = &apiv1alpha1.DNSEndpointList{} err = cs.crdClient.Get(). Namespace(cs.namespace). Resource(cs.crdResource). @@ -255,8 +255,8 @@ func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result return } -func (cs *crdSource) UpdateStatus(ctx context.Context, dnsEndpoint *endpoint.DNSEndpoint) (result *endpoint.DNSEndpoint, err error) { - result = &endpoint.DNSEndpoint{} +func (cs *crdSource) UpdateStatus(ctx context.Context, dnsEndpoint *apiv1alpha1.DNSEndpoint) (result *apiv1alpha1.DNSEndpoint, err error) { + result = &apiv1alpha1.DNSEndpoint{} err = cs.crdClient.Put(). Namespace(dnsEndpoint.Namespace). Resource(cs.crdResource). @@ -269,7 +269,7 @@ func (cs *crdSource) UpdateStatus(ctx context.Context, dnsEndpoint *endpoint.DNS } // filterByAnnotations filters a list of dnsendpoints by a given annotation selector. -func (cs *crdSource) filterByAnnotations(dnsendpoints *endpoint.DNSEndpointList) (*endpoint.DNSEndpointList, error) { +func (cs *crdSource) filterByAnnotations(dnsendpoints *apiv1alpha1.DNSEndpointList) (*apiv1alpha1.DNSEndpointList, error) { labelSelector, err := metav1.ParseToLabelSelector(cs.annotationFilter) if err != nil { return nil, err @@ -284,7 +284,7 @@ func (cs *crdSource) filterByAnnotations(dnsendpoints *endpoint.DNSEndpointList) return dnsendpoints, nil } - filteredList := endpoint.DNSEndpointList{} + filteredList := apiv1alpha1.DNSEndpointList{} for _, dnsendpoint := range dnsendpoints.Items { // include dnsendpoint if its annotations match the selector diff --git a/source/crd_test.go b/source/crd_test.go index 53d8b322c..8386c6428 100644 --- a/source/crd_test.go +++ b/source/crd_test.go @@ -36,6 +36,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/rest/fake" + apiv1alpha1 "sigs.k8s.io/external-dns/apis/v1alpha1" "sigs.k8s.io/external-dns/endpoint" ) @@ -61,8 +62,8 @@ func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace, scheme := runtime.NewScheme() addKnownTypes(scheme, groupVersion) - dnsEndpointList := endpoint.DNSEndpointList{} - dnsEndpoint := &endpoint.DNSEndpoint{ + dnsEndpointList := apiv1alpha1.DNSEndpointList{} + dnsEndpoint := &apiv1alpha1.DNSEndpoint{ TypeMeta: metav1.TypeMeta{ APIVersion: apiVersion, Kind: kind, @@ -74,7 +75,7 @@ func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace, Labels: labels, Generation: 1, }, - Spec: endpoint.DNSEndpointSpec{ + Spec: apiv1alpha1.DNSEndpointSpec{ Endpoints: endpoints, }, } @@ -101,7 +102,7 @@ func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace, case p == "/apis/"+apiVersion+"/namespaces/"+namespace+"/"+strings.ToLower(kind)+"s/"+name+"/status" && m == http.MethodPut: decoder := json.NewDecoder(req.Body) - var body endpoint.DNSEndpoint + var body apiv1alpha1.DNSEndpoint decoder.Decode(&body) dnsEndpoint.Status.ObservedGeneration = body.Status.ObservedGeneration return &http.Response{StatusCode: http.StatusOK, Header: defaultHeader(), Body: objBody(codec, dnsEndpoint)}, nil @@ -468,7 +469,6 @@ func testCRDSourceEndpoints(t *testing.T) { expectError: false, }, } { - t.Run(ti.title, func(t *testing.T) { t.Parallel()