chore(crd): use conventional paths and update controller-gen to v0.17.2 (#5287)

* chore(crd): update controller-gen to v0.17.2

* review: only one crd manifest

* set crd in expected paths
This commit is contained in:
Michel Loiseleur 2025-05-04 21:53:56 +02:00 committed by GitHub
parent 902fab7503
commit 2481c07e95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 100 additions and 207 deletions

View File

@ -32,10 +32,6 @@ else
CONTROLLER_GEN=$(shell which controller-gen) CONTROLLER_GEN=$(shell which controller-gen)
endif endif
#? controller-gen-install: download controller-gen if necessary
controller-gen-install:
@scripts/install-tools.sh --generator
#? golangci-lint-install: Install golangci-lint tool #? golangci-lint-install: Install golangci-lint tool
golangci-lint-install: golangci-lint-install:
@scripts/install-tools.sh --golangci @scripts/install-tools.sh --golangci
@ -67,10 +63,11 @@ oas-lint:
.PHONY: lint .PHONY: lint
lint: licensecheck go-lint oas-lint lint: licensecheck go-lint oas-lint
#? crd: Generates CRD using controller-gen #? 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 > docs/contributing/crd-source/crd-manifest.yaml ${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." 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 #? test: The verify target runs tasks similar to the CI tasks, but without code coverage
.PHONY: test .PHONY: test

View File

@ -1,9 +1,11 @@
---
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
metadata: metadata:
name: dnsendpoints.externaldns.k8s.io
annotations: annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007 api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007
controller-gen.kubebuilder.io/version: v0.17.2
name: dnsendpoints.externaldns.k8s.io
spec: spec:
group: externaldns.k8s.io group: externaldns.k8s.io
names: names:
@ -13,90 +15,86 @@ spec:
singular: dnsendpoint singular: dnsendpoint
scope: Namespaced scope: Namespaced
versions: versions:
- name: v1alpha1 - name: v1alpha1
schema: schema:
openAPIV3Schema: openAPIV3Schema:
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
APIVersion defines the versioned schema of this representation of an object. APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values. may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string type: string
kind: kind:
description: |- description: |-
Kind is a string value representing the REST resource this object represents. Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to. Servers may infer this from the endpoint the client submits requests to.
Cannot be updated. Cannot be updated.
In CamelCase. In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string type: string
metadata: metadata:
type: object type: object
spec: spec:
description: DNSEndpointSpec defines the desired state of DNSEndpoint description: DNSEndpointSpec defines the desired state of DNSEndpoint
properties: properties:
endpoints: endpoints:
items: items:
description: description: Endpoint is a high-level way of a connection between
Endpoint is a high-level way of a connection between a service and an IP
a service and an IP properties:
properties: dnsName:
dnsName: description: The hostname of the DNS record
description: The hostname of the DNS record type: string
labels:
additionalProperties:
type: string type: string
labels: description: Labels stores labels defined for the Endpoint
additionalProperties: type: object
type: string providerSpecific:
description: Labels stores labels defined for the Endpoint description: ProviderSpecific stores provider specific config
items:
description: ProviderSpecificProperty holds the name and value
of a configuration which is specific to individual DNS providers
properties:
name:
type: string
value:
type: string
type: object type: object
providerSpecific: type: array
description: ProviderSpecific stores provider specific config recordTTL:
items: description: TTL for the record
description: format: int64
ProviderSpecificProperty holds the name and value type: integer
of a configuration which is specific to individual DNS providers recordType:
properties: description: RecordType type of record, e.g. CNAME, A, AAAA,
name: SRV, TXT etc
type: string type: string
value: setIdentifier:
type: string description: Identifier to distinguish multiple records with
type: object the same name and type (e.g. Route53 records with routing
type: array policies other than 'simple')
recordTTL: type: string
description: TTL for the record targets:
format: int64 description: The targets the DNS record points to
type: integer items:
recordType:
description:
RecordType type of record, e.g. CNAME, A, AAAA,
SRV, TXT etc
type: string type: string
setIdentifier: type: array
description: type: object
Identifier to distinguish multiple records with type: array
the same name and type (e.g. Route53 records with routing type: object
policies other than 'simple') status:
type: string description: DNSEndpointStatus defines the observed state of DNSEndpoint
targets: properties:
description: The targets the DNS record points to observedGeneration:
items: description: The generation observed by the external-dns controller.
type: string format: int64
type: array type: integer
type: object type: object
type: array type: object
type: object served: true
status: storage: true
description: DNSEndpointStatus defines the observed state of DNSEndpoint subresources:
properties: status: {}
observedGeneration:
description: The generation observed by the external-dns controller.
format: int64
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}

View File

@ -4,7 +4,7 @@ kind: CustomResourceDefinition
metadata: metadata:
annotations: annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007 api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007
controller-gen.kubebuilder.io/version: v0.15.0 controller-gen.kubebuilder.io/version: v0.17.2
name: dnsendpoints.externaldns.k8s.io name: dnsendpoints.externaldns.k8s.io
spec: spec:
group: externaldns.k8s.io group: externaldns.k8s.io

View File

@ -81,11 +81,11 @@ Create the objects of CRD type by filling in the fields of CRD and DNS record wo
### Example ### Example
Here is an example [CRD manifest](crd/crd-manifest.yaml) generated by kubebuilder. Here is an example [CRD manifest](https://github.com/kubernetes-sigs/external-dns/blob/HEAD/charts/external-dns/crds/dnsendpoint.yaml) generated by kubebuilder.
Apply this to register the CRD Apply this to register the CRD
```sh ```sh
$ kubectl apply --validate=false -f docs/sources/crd/crd-manifest.yaml $ kubectl apply --server-side=true -f "https://raw.githubusercontent.com/kubernetes-sigs/external-dns/master/config/crd/standard/dnsendpoint.yaml"
customresourcedefinition.apiextensions.k8s.io "dnsendpoints.externaldns.k8s.io" created customresourcedefinition.apiextensions.k8s.io "dnsendpoints.externaldns.k8s.io" created
``` ```

View File

@ -204,6 +204,7 @@ type EndpointKey struct {
} }
// Endpoint is a high-level way of a connection between a service and an IP // Endpoint is a high-level way of a connection between a service and an IP
// +kubebuilder:object:generate=true
type Endpoint struct { type Endpoint struct {
// The hostname of the DNS record // The hostname of the DNS record
DNSName string `json:"dnsName,omitempty"` DNSName string `json:"dnsName,omitempty"`
@ -337,6 +338,7 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint {
} }
// DNSEndpointSpec defines the desired state of DNSEndpoint // DNSEndpointSpec defines the desired state of DNSEndpoint
// +kubebuilder:object:generate=true
type DNSEndpointSpec struct { type DNSEndpointSpec struct {
Endpoints []*Endpoint `json:"endpoints,omitempty"` Endpoints []*Endpoint `json:"endpoints,omitempty"`
} }

View File

@ -1,28 +1,11 @@
//go:build !ignore_autogenerated //go:build !ignore_autogenerated
// +build !ignore_autogenerated
/* // Code generated by controller-gen. DO NOT EDIT.
Copyright 2018 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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package endpoint package endpoint
import ( import (
"k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )
// 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.
@ -32,7 +15,6 @@ func (in *DNSEndpoint) DeepCopyInto(out *DNSEndpoint) {
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec) in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status out.Status = in.Status
return
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpoint. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpoint.
@ -57,7 +39,7 @@ func (in *DNSEndpoint) DeepCopyObject() runtime.Object {
func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList) { func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList) {
*out = *in *out = *in
out.TypeMeta = in.TypeMeta out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil { if in.Items != nil {
in, out := &in.Items, &out.Items in, out := &in.Items, &out.Items
*out = make([]DNSEndpoint, len(*in)) *out = make([]DNSEndpoint, len(*in))
@ -65,7 +47,6 @@ func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList) {
(*in)[i].DeepCopyInto(&(*out)[i]) (*in)[i].DeepCopyInto(&(*out)[i])
} }
} }
return
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointList. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointList.
@ -93,15 +74,13 @@ func (in *DNSEndpointSpec) DeepCopyInto(out *DNSEndpointSpec) {
in, out := &in.Endpoints, &out.Endpoints in, out := &in.Endpoints, &out.Endpoints
*out = make([]*Endpoint, len(*in)) *out = make([]*Endpoint, len(*in))
for i := range *in { for i := range *in {
if (*in)[i] == nil { if (*in)[i] != nil {
(*out)[i] = nil in, out := &(*in)[i], &(*out)[i]
} else { *out = new(Endpoint)
(*out)[i] = new(Endpoint) (*in).DeepCopyInto(*out)
(*in)[i].DeepCopyInto((*out)[i])
} }
} }
} }
return
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointSpec. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointSpec.
@ -114,22 +93,6 @@ func (in *DNSEndpointSpec) DeepCopy() *DNSEndpointSpec {
return 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
return
}
// 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
}
// 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
@ -148,11 +111,8 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
if in.ProviderSpecific != nil { if in.ProviderSpecific != nil {
in, out := &in.ProviderSpecific, &out.ProviderSpecific in, out := &in.ProviderSpecific, &out.ProviderSpecific
*out = make(ProviderSpecific, len(*in)) *out = make(ProviderSpecific, len(*in))
for key, val := range *in { copy(*out, *in)
(*out)[key] = val
}
} }
return
} }
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint. // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
@ -164,67 +124,3 @@ func (in *Endpoint) DeepCopy() *Endpoint {
in.DeepCopyInto(out) in.DeepCopyInto(out)
return out return out
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in Labels) DeepCopyInto(out *Labels) {
{
in := &in
*out = make(Labels, len(*in))
for key, val := range *in {
(*out)[key] = val
}
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Labels.
func (in Labels) DeepCopy() Labels {
if in == nil {
return nil
}
out := new(Labels)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ProviderSpecific) DeepCopyInto(out *ProviderSpecific) {
{
in := &in
*out = make(ProviderSpecific, len(*in))
for key, val := range *in {
(*out)[key] = val
}
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpecific.
func (in ProviderSpecific) DeepCopy() ProviderSpecific {
if in == nil {
return nil
}
out := new(ProviderSpecific)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in Targets) DeepCopyInto(out *Targets) {
{
in := &in
*out = make(Targets, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Targets.
func (in Targets) DeepCopy() Targets {
if in == nil {
return nil
}
out := new(Targets)
in.DeepCopyInto(out)
return *out
}

View File

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools # renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_GENERATOR_VERSION=v0.15.0 CONTROLLER_TOOLS_GENERATOR_VERSION=v0.17.2
# renovate: datasource=github-releases depName=golangci/golangci-lint # renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANG_CI_LINTER_VERSION=v2.0.2 GOLANG_CI_LINTER_VERSION=v2.0.2