Skip to content

Commit

Permalink
Merge pull request #4838 from ywk253100/220418_marker
Browse files Browse the repository at this point in the history
Use controller-gen to generate the deep copy methods for objects
  • Loading branch information
reasonerjt authored Apr 21, 2022
2 parents ff4f63b + 28bc8b7 commit 3ec96e2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 90 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/4838-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use controller-gen to generate the deep copy methods for objects
14 changes: 7 additions & 7 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rules:
- apiGroups:
- velero.io
resources:
- schedules
- podvolumebackups
verbs:
- create
- delete
Expand All @@ -67,15 +67,15 @@ rules:
- apiGroups:
- velero.io
resources:
- schedules/status
- podvolumebackups/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- serverstatusrequests
- schedules
verbs:
- create
- delete
Expand All @@ -87,15 +87,15 @@ rules:
- apiGroups:
- velero.io
resources:
- serverstatusrequests/status
- schedules/status
verbs:
- get
- patch
- update
- apiGroups:
- velero.io
resources:
- podvolumebackup
- serverstatusrequests
verbs:
- create
- delete
Expand All @@ -107,8 +107,8 @@ rules:
- apiGroups:
- velero.io
resources:
- podvolumebackup/status
- serverstatusrequests/status
verbs:
- get
- patch
- update
- update
4 changes: 3 additions & 1 deletion hack/update-generated-crd-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ controller-gen \
paths=./pkg/apis/velero/v1/... \
rbac:roleName=velero-perms \
paths=./pkg/controller/... \
output:crd:artifacts:config=config/crd/v1/bases
output:crd:artifacts:config=config/crd/v1/bases \
object \
paths=./pkg/apis/velero/v1/...

# this is a super hacky workaround for https://github.com/kubernetes/kubernetes/issues/91395
# which a result of fixing the validation on CRD objects. The validation ensures the fields that are list map keys, are either marked
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-generated-crd-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

HACK_DIR=$(dirname "${BASH_SOURCE}")

${HACK_DIR}/update-generated-crd-code.sh --verify-only
${HACK_DIR}/update-generated-crd-code.sh

# ensure no changes to generated CRDs
if ! git diff --exit-code config/crd/v1/crds/crds.go >/dev/null; then
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/velero/v1/schedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ type ScheduleStatus struct {
// TODO(2.0) After converting all resources to use the runtime-controller client, the genclient and k8s:deepcopy markers will no longer be needed and should be removed.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root
// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Name",type="string",JSONPath=".metadata.name",description="Name of the schedule"
Expand All @@ -106,7 +106,8 @@ type Schedule struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root
// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true

// ScheduleList is a list of Schedules.
type ScheduleList struct {
Expand Down
Loading

0 comments on commit 3ec96e2

Please sign in to comment.