Skip to content

Commit 58dc141

Browse files
committed
address claude api review
Signed-off-by: Andreas Karis <ak.karis@gmail.com> next Signed-off-by: Andreas Karis <ak.karis@gmail.com>
1 parent 9630aa9 commit 58dc141

20 files changed

+416
-235
lines changed

bpfman-operator/apis/v1alpha1/bpf_application_state_types.go

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package v1alpha1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21-
metav1types "k8s.io/apimachinery/pkg/types"
22-
"sigs.k8s.io/controller-runtime/pkg/client"
2321
)
2422

2523
// +union
@@ -52,7 +50,7 @@ type BpfApplicationProgramState struct {
5250
// +unionDiscriminator
5351
// +required
5452
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
55-
Type EBPFProgType `json:"type"`
53+
Type EBPFProgType `json:"type,omitempty"`
5654

5755
// xdp contains the attachment data for an XDP program when type is set to XDP.
5856
// +unionMember
@@ -83,15 +81,32 @@ type BpfApplicationProgramState struct {
8381
}
8482

8583
type BpfApplicationStateStatus struct {
86-
// UpdateCount tracks the number of times the BpfApplicationState object has
84+
// conditions contains the summary state of the BpfApplication for the given
85+
// Kubernetes node. If one or more programs failed to load or attach to the
86+
// designated attachment point, the condition will report the error. If more
87+
// than one error has occurred, condition will contain the first error
88+
// encountered.
89+
// +patchMergeKey=type
90+
// +patchStrategy=merge
91+
// +listType=map
92+
// +listMapKey=type
93+
// +optional
94+
// +kubebuilder:validation:MaxItems=1023
95+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
96+
// updateCount tracks the number of times the BpfApplicationState object has
8797
// been updated. The bpfman agent initializes it to 1 when it creates the
8898
// object, and then increments it before each subsequent update. It serves
8999
// as a lightweight sequence number to verify that the API server is serving
90100
// the most recent version of the object before beginning a new Reconcile
91101
// operation.
92-
UpdateCount int64 `json:"updateCount"`
93-
// node is the name of the Kubernets node for this BpfApplicationState.
94-
Node string `json:"node"`
102+
// +kubebuilder:validation:Minimum=1
103+
// +optional
104+
UpdateCount int64 `json:"updateCount,omitempty"`
105+
// node is the name of the Kubernetes node for this BpfApplicationState.
106+
// +kubebuilder:validation:MinLength=1
107+
// +kubebuilder:validation:MaxLength=253
108+
// +optional
109+
Node string `json:"node,omitempty"`
95110
// appLoadStatus reflects the status of loading the eBPF application on the
96111
// given node.
97112
//
@@ -113,21 +128,15 @@ type BpfApplicationStateStatus struct {
113128
//
114129
// UnloadError is returned if one or more programs encountered an error when
115130
// being unloaded.
116-
AppLoadStatus AppLoadStatus `json:"appLoadStatus"`
131+
// +optional
132+
AppLoadStatus AppLoadStatus `json:"appLoadStatus,omitempty"`
117133
// programs is a list of eBPF programs contained in the parent BpfApplication
118134
// instance. Each entry in the list contains the derived program attributes as
119135
// well as the attach status for each program on the given Kubernetes node.
136+
// +kubebuilder:validation:MaxItems=1023
137+
// +listType=atomic
138+
// +optional
120139
Programs []BpfApplicationProgramState `json:"programs,omitempty"`
121-
// conditions contains the summary state of the BpfApplication for the given
122-
// Kubernetes node. If one or more programs failed to load or attach to the
123-
// designated attachment point, the condition will report the error. If more
124-
// than one error has occurred, condition will contain the first error
125-
// encountered.
126-
// +patchMergeKey=type
127-
// +patchStrategy=merge
128-
// +listType=map
129-
// +listMapKey=type
130-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
131140
}
132141

133142
// +genclient
@@ -143,13 +152,16 @@ type BpfApplicationStateStatus struct {
143152
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
144153
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
145154
type BpfApplicationState struct {
146-
metav1.TypeMeta `json:",inline"`
155+
metav1.TypeMeta `json:",inline"`
156+
// metadata is the object's metadata.
157+
// +optional
147158
metav1.ObjectMeta `json:"metadata,omitempty"`
148159

149160
// status reflects the status of a BpfApplication instance for the given node.
150161
// appLoadStatus and conditions provide an overall status for the given node,
151162
// while each item in the programs list provides a per eBPF program status for
152163
// the given node.
164+
// +optional
153165
Status BpfApplicationStateStatus `json:"status,omitempty"`
154166
}
155167

@@ -160,31 +172,3 @@ type BpfApplicationStateList struct {
160172
metav1.ListMeta `json:"metadata,omitempty"`
161173
Items []BpfApplicationState `json:"items"`
162174
}
163-
164-
func (an BpfApplicationState) GetName() string {
165-
return an.Name
166-
}
167-
168-
func (an BpfApplicationState) GetUID() metav1types.UID {
169-
return an.UID
170-
}
171-
172-
func (an BpfApplicationState) GetAnnotations() map[string]string {
173-
return an.Annotations
174-
}
175-
176-
func (an BpfApplicationState) GetLabels() map[string]string {
177-
return an.Labels
178-
}
179-
180-
func (an BpfApplicationState) GetConditions() []metav1.Condition {
181-
return an.Status.Conditions
182-
}
183-
184-
func (an BpfApplicationState) GetClientObject() client.Object {
185-
return &an
186-
}
187-
188-
func (anl BpfApplicationStateList) GetItems() []BpfApplicationState {
189-
return anl.Items
190-
}

bpfman-operator/apis/v1alpha1/bpf_application_types.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ type BpfApplicationProgram struct {
3131
// name is a required field and is the name of the function that is the entry
3232
// point for the eBPF program. name must not be an empty string, must not
3333
// exceed 64 characters in length, must start with alpha characters and must
34-
// only contain alphanumeric characters.
34+
// only contain alphanumeric characters and underscores.
3535
// +required
3636
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
3737
// +kubebuilder:validation:MinLength=1
3838
// +kubebuilder:validation:MaxLength=64
39-
Name string `json:"name"`
39+
Name string `json:"name,omitempty"`
4040

4141
// type is a required field used to specify the type of the eBPF program.
4242
//
@@ -73,7 +73,7 @@ type BpfApplicationProgram struct {
7373
// +unionDiscriminator
7474
// +required
7575
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"UProbe";"URetProbe"
76-
Type EBPFProgType `json:"type"`
76+
Type EBPFProgType `json:"type,omitempty"`
7777

7878
// xdp is an optional field, but required when the type field is set to XDP.
7979
// xdp defines the desired state of the application's XDP programs. XDP program
@@ -163,7 +163,9 @@ type BpfApplicationSpec struct {
163163
// programs in the list to be reloaded, which could be temporarily service
164164
// effecting. For this reason, modifying the list is currently not allowed.
165165
// +required
166-
// +kubebuilder:validation:MinItems:=1
166+
// +kubebuilder:validation:MinItems=1
167+
// +kubebuilder:validation:MaxItems=1023
168+
// +listType=atomic
167169
Programs []BpfApplicationProgram `json:"programs,omitempty"`
168170
}
169171

@@ -185,11 +187,17 @@ type BpfApplicationSpec struct {
185187
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
186188
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
187189
type BpfApplication struct {
188-
metav1.TypeMeta `json:",inline"`
190+
metav1.TypeMeta `json:",inline"`
191+
// metadata is the object's metadata.
192+
// +optional
189193
metav1.ObjectMeta `json:"metadata,omitempty"`
190194

191-
Spec BpfApplicationSpec `json:"spec,omitempty"`
192-
Status BpfAppStatus `json:"status,omitempty"`
195+
// spec defines the desired state of the BpfApplication.
196+
// +required
197+
Spec BpfApplicationSpec `json:"spec,omitzero"`
198+
// status reflects the observed state of the BpfApplication.
199+
// +optional
200+
Status BpfAppStatus `json:"status,omitempty"`
193201
}
194202

195203
// +kubebuilder:object:root=true

bpfman-operator/apis/v1alpha1/cluster_bpf_application_state_types.go

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package v1alpha1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21-
metav1types "k8s.io/apimachinery/pkg/types"
22-
"sigs.k8s.io/controller-runtime/pkg/client"
2321
)
2422

2523
// +union
@@ -73,7 +71,7 @@ type ClBpfApplicationProgramState struct {
7371
// +unionDiscriminator
7472
// +required
7573
// +kubebuilder:validation:Enum:="FEntry";"FExit";"KProbe";"KRetProbe";"TC";"TCX";"TracePoint";"UProbe";"URetProbe";"XDP"
76-
Type EBPFProgType `json:"type"`
74+
Type EBPFProgType `json:"type,omitempty"`
7775

7876
// xdp contains the attachment data for an XDP program when type is set to XDP.
7977
// +unionMember
@@ -134,15 +132,32 @@ type ClBpfApplicationProgramState struct {
134132
}
135133

136134
type ClBpfApplicationStateStatus struct {
137-
// UpdateCount tracks the number of times the BpfApplicationState object has
135+
// conditions contains the summary state of the ClusterBpfApplication for the
136+
// given Kubernetes node. If one or more programs failed to load or attach to
137+
// the designated attachment point, the condition will report the error. If
138+
// more than one error has occurred, condition will contain the first error
139+
// encountered.
140+
// +patchMergeKey=type
141+
// +patchStrategy=merge
142+
// +listType=map
143+
// +listMapKey=type
144+
// +optional
145+
// +kubebuilder:validation:MaxItems=1023
146+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
147+
// updateCount tracks the number of times the BpfApplicationState object has
138148
// been updated. The bpfman agent initializes it to 1 when it creates the
139149
// object, and then increments it before each subsequent update. It serves
140150
// as a lightweight sequence number to verify that the API server is serving
141151
// the most recent version of the object before beginning a new Reconcile
142152
// operation.
143-
UpdateCount int64 `json:"updateCount"`
153+
// +kubebuilder:validation:Minimum=1
154+
// +optional
155+
UpdateCount int64 `json:"updateCount,omitempty"`
144156
// node is the name of the Kubernetes node for this ClusterBpfApplicationState.
145-
Node string `json:"node"`
157+
// +kubebuilder:validation:MinLength=1
158+
// +kubebuilder:validation:MaxLength=253
159+
// +optional
160+
Node string `json:"node,omitempty"`
146161
// appLoadStatus reflects the status of loading the eBPF application on the
147162
// given node.
148163
//
@@ -162,22 +177,16 @@ type ClBpfApplicationStateStatus struct {
162177
//
163178
// UnloadError is returned if one or more programs encountered an error when
164179
// being unloaded.
165-
AppLoadStatus AppLoadStatus `json:"appLoadStatus"`
180+
// +optional
181+
AppLoadStatus AppLoadStatus `json:"appLoadStatus,omitempty"`
166182
// programs is a list of eBPF programs contained in the parent
167183
// ClusterBpfApplication instance. Each entry in the list contains the derived
168184
// program attributes as well as the attach status for each program on the
169185
// given Kubernetes node.
186+
// +kubebuilder:validation:MaxItems=1023
187+
// +listType=atomic
188+
// +optional
170189
Programs []ClBpfApplicationProgramState `json:"programs,omitempty"`
171-
// conditions contains the summary state of the ClusterBpfApplication for the
172-
// given Kubernetes node. If one or more programs failed to load or attach to
173-
// the designated attachment point, the condition will report the error. If
174-
// more than one error has occurred, condition will contain the first error
175-
// encountered.
176-
// +patchMergeKey=type
177-
// +patchStrategy=merge
178-
// +listType=map
179-
// +listMapKey=type
180-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
181190
}
182191

183192
// +genclient
@@ -194,13 +203,16 @@ type ClBpfApplicationStateStatus struct {
194203
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
195204
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
196205
type ClusterBpfApplicationState struct {
197-
metav1.TypeMeta `json:",inline"`
206+
metav1.TypeMeta `json:",inline"`
207+
// metadata is the object's metadata.
208+
// +optional
198209
metav1.ObjectMeta `json:"metadata,omitempty"`
199210

200211
// status reflects the status of a ClusterBpfApplication instance for the given
201212
// node. appLoadStatus and conditions provide an overall status for the given
202213
// node, while each item in the programs list provides a per eBPF program
203214
// status for the given node.
215+
// +optional
204216
Status ClBpfApplicationStateStatus `json:"status,omitempty"`
205217
}
206218

@@ -211,31 +223,3 @@ type ClusterBpfApplicationStateList struct {
211223
metav1.ListMeta `json:"metadata,omitempty"`
212224
Items []ClusterBpfApplicationState `json:"items"`
213225
}
214-
215-
func (an ClusterBpfApplicationState) GetName() string {
216-
return an.Name
217-
}
218-
219-
func (an ClusterBpfApplicationState) GetUID() metav1types.UID {
220-
return an.UID
221-
}
222-
223-
func (an ClusterBpfApplicationState) GetAnnotations() map[string]string {
224-
return an.Annotations
225-
}
226-
227-
func (an ClusterBpfApplicationState) GetLabels() map[string]string {
228-
return an.Labels
229-
}
230-
231-
func (an ClusterBpfApplicationState) GetConditions() []metav1.Condition {
232-
return an.Status.Conditions
233-
}
234-
235-
func (an ClusterBpfApplicationState) GetClientObject() client.Object {
236-
return &an
237-
}
238-
239-
func (anl ClusterBpfApplicationStateList) GetItems() []ClusterBpfApplicationState {
240-
return anl.Items
241-
}

bpfman-operator/apis/v1alpha1/cluster_bpf_application_types.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ type ClBpfApplicationProgram struct {
7777
// name is a required field and is the name of the function that is the entry
7878
// point for the eBPF program. name must not be an empty string, must not
7979
// exceed 64 characters in length, must start with alpha characters and must
80-
// only contain alphanumeric characters.
80+
// only contain alphanumeric characters and underscores.
8181
// +required
8282
// +kubebuilder:validation:Pattern="^[a-zA-Z][a-zA-Z0-9_]+."
8383
// +kubebuilder:validation:MinLength=1
8484
// +kubebuilder:validation:MaxLength=64
85-
Name string `json:"name"`
85+
Name string `json:"name,omitempty"`
8686

8787
// type is a required field used to specify the type of the eBPF program.
8888
//
@@ -143,7 +143,7 @@ type ClBpfApplicationProgram struct {
143143
// +unionDiscriminator
144144
// +required
145145
// +kubebuilder:validation:Enum:="XDP";"TC";"TCX";"FEntry";"FExit";"KProbe";"KRetProbe";"UProbe";"URetProbe";"TracePoint"
146-
Type EBPFProgType `json:"type"`
146+
Type EBPFProgType `json:"type,omitempty"`
147147

148148
// xdp is an optional field, but required when the type field is set to XDP.
149149
// xdp defines the desired state of the application's XDP programs. XDP program
@@ -293,7 +293,9 @@ type ClBpfApplicationSpec struct {
293293
// effecting. For this reason, modifying the list is currently not allowed.
294294
// +required
295295
// +kubebuilder:validation:MinItems:=1
296-
Programs []ClBpfApplicationProgram `json:"programs"`
296+
// +kubebuilder:validation:MaxItems=1023
297+
// +listType=atomic
298+
Programs []ClBpfApplicationProgram `json:"programs,omitempty"`
297299
}
298300

299301
// +genclient
@@ -316,11 +318,17 @@ type ClBpfApplicationSpec struct {
316318
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[0].reason`
317319
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
318320
type ClusterBpfApplication struct {
319-
metav1.TypeMeta `json:",inline"`
321+
metav1.TypeMeta `json:",inline"`
322+
// metadata is the standard object's metadata.
323+
// +optional
320324
metav1.ObjectMeta `json:"metadata,omitempty"`
321325

322-
Spec ClBpfApplicationSpec `json:"spec,omitempty"`
323-
Status BpfAppStatus `json:"status,omitempty"`
326+
// spec defines the desired state of the BpfApplication.
327+
// +required
328+
Spec ClBpfApplicationSpec `json:"spec,omitzero"`
329+
// status reflects the observed state of the BpfApplication.
330+
// +optional
331+
Status BpfAppStatus `json:"status,omitempty"`
324332
}
325333

326334
// +kubebuilder:object:root=true

0 commit comments

Comments
 (0)