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:
@ -39,8 +41,7 @@ spec:
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:
@ -54,8 +55,7 @@ spec:
providerSpecific: providerSpecific:
description: ProviderSpecific stores provider specific config description: ProviderSpecific stores provider specific config
items: items:
description: description: ProviderSpecificProperty holds the name and value
ProviderSpecificProperty holds the name and value
of a configuration which is specific to individual DNS providers of a configuration which is specific to individual DNS providers
properties: properties:
name: name:
@ -69,13 +69,11 @@ spec:
format: int64 format: int64
type: integer type: integer
recordType: recordType:
description: description: RecordType type of record, e.g. CNAME, A, AAAA,
RecordType type of record, e.g. CNAME, A, AAAA,
SRV, TXT etc SRV, TXT etc
type: string type: string
setIdentifier: setIdentifier:
description: description: Identifier to distinguish multiple records with
Identifier to distinguish multiple records with
the same name and type (e.g. Route53 records with routing the same name and type (e.g. Route53 records with routing
policies other than 'simple') policies other than 'simple')
type: string type: string

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,12 +111,9 @@ 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.
func (in *Endpoint) DeepCopy() *Endpoint { func (in *Endpoint) DeepCopy() *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