Skip to content

Commit 3f96e53

Browse files
plugin/deploy-image,v1alpha1: drop patchStrategy/protobuf tags from Conditions
Simplify the Conditions field in status scaffolding by removing patchStrategy, patchMergeKey, and protobuf tags. Applied to: - deploy-image/alpha-v1 plugin template - Getting Started Memcached example These tags are unnecessary by default and can cause unintended merge behavior. This aligns with best practices for CRD scaffolding.
1 parent 202a630 commit 3f96e53

File tree

15 files changed

+137
-80
lines changed

15 files changed

+137
-80
lines changed

docs/book/src/getting-started/testdata/project/api/v1alpha1/memcached_types.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,22 @@ type MemcachedSpec struct {
4242

4343
// MemcachedStatus defines the observed state of Memcached.
4444
type MemcachedStatus struct {
45-
// Represents the observations of a Memcached's current state.
46-
// Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded"
47-
// Memcached.status.conditions.status are one of True, False, Unknown.
48-
// Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific
49-
// condition types may define expected values and meanings for this field, and whether the values
50-
// are considered a guaranteed API.
51-
// Memcached.status.conditions.Message is a human readable message indicating details about the transition.
52-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
53-
54-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
45+
// conditions represent the current state of the Memcached resource.
46+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
47+
//
48+
// Standard condition types include:
49+
// - "Available": the resource is fully functional.
50+
// - "Progressing": the resource is being created or updated.
51+
// - "Degraded": the resource failed to reach or maintain its desired state.
52+
//
53+
// The status of each condition is one of True, False, or Unknown.
54+
// The reason is a CamelCase string, suitable for machine interpretation.
55+
// The message provides a human-readable description of the transition.
56+
//
57+
// For Kubernetes API conventions, see:
58+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
59+
60+
Conditions []metav1.Condition `json:"conditions,omitempty"`
5561
}
5662

5763
// +kubebuilder:object:root=true

hack/docs/internal/getting-started/generate_getting_started.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,22 @@ const (
256256
const oldStatusAPI = `// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
257257
// Important: Run "make" to regenerate code after modifying this file`
258258

259-
const newStatusAPI = `// Represents the observations of a Memcached's current state.
260-
// Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded"
261-
// Memcached.status.conditions.status are one of True, False, Unknown.
262-
// Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific
263-
// condition types may define expected values and meanings for this field, and whether the values
264-
// are considered a guaranteed API.
265-
// Memcached.status.conditions.Message is a human readable message indicating details about the transition.
266-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
267-
268-
Conditions []metav1.Condition ` + "`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`"
259+
const newStatusAPI = `// conditions represent the current state of the Memcached resource.
260+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
261+
//
262+
// Standard condition types include:
263+
// - "Available": the resource is fully functional.
264+
// - "Progressing": the resource is being created or updated.
265+
// - "Degraded": the resource failed to reach or maintain its desired state.
266+
//
267+
// The status of each condition is one of True, False, or Unknown.
268+
// The reason is a CamelCase string, suitable for machine interpretation.
269+
// The message provides a human-readable description of the transition.
270+
//
271+
// For Kubernetes API conventions, see:
272+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
273+
274+
Conditions []metav1.Condition ` + "`json:\"conditions,omitempty\"`"
269275

270276
const sampleSizeFragment = `# TODO(user): edit the following value to ensure the number
271277
# of Pods/Instances your Operand must have on cluster

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/api/types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,20 @@ type {{ .Resource.Kind }}Spec struct {
9191
}
9292
9393
// {{ .Resource.Kind }}Status defines the observed state of {{ .Resource.Kind }}
94+
// For Kubernetes API conventions, see:
95+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
9496
type {{ .Resource.Kind }}Status struct {
95-
// Represents the observations of a {{ .Resource.Kind }}'s current state.
96-
// {{ .Resource.Kind }}.status.conditions.type are: "Available", "Progressing", and "Degraded"
97-
// {{ .Resource.Kind }}.status.conditions.status are one of True, False, Unknown.
98-
// {{ .Resource.Kind }}.status.conditions.reason the value should be a CamelCase string and producers of specific
99-
// condition types may define expected values and meanings for this field, and whether the values
100-
// are considered a guaranteed API.
101-
// {{ .Resource.Kind }}.status.conditions.Message is a human readable message indicating details about the transition.
102-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
103-
104-
Conditions []metav1.Condition ` + "`" + `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` + "`" + `
97+
// conditions represent the current state of the {{ .Resource.Kind }} resource.
98+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
99+
//
100+
// Standard condition types include:
101+
// - "Available": the resource is fully functional.
102+
// - "Progressing": the resource is being created or updated.
103+
// - "Degraded": the resource failed to reach or maintain its desired state.
104+
//
105+
// The status of each condition is one of True, False, or Unknown.
106+
107+
Conditions []metav1.Condition ` + "`" + `json:"conditions,omitempty"` + "`" + `
105108
}
106109
107110
// +kubebuilder:object:root=true

testdata/project-v4-multigroup/api/example.com/v1alpha1/busybox_types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,20 @@ type BusyboxSpec struct {
3838
}
3939

4040
// BusyboxStatus defines the observed state of Busybox
41+
// For Kubernetes API conventions, see:
42+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
4143
type BusyboxStatus struct {
42-
// Represents the observations of a Busybox's current state.
43-
// Busybox.status.conditions.type are: "Available", "Progressing", and "Degraded"
44-
// Busybox.status.conditions.status are one of True, False, Unknown.
45-
// Busybox.status.conditions.reason the value should be a CamelCase string and producers of specific
46-
// condition types may define expected values and meanings for this field, and whether the values
47-
// are considered a guaranteed API.
48-
// Busybox.status.conditions.Message is a human readable message indicating details about the transition.
49-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
50-
51-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
44+
// conditions represent the current state of the Busybox resource.
45+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
46+
//
47+
// Standard condition types include:
48+
// - "Available": the resource is fully functional.
49+
// - "Progressing": the resource is being created or updated.
50+
// - "Degraded": the resource failed to reach or maintain its desired state.
51+
//
52+
// The status of each condition is one of True, False, or Unknown.
53+
54+
Conditions []metav1.Condition `json:"conditions,omitempty"`
5255
}
5356

5457
// +kubebuilder:object:root=true

testdata/project-v4-multigroup/api/example.com/v1alpha1/memcached_types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ type MemcachedSpec struct {
4141
}
4242

4343
// MemcachedStatus defines the observed state of Memcached
44+
// For Kubernetes API conventions, see:
45+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
4446
type MemcachedStatus struct {
45-
// Represents the observations of a Memcached's current state.
46-
// Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded"
47-
// Memcached.status.conditions.status are one of True, False, Unknown.
48-
// Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific
49-
// condition types may define expected values and meanings for this field, and whether the values
50-
// are considered a guaranteed API.
51-
// Memcached.status.conditions.Message is a human readable message indicating details about the transition.
52-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
53-
54-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
47+
// conditions represent the current state of the Memcached resource.
48+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
49+
//
50+
// Standard condition types include:
51+
// - "Available": the resource is fully functional.
52+
// - "Progressing": the resource is being created or updated.
53+
// - "Degraded": the resource failed to reach or maintain its desired state.
54+
//
55+
// The status of each condition is one of True, False, or Unknown.
56+
57+
Conditions []metav1.Condition `json:"conditions,omitempty"`
5558
}
5659

5760
// +kubebuilder:object:root=true

testdata/project-v4-multigroup/config/crd/bases/example.com.testproject.org_busyboxes.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ spec:
5050
type: integer
5151
type: object
5252
status:
53-
description: BusyboxStatus defines the observed state of Busybox
53+
description: |-
54+
BusyboxStatus defines the observed state of Busybox
55+
For Kubernetes API conventions, see:
56+
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
5457
properties:
5558
conditions:
5659
items:

testdata/project-v4-multigroup/config/crd/bases/example.com.testproject.org_memcacheds.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ spec:
5555
type: integer
5656
type: object
5757
status:
58-
description: MemcachedStatus defines the observed state of Memcached
58+
description: |-
59+
MemcachedStatus defines the observed state of Memcached
60+
For Kubernetes API conventions, see:
61+
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
5962
properties:
6063
conditions:
6164
items:

testdata/project-v4-multigroup/dist/install.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ spec:
166166
type: integer
167167
type: object
168168
status:
169-
description: BusyboxStatus defines the observed state of Busybox
169+
description: |-
170+
BusyboxStatus defines the observed state of Busybox
171+
For Kubernetes API conventions, see:
172+
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
170173
properties:
171174
conditions:
172175
items:
@@ -665,7 +668,10 @@ spec:
665668
type: integer
666669
type: object
667670
status:
668-
description: MemcachedStatus defines the observed state of Memcached
671+
description: |-
672+
MemcachedStatus defines the observed state of Memcached
673+
For Kubernetes API conventions, see:
674+
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
669675
properties:
670676
conditions:
671677
items:

testdata/project-v4-with-plugins/api/v1alpha1/busybox_types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,20 @@ type BusyboxSpec struct {
3838
}
3939

4040
// BusyboxStatus defines the observed state of Busybox
41+
// For Kubernetes API conventions, see:
42+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
4143
type BusyboxStatus struct {
42-
// Represents the observations of a Busybox's current state.
43-
// Busybox.status.conditions.type are: "Available", "Progressing", and "Degraded"
44-
// Busybox.status.conditions.status are one of True, False, Unknown.
45-
// Busybox.status.conditions.reason the value should be a CamelCase string and producers of specific
46-
// condition types may define expected values and meanings for this field, and whether the values
47-
// are considered a guaranteed API.
48-
// Busybox.status.conditions.Message is a human readable message indicating details about the transition.
49-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
50-
51-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
44+
// conditions represent the current state of the Busybox resource.
45+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
46+
//
47+
// Standard condition types include:
48+
// - "Available": the resource is fully functional.
49+
// - "Progressing": the resource is being created or updated.
50+
// - "Degraded": the resource failed to reach or maintain its desired state.
51+
//
52+
// The status of each condition is one of True, False, or Unknown.
53+
54+
Conditions []metav1.Condition `json:"conditions,omitempty"`
5255
}
5356

5457
// +kubebuilder:object:root=true

testdata/project-v4-with-plugins/api/v1alpha1/memcached_types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ type MemcachedSpec struct {
4141
}
4242

4343
// MemcachedStatus defines the observed state of Memcached
44+
// For Kubernetes API conventions, see:
45+
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
4446
type MemcachedStatus struct {
45-
// Represents the observations of a Memcached's current state.
46-
// Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded"
47-
// Memcached.status.conditions.status are one of True, False, Unknown.
48-
// Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific
49-
// condition types may define expected values and meanings for this field, and whether the values
50-
// are considered a guaranteed API.
51-
// Memcached.status.conditions.Message is a human readable message indicating details about the transition.
52-
// For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
53-
54-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
47+
// conditions represent the current state of the Memcached resource.
48+
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
49+
//
50+
// Standard condition types include:
51+
// - "Available": the resource is fully functional.
52+
// - "Progressing": the resource is being created or updated.
53+
// - "Degraded": the resource failed to reach or maintain its desired state.
54+
//
55+
// The status of each condition is one of True, False, or Unknown.
56+
57+
Conditions []metav1.Condition `json:"conditions,omitempty"`
5558
}
5659

5760
// +kubebuilder:object:root=true

0 commit comments

Comments
 (0)