mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
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
This commit is contained in:
parent
d4013c22e2
commit
d0e6a9075e
@ -95,7 +95,6 @@ formatters:
|
|||||||
exclusions:
|
exclusions:
|
||||||
generated: lax
|
generated: lax
|
||||||
paths:
|
paths:
|
||||||
- endpoint/zz_generated.deepcopy.go
|
|
||||||
- third_party$
|
- third_party$
|
||||||
- builtin$
|
- builtin$
|
||||||
- examples$
|
- examples$
|
||||||
|
3
Makefile
3
Makefile
@ -66,7 +66,8 @@ lint: licensecheck go-lint oas-lint
|
|||||||
#? crd: Generates CRD using controller-gen and copy it into chart
|
#? crd: Generates CRD using controller-gen and copy it into chart
|
||||||
.PHONY: crd
|
.PHONY: crd
|
||||||
crd: controller-gen-install
|
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
|
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
|
#? test: The verify target runs tasks similar to the CI tasks, but without code coverage
|
||||||
|
17
apis/api.go
Normal file
17
apis/api.go
Normal file
@ -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
|
20
apis/v1alpha1/api.go
Normal file
20
apis/v1alpha1/api.go
Normal file
@ -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
|
62
apis/v1alpha1/dnsendpoint.go
Normal file
62
apis/v1alpha1/dnsendpoint.go
Normal file
@ -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"`
|
||||||
|
}
|
40
apis/v1alpha1/groupversion_info.go
Normal file
40
apis/v1alpha1/groupversion_info.go
Normal file
@ -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{})
|
||||||
|
}
|
110
apis/v1alpha1/zz_generated.deepcopy.go
Normal file
110
apis/v1alpha1/zz_generated.deepcopy.go
Normal file
@ -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
|
||||||
|
}
|
@ -18,6 +18,9 @@ spec:
|
|||||||
- name: v1alpha1
|
- name: v1alpha1
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
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:
|
properties:
|
||||||
apiVersion:
|
apiVersion:
|
||||||
description: |-
|
description: |-
|
||||||
|
@ -18,6 +18,9 @@ spec:
|
|||||||
- name: v1alpha1
|
- name: v1alpha1
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
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:
|
properties:
|
||||||
apiVersion:
|
apiVersion:
|
||||||
description: |-
|
description: |-
|
||||||
|
@ -24,8 +24,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -337,48 +335,6 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint {
|
|||||||
return filtered
|
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.
|
// RemoveDuplicates returns a slice holding the unique endpoints.
|
||||||
// This function doesn't contemplate the Targets of an Endpoint
|
// This function doesn't contemplate the Targets of an Endpoint
|
||||||
// as part of the primary Key
|
// as part of the primary Key
|
||||||
@ -400,7 +356,7 @@ func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint {
|
|||||||
return result
|
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 {
|
func (e *Endpoint) CheckEndpoint() bool {
|
||||||
switch recordType := e.RecordType; recordType {
|
switch recordType := e.RecordType; recordType {
|
||||||
case RecordTypeMX:
|
case RecordTypeMX:
|
||||||
|
@ -4,95 +4,6 @@
|
|||||||
|
|
||||||
package endpoint
|
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.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|
||||||
|
apiv1alpha1 "sigs.k8s.io/external-dns/apis/v1alpha1"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,8 +54,8 @@ type crdSource struct {
|
|||||||
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error {
|
func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error {
|
||||||
scheme.AddKnownTypes(groupVersion,
|
scheme.AddKnownTypes(groupVersion,
|
||||||
&endpoint.DNSEndpoint{},
|
&apiv1alpha1.DNSEndpoint{},
|
||||||
&endpoint.DNSEndpointList{},
|
&apiv1alpha1.DNSEndpointList{},
|
||||||
)
|
)
|
||||||
metav1.AddToGroupVersion(scheme, groupVersion)
|
metav1.AddToGroupVersion(scheme, groupVersion)
|
||||||
return nil
|
return nil
|
||||||
@ -129,7 +130,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi
|
|||||||
return sourceCrd.watch(context.TODO(), &lo)
|
return sourceCrd.watch(context.TODO(), &lo)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&endpoint.DNSEndpoint{},
|
&apiv1alpha1.DNSEndpoint{},
|
||||||
0)
|
0)
|
||||||
sourceCrd.informer = &informer
|
sourceCrd.informer = &informer
|
||||||
go informer.Run(wait.NeverStop)
|
go informer.Run(wait.NeverStop)
|
||||||
@ -164,7 +165,7 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
|||||||
endpoints := []*endpoint.Endpoint{}
|
endpoints := []*endpoint.Endpoint{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
result *endpoint.DNSEndpointList
|
result *apiv1alpha1.DNSEndpointList
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -174,7 +175,6 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
result, err = cs.filterByAnnotations(result)
|
result, err = cs.filterByAnnotations(result)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
|||||||
return endpoints, nil
|
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 {
|
for _, ep := range endpoints {
|
||||||
ep.Labels[endpoint.ResourceLabelKey] = fmt.Sprintf("crd/%s/%s", crd.Namespace, crd.Name)
|
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)
|
Watch(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result *endpoint.DNSEndpointList, err error) {
|
func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result *apiv1alpha1.DNSEndpointList, err error) {
|
||||||
result = &endpoint.DNSEndpointList{}
|
result = &apiv1alpha1.DNSEndpointList{}
|
||||||
err = cs.crdClient.Get().
|
err = cs.crdClient.Get().
|
||||||
Namespace(cs.namespace).
|
Namespace(cs.namespace).
|
||||||
Resource(cs.crdResource).
|
Resource(cs.crdResource).
|
||||||
@ -255,8 +255,8 @@ func (cs *crdSource) List(ctx context.Context, opts *metav1.ListOptions) (result
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *crdSource) UpdateStatus(ctx context.Context, dnsEndpoint *endpoint.DNSEndpoint) (result *endpoint.DNSEndpoint, err error) {
|
func (cs *crdSource) UpdateStatus(ctx context.Context, dnsEndpoint *apiv1alpha1.DNSEndpoint) (result *apiv1alpha1.DNSEndpoint, err error) {
|
||||||
result = &endpoint.DNSEndpoint{}
|
result = &apiv1alpha1.DNSEndpoint{}
|
||||||
err = cs.crdClient.Put().
|
err = cs.crdClient.Put().
|
||||||
Namespace(dnsEndpoint.Namespace).
|
Namespace(dnsEndpoint.Namespace).
|
||||||
Resource(cs.crdResource).
|
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.
|
// 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)
|
labelSelector, err := metav1.ParseToLabelSelector(cs.annotationFilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -284,7 +284,7 @@ func (cs *crdSource) filterByAnnotations(dnsendpoints *endpoint.DNSEndpointList)
|
|||||||
return dnsendpoints, nil
|
return dnsendpoints, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredList := endpoint.DNSEndpointList{}
|
filteredList := apiv1alpha1.DNSEndpointList{}
|
||||||
|
|
||||||
for _, dnsendpoint := range dnsendpoints.Items {
|
for _, dnsendpoint := range dnsendpoints.Items {
|
||||||
// include dnsendpoint if its annotations match the selector
|
// include dnsendpoint if its annotations match the selector
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/rest/fake"
|
"k8s.io/client-go/rest/fake"
|
||||||
|
|
||||||
|
apiv1alpha1 "sigs.k8s.io/external-dns/apis/v1alpha1"
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,8 +62,8 @@ func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace,
|
|||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
addKnownTypes(scheme, groupVersion)
|
addKnownTypes(scheme, groupVersion)
|
||||||
|
|
||||||
dnsEndpointList := endpoint.DNSEndpointList{}
|
dnsEndpointList := apiv1alpha1.DNSEndpointList{}
|
||||||
dnsEndpoint := &endpoint.DNSEndpoint{
|
dnsEndpoint := &apiv1alpha1.DNSEndpoint{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: apiVersion,
|
APIVersion: apiVersion,
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
@ -74,7 +75,7 @@ func fakeRESTClient(endpoints []*endpoint.Endpoint, apiVersion, kind, namespace,
|
|||||||
Labels: labels,
|
Labels: labels,
|
||||||
Generation: 1,
|
Generation: 1,
|
||||||
},
|
},
|
||||||
Spec: endpoint.DNSEndpointSpec{
|
Spec: apiv1alpha1.DNSEndpointSpec{
|
||||||
Endpoints: endpoints,
|
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:
|
case p == "/apis/"+apiVersion+"/namespaces/"+namespace+"/"+strings.ToLower(kind)+"s/"+name+"/status" && m == http.MethodPut:
|
||||||
decoder := json.NewDecoder(req.Body)
|
decoder := json.NewDecoder(req.Body)
|
||||||
|
|
||||||
var body endpoint.DNSEndpoint
|
var body apiv1alpha1.DNSEndpoint
|
||||||
decoder.Decode(&body)
|
decoder.Decode(&body)
|
||||||
dnsEndpoint.Status.ObservedGeneration = body.Status.ObservedGeneration
|
dnsEndpoint.Status.ObservedGeneration = body.Status.ObservedGeneration
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: defaultHeader(), Body: objBody(codec, dnsEndpoint)}, nil
|
return &http.Response{StatusCode: http.StatusOK, Header: defaultHeader(), Body: objBody(codec, dnsEndpoint)}, nil
|
||||||
@ -468,7 +469,6 @@ func testCRDSourceEndpoints(t *testing.T) {
|
|||||||
expectError: false,
|
expectError: false,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
||||||
t.Run(ti.title, func(t *testing.T) {
|
t.Run(ti.title, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user