Skip to content

Commit 2481c07

Browse files
authored
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
1 parent 902fab7 commit 2481c07

File tree

7 files changed

+100
-207
lines changed

7 files changed

+100
-207
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ else
3232
CONTROLLER_GEN=$(shell which controller-gen)
3333
endif
3434

35-
#? controller-gen-install: download controller-gen if necessary
36-
controller-gen-install:
37-
@scripts/install-tools.sh --generator
38-
3935
#? golangci-lint-install: Install golangci-lint tool
4036
golangci-lint-install:
4137
@scripts/install-tools.sh --golangci
@@ -67,10 +63,11 @@ oas-lint:
6763
.PHONY: lint
6864
lint: licensecheck go-lint oas-lint
6965

70-
#? crd: Generates CRD using controller-gen
66+
#? crd: Generates CRD using controller-gen and copy it into chart
7167
.PHONY: crd
7268
crd: controller-gen-install
73-
${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > docs/contributing/crd-source/crd-manifest.yaml
69+
${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > config/crd/standard/dnsendpoint.yaml
70+
cp -f config/crd/standard/dnsendpoint.yaml charts/external-dns/crds/dnsendpoint.yaml
7471

7572
#? test: The verify target runs tasks similar to the CI tasks, but without code coverage
7673
.PHONY: test
Lines changed: 83 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
---
12
apiVersion: apiextensions.k8s.io/v1
23
kind: CustomResourceDefinition
34
metadata:
4-
name: dnsendpoints.externaldns.k8s.io
55
annotations:
66
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007
7+
controller-gen.kubebuilder.io/version: v0.17.2
8+
name: dnsendpoints.externaldns.k8s.io
79
spec:
810
group: externaldns.k8s.io
911
names:
@@ -13,90 +15,86 @@ spec:
1315
singular: dnsendpoint
1416
scope: Namespaced
1517
versions:
16-
- name: v1alpha1
17-
schema:
18-
openAPIV3Schema:
19-
properties:
20-
apiVersion:
21-
description: |-
22-
APIVersion defines the versioned schema of this representation of an object.
23-
Servers should convert recognized schemas to the latest internal value, and
24-
may reject unrecognized values.
25-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
26-
type: string
27-
kind:
28-
description: |-
29-
Kind is a string value representing the REST resource this object represents.
30-
Servers may infer this from the endpoint the client submits requests to.
31-
Cannot be updated.
32-
In CamelCase.
33-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
34-
type: string
35-
metadata:
36-
type: object
37-
spec:
38-
description: DNSEndpointSpec defines the desired state of DNSEndpoint
39-
properties:
40-
endpoints:
41-
items:
42-
description:
43-
Endpoint is a high-level way of a connection between
44-
a service and an IP
45-
properties:
46-
dnsName:
47-
description: The hostname of the DNS record
18+
- name: v1alpha1
19+
schema:
20+
openAPIV3Schema:
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: DNSEndpointSpec defines the desired state of DNSEndpoint
41+
properties:
42+
endpoints:
43+
items:
44+
description: Endpoint is a high-level way of a connection between
45+
a service and an IP
46+
properties:
47+
dnsName:
48+
description: The hostname of the DNS record
49+
type: string
50+
labels:
51+
additionalProperties:
4852
type: string
49-
labels:
50-
additionalProperties:
51-
type: string
52-
description: Labels stores labels defined for the Endpoint
53+
description: Labels stores labels defined for the Endpoint
54+
type: object
55+
providerSpecific:
56+
description: ProviderSpecific stores provider specific config
57+
items:
58+
description: ProviderSpecificProperty holds the name and value
59+
of a configuration which is specific to individual DNS providers
60+
properties:
61+
name:
62+
type: string
63+
value:
64+
type: string
5365
type: object
54-
providerSpecific:
55-
description: ProviderSpecific stores provider specific config
56-
items:
57-
description:
58-
ProviderSpecificProperty holds the name and value
59-
of a configuration which is specific to individual DNS providers
60-
properties:
61-
name:
62-
type: string
63-
value:
64-
type: string
65-
type: object
66-
type: array
67-
recordTTL:
68-
description: TTL for the record
69-
format: int64
70-
type: integer
71-
recordType:
72-
description:
73-
RecordType type of record, e.g. CNAME, A, AAAA,
74-
SRV, TXT etc
75-
type: string
76-
setIdentifier:
77-
description:
78-
Identifier to distinguish multiple records with
79-
the same name and type (e.g. Route53 records with routing
80-
policies other than 'simple')
66+
type: array
67+
recordTTL:
68+
description: TTL for the record
69+
format: int64
70+
type: integer
71+
recordType:
72+
description: RecordType type of record, e.g. CNAME, A, AAAA,
73+
SRV, TXT etc
74+
type: string
75+
setIdentifier:
76+
description: Identifier to distinguish multiple records with
77+
the same name and type (e.g. Route53 records with routing
78+
policies other than 'simple')
79+
type: string
80+
targets:
81+
description: The targets the DNS record points to
82+
items:
8183
type: string
82-
targets:
83-
description: The targets the DNS record points to
84-
items:
85-
type: string
86-
type: array
87-
type: object
88-
type: array
89-
type: object
90-
status:
91-
description: DNSEndpointStatus defines the observed state of DNSEndpoint
92-
properties:
93-
observedGeneration:
94-
description: The generation observed by the external-dns controller.
95-
format: int64
96-
type: integer
97-
type: object
98-
type: object
99-
served: true
100-
storage: true
101-
subresources:
102-
status: {}
84+
type: array
85+
type: object
86+
type: array
87+
type: object
88+
status:
89+
description: DNSEndpointStatus defines the observed state of DNSEndpoint
90+
properties:
91+
observedGeneration:
92+
description: The generation observed by the external-dns controller.
93+
format: int64
94+
type: integer
95+
type: object
96+
type: object
97+
served: true
98+
storage: true
99+
subresources:
100+
status: {}

docs/sources/crd/crd-manifest.yaml renamed to config/crd/standard/dnsendpoint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/external-dns/pull/2007
7-
controller-gen.kubebuilder.io/version: v0.15.0
7+
controller-gen.kubebuilder.io/version: v0.17.2
88
name: dnsendpoints.externaldns.k8s.io
99
spec:
1010
group: externaldns.k8s.io

docs/sources/crd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ Create the objects of CRD type by filling in the fields of CRD and DNS record wo
8181

8282
### Example
8383

84-
Here is an example [CRD manifest](crd/crd-manifest.yaml) generated by kubebuilder.
84+
Here is an example [CRD manifest](https://github.com/kubernetes-sigs/external-dns/blob/HEAD/charts/external-dns/crds/dnsendpoint.yaml) generated by kubebuilder.
8585
Apply this to register the CRD
8686

8787
```sh
88-
$ kubectl apply --validate=false -f docs/sources/crd/crd-manifest.yaml
88+
$ kubectl apply --server-side=true -f "https://raw.githubusercontent.com/kubernetes-sigs/external-dns/master/config/crd/standard/dnsendpoint.yaml"
8989
customresourcedefinition.apiextensions.k8s.io "dnsendpoints.externaldns.k8s.io" created
9090
```
9191

endpoint/endpoint.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ type EndpointKey struct {
204204
}
205205

206206
// Endpoint is a high-level way of a connection between a service and an IP
207+
// +kubebuilder:object:generate=true
207208
type Endpoint struct {
208209
// The hostname of the DNS record
209210
DNSName string `json:"dnsName,omitempty"`
@@ -337,6 +338,7 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint {
337338
}
338339

339340
// DNSEndpointSpec defines the desired state of DNSEndpoint
341+
// +kubebuilder:object:generate=true
340342
type DNSEndpointSpec struct {
341343
Endpoints []*Endpoint `json:"endpoints,omitempty"`
342344
}

0 commit comments

Comments
 (0)