Skip to content

Commit 4701e85

Browse files
committed
migrate CRD generation to controller-gen
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent e397696 commit 4701e85

8 files changed

Lines changed: 6068 additions & 3215 deletions

File tree

config/crd/bases/operator.knative.dev_knativeeventings.yaml

Lines changed: 2740 additions & 1530 deletions
Large diffs are not rendered by default.

config/crd/bases/operator.knative.dev_knativeservings.yaml

Lines changed: 3290 additions & 1683 deletions
Large diffs are not rendered by default.

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# This kustomization.yaml is not intended to be run by itself,
1616
# since it depends on service name and namespace that are out of this kustomize package.
1717
# It should be run by config/default
18+
commonLabels:
19+
app.kubernetes.io/version: devel
20+
app.kubernetes.io/name: knative-operator
1821
resources:
1922
- bases/operator.knative.dev_knativeservings.yaml
2023
- bases/operator.knative.dev_knativeeventings.yaml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 The Knative Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+

hack/update-codegen.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ kube::codegen::gen_helpers \
5353
--boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \
5454
"${REPO_ROOT_DIR}/pkg/apis"
5555

56+
group "CRD Gen"
57+
58+
# Install controller-gen if not already available
59+
GOFLAGS=-mod=mod go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.20.1
60+
export PATH="$(go env GOPATH)/bin:$PATH"
61+
62+
# Generate CRD manifests from Go types using controller-gen.
63+
# This ensures CRD schemas stay in sync with the API type definitions.
64+
GOFLAGS=-mod=mod controller-gen \
65+
crd:allowDangerousTypes=true,ignoreUnexportedFields=true,headerFile="${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.yaml.txt" \
66+
paths="${REPO_ROOT_DIR}/pkg/apis/..." \
67+
output:crd:dir="${REPO_ROOT_DIR}/config/crd/bases"
68+
5669
group "Update deps post-codegen"
5770

5871
# Make sure our dependencies are up-to-date

pkg/apis/operator/base/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ type PodDisruptionBudgetOverride struct {
348348
// Name is the name of the podDisruptionBudget to override.
349349
Name string `json:"name"`
350350
// The desired PodDisruptionBudgetSpec
351-
policyv1.PodDisruptionBudgetSpec
351+
policyv1.PodDisruptionBudgetSpec `json:",inline"`
352352
}
353353

354354
// ResourceRequirementsOverride enables the user to override any container's
@@ -357,7 +357,7 @@ type ResourceRequirementsOverride struct {
357357
// The container name
358358
Container string `json:"container"`
359359
// The desired ResourceRequirements
360-
corev1.ResourceRequirements
360+
corev1.ResourceRequirements `json:",inline"`
361361
}
362362

363363
// EnvRequirementsOverride enables the user to override any container's env vars.

pkg/apis/operator/v1beta1/knativeeventing_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var (
3131
// +genclient
3232
// +genreconciler:krshapedlogic=false
3333
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
3436
type KnativeEventing struct {
3537
metav1.TypeMeta `json:",inline"`
3638
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -89,6 +91,7 @@ type KnativeEventingStatus struct {
8991

9092
// KnativeEventingList contains a list of KnativeEventing
9193
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
94+
// +kubebuilder:object:root=true
9295
type KnativeEventingList struct {
9396
metav1.TypeMeta `json:",inline"`
9497
metav1.ListMeta `json:"metadata,omitempty"`

pkg/apis/operator/v1beta1/knativeserving_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var (
3131
// +genclient
3232
// +genreconciler:krshapedlogic=false
3333
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
3436
type KnativeServing struct {
3537
metav1.TypeMeta `json:",inline"`
3638
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -78,6 +80,7 @@ type KnativeServingStatus struct {
7880

7981
// KnativeServingList contains a list of KnativeServing
8082
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
83+
// +kubebuilder:object:root=true
8184
type KnativeServingList struct {
8285
metav1.TypeMeta `json:",inline"`
8386
metav1.ListMeta `json:"metadata,omitempty"`

0 commit comments

Comments
 (0)