Skip to content

Commit 703ef1c

Browse files
committed
Align Config API with OpenShift API conventions
Make the following changes to align with OpenShift API standards: - Update field documentation to use lowercase descriptions per OpenShift style guidelines - Add explicit field descriptions for metadata, spec, and status on Config type - Remove redundant +kubebuilder:validation:Required tags (implied by +required marker) - Add validation constraints (MinLength, MaxLength) to string fields - Change HealthProbePort type from int to int32 for consistency - Make HealthProbePort optional, with default value 8175 applied in controller instead of API layer - Add enum validation for AgentSpec.LogLevel - Use omitzero JSON tag for required Spec field - Add MaxItems validation for status Conditions array - Add documentation for ConfigComponentStatus constants Signed-off-by: Andreas Karis <[email protected]>
1 parent 234b327 commit 703ef1c

File tree

6 files changed

+148
-68
lines changed

6 files changed

+148
-68
lines changed

apis/v1alpha1/config_types.go

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,64 +31,84 @@ import (
3131
// +kubebuilder:printcolumn:name="Progressing",type="string",JSONPath=".status.conditions[?(@.type=='Progressing')].status"
3232
// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status"
3333
type Config struct {
34-
metav1.TypeMeta `json:",inline"`
34+
metav1.TypeMeta `json:",inline"`
35+
// metadata is the object's metadata.
36+
// +optional
3537
metav1.ObjectMeta `json:"metadata,omitempty"`
3638

37-
Spec ConfigSpec `json:"spec,omitempty"`
39+
// spec defines the desired state of the bpfman-operator.
40+
// +required
41+
Spec ConfigSpec `json:"spec,omitzero"`
42+
// status reflects the observed state of the bpfman-operator.
43+
// +optional
3844
Status ConfigStatus `json:"status,omitempty"`
3945
}
4046

41-
// Spec defines the desired state of the bpfman-operator.
47+
// spec defines the desired state of the bpfman-operator.
4248
type ConfigSpec struct {
43-
// Agent holds the configuration for the bpfman agent.
49+
// agent specifies the configuration for the bpfman agent DaemonSet.
4450
// +required
45-
Agent AgentSpec `json:"agent,omitempty"`
46-
// Configuration holds the content of bpfman.toml.
51+
Agent AgentSpec `json:"agent,omitzero"`
52+
// configuration specifies the content of bpfman.toml configuration file used by the bpfman DaemonSet.
4753
// +required
48-
// +kubebuilder:validation:Required
4954
// +kubebuilder:validation:MinLength=1
50-
Configuration string `json:"configuration"`
51-
// Image holds the image of the bpfman DaemonSets.
55+
// +kubebuilder:validation:MaxLength=65536
56+
Configuration string `json:"configuration,omitempty"`
57+
// image specifies the container image for the bpfman DaemonSet.
5258
// +required
53-
// +kubebuilder:validation:Required
5459
// +kubebuilder:validation:MinLength=1
55-
Image string `json:"image"`
56-
// LogLevel holds the log level for the bpfman-operator.
60+
// +kubebuilder:validation:MaxLength=1023
61+
Image string `json:"image,omitempty"`
62+
// logLevel specifies the log level for the bpfman DaemonSet via the RUST_LOG environment variable.
63+
// The RUST_LOG environment variable controls logging with the syntax: RUST_LOG=[target][=][level][,...].
64+
// For further information, see https://docs.rs/env_logger/latest/env_logger/.
5765
// +optional
66+
// +kubebuilder:validation:MinLength=1
67+
// +kubebuilder:validation:MaxLength=1024
5868
LogLevel string `json:"logLevel,omitempty"`
59-
// Namespace holds the namespace where bpfman-operator resources shall be
60-
// deployed.
69+
// namespace specifies the namespace where bpfman-operator resources will be deployed.
70+
// If not specified, resources will be deployed in the default bpfman namespace.
71+
// +optional
72+
// +kubebuilder:validation:MinLength=1
73+
// +kubebuilder:validation:MaxLength=256
6174
Namespace string `json:"namespace,omitempty"`
6275
}
6376

6477
// AgentSpec defines the desired state of the bpfman agent.
6578
type AgentSpec struct {
66-
// HealthProbePort holds the health probe bind port for the bpfman agent.
79+
// healthProbePort specifies the port on which the bpfman agent's health probe endpoint will listen.
80+
// If unspecified, the default port will be used.
6781
// +optional
68-
// +kubebuilder:default=8175
6982
// +kubebuilder:validation:Minimum=1
7083
// +kubebuilder:validation:Maximum=65535
71-
HealthProbePort int `json:"healthProbePort"`
72-
// Image holds the image for the bpfman agent.
84+
HealthProbePort int32 `json:"healthProbePort,omitempty"`
85+
// image specifies the container image for the bpfman agent DaemonSet.
7386
// +required
74-
// +kubebuilder:validation:Required
7587
// +kubebuilder:validation:MinLength=1
76-
Image string `json:"image"`
77-
// LogLevel holds the log level for the bpfman agent.
88+
// +kubebuilder:validation:MaxLength=1023
89+
Image string `json:"image,omitempty"`
90+
// logLevel specifies the verbosity of logs produced by the bpfman agent.
91+
// Valid values are: "info", "debug", "trace".
7892
// +optional
93+
// +kubebuilder:validation:MinLength=1
94+
// +kubebuilder:validation:MaxLength=256
95+
// +kubebuilder:validation:Enum=info;debug;trace
7996
LogLevel string `json:"logLevel,omitempty"`
8097
}
8198

8299
// status reflects the status of the bpfman-operator configuration.
83100
type ConfigStatus struct {
84-
// conditions store the status conditions of the bpfman-operator components.
101+
// conditions represents the current state conditions of the bpfman-operator and its components.
102+
// +optional
85103
// +patchMergeKey=type
86104
// +patchStrategy=merge
87105
// +listType=map
88106
// +listMapKey=type
107+
// +kubebuilder:validation:MaxItems=1023
89108
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
90109

91-
// components stores the status of all components.
110+
// components represents the operational status of each individual bpfman-operator component such as the deployed
111+
// DaemonSets.
92112
// +optional
93113
Components map[string]ConfigComponentStatus `json:"components,omitempty"`
94114
}
@@ -101,10 +121,14 @@ type ConfigList struct {
101121
Items []Config `json:"items"`
102122
}
103123

124+
// ConfigComponentStatus holds the status of a single Config component.
104125
type ConfigComponentStatus string
105126

106127
const (
107-
ConfigStatusUnknown ConfigComponentStatus = "Unknown"
128+
// ConfigStatusUnknown indicates the component state cannot be determined.
129+
ConfigStatusUnknown ConfigComponentStatus = "Unknown"
130+
// ConfigStatusProgressing indicates the component is being updated or reconciled.
108131
ConfigStatusProgressing ConfigComponentStatus = "Progressing"
109-
ConfigStatusReady ConfigComponentStatus = "Ready"
132+
// ConfigStatusReady indicates the component is fully operational and ready.
133+
ConfigStatusReady ConfigComponentStatus = "Ready"
110134
)

bundle/manifests/bpfman-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ metadata:
10121012
capabilities: Basic Install
10131013
categories: OpenShift Optional
10141014
containerImage: quay.io/bpfman/bpfman-operator:latest
1015-
createdAt: "2025-10-08T15:10:52Z"
1015+
createdAt: "2025-10-21T13:05:28Z"
10161016
description: The bpfman Operator is designed to manage eBPF programs for applications.
10171017
features.operators.openshift.io/cnf: "false"
10181018
features.operators.openshift.io/cni: "false"

bundle/manifests/bpfman.io_configs.yaml

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,59 +47,82 @@ spec:
4747
metadata:
4848
type: object
4949
spec:
50-
description: Spec defines the desired state of the bpfman-operator.
50+
description: spec defines the desired state of the bpfman-operator.
5151
properties:
5252
agent:
53-
description: Agent holds the configuration for the bpfman agent.
53+
description: agent specifies the configuration for the bpfman agent
54+
DaemonSet.
5455
properties:
5556
healthProbePort:
56-
default: 8175
57-
description: HealthProbePort holds the health probe bind port
58-
for the bpfman agent.
57+
description: |-
58+
healthProbePort specifies the port on which the bpfman agent's health probe endpoint will listen.
59+
If unspecified, the default port will be used.
60+
format: int32
5961
maximum: 65535
6062
minimum: 1
6163
type: integer
6264
image:
63-
description: Image holds the image for the bpfman agent.
65+
description: image specifies the container image for the bpfman
66+
agent DaemonSet.
67+
maxLength: 1023
6468
minLength: 1
6569
type: string
6670
logLevel:
67-
description: LogLevel holds the log level for the bpfman agent.
71+
description: |-
72+
logLevel specifies the verbosity of logs produced by the bpfman agent.
73+
Valid values are: "info", "debug", "trace".
74+
enum:
75+
- info
76+
- debug
77+
- trace
78+
maxLength: 256
79+
minLength: 1
6880
type: string
69-
required:
70-
- image
7181
type: object
7282
configuration:
73-
description: Configuration holds the content of bpfman.toml.
83+
description: configuration specifies the content of bpfman.toml configuration
84+
file used by the bpfman DaemonSet.
85+
maxLength: 65536
7486
minLength: 1
7587
type: string
7688
image:
77-
description: Image holds the image of the bpfman DaemonSets.
89+
description: image specifies the container image for the bpfman DaemonSet.
90+
maxLength: 1023
7891
minLength: 1
7992
type: string
8093
logLevel:
81-
description: LogLevel holds the log level for the bpfman-operator.
94+
description: |-
95+
logLevel specifies the log level for the bpfman DaemonSet via the RUST_LOG environment variable.
96+
The RUST_LOG environment variable controls logging with the syntax: RUST_LOG=[target][=][level][,...].
97+
For further information, see https://docs.rs/env_logger/latest/env_logger/.
98+
maxLength: 1024
99+
minLength: 1
82100
type: string
83101
namespace:
84102
description: |-
85-
Namespace holds the namespace where bpfman-operator resources shall be
86-
deployed.
103+
namespace specifies the namespace where bpfman-operator resources will be deployed.
104+
If not specified, resources will be deployed in the default bpfman namespace.
105+
maxLength: 256
106+
minLength: 1
87107
type: string
88108
required:
89-
- configuration
90-
- image
109+
- agent
91110
type: object
92111
status:
93-
description: status reflects the status of the bpfman-operator configuration.
112+
description: status reflects the observed state of the bpfman-operator.
94113
properties:
95114
components:
96115
additionalProperties:
116+
description: ConfigComponentStatus holds the status of a single
117+
Config component.
97118
type: string
98-
description: components stores the status of all components.
119+
description: |-
120+
components represents the operational status of each individual bpfman-operator component such as the deployed
121+
DaemonSets.
99122
type: object
100123
conditions:
101-
description: conditions store the status conditions of the bpfman-operator
102-
components.
124+
description: conditions represents the current state conditions of
125+
the bpfman-operator and its components.
103126
items:
104127
description: "Condition contains details for one aspect of the current
105128
state of this API Resource.\n---\nThis struct is intended for
@@ -167,11 +190,14 @@ spec:
167190
- status
168191
- type
169192
type: object
193+
maxItems: 1023
170194
type: array
171195
x-kubernetes-list-map-keys:
172196
- type
173197
x-kubernetes-list-type: map
174198
type: object
199+
required:
200+
- spec
175201
type: object
176202
served: true
177203
storage: true

config/crd/bases/bpfman.io_configs.yaml

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,59 +47,82 @@ spec:
4747
metadata:
4848
type: object
4949
spec:
50-
description: Spec defines the desired state of the bpfman-operator.
50+
description: spec defines the desired state of the bpfman-operator.
5151
properties:
5252
agent:
53-
description: Agent holds the configuration for the bpfman agent.
53+
description: agent specifies the configuration for the bpfman agent
54+
DaemonSet.
5455
properties:
5556
healthProbePort:
56-
default: 8175
57-
description: HealthProbePort holds the health probe bind port
58-
for the bpfman agent.
57+
description: |-
58+
healthProbePort specifies the port on which the bpfman agent's health probe endpoint will listen.
59+
If unspecified, the default port will be used.
60+
format: int32
5961
maximum: 65535
6062
minimum: 1
6163
type: integer
6264
image:
63-
description: Image holds the image for the bpfman agent.
65+
description: image specifies the container image for the bpfman
66+
agent DaemonSet.
67+
maxLength: 1023
6468
minLength: 1
6569
type: string
6670
logLevel:
67-
description: LogLevel holds the log level for the bpfman agent.
71+
description: |-
72+
logLevel specifies the verbosity of logs produced by the bpfman agent.
73+
Valid values are: "info", "debug", "trace".
74+
enum:
75+
- info
76+
- debug
77+
- trace
78+
maxLength: 256
79+
minLength: 1
6880
type: string
69-
required:
70-
- image
7181
type: object
7282
configuration:
73-
description: Configuration holds the content of bpfman.toml.
83+
description: configuration specifies the content of bpfman.toml configuration
84+
file used by the bpfman DaemonSet.
85+
maxLength: 65536
7486
minLength: 1
7587
type: string
7688
image:
77-
description: Image holds the image of the bpfman DaemonSets.
89+
description: image specifies the container image for the bpfman DaemonSet.
90+
maxLength: 1023
7891
minLength: 1
7992
type: string
8093
logLevel:
81-
description: LogLevel holds the log level for the bpfman-operator.
94+
description: |-
95+
logLevel specifies the log level for the bpfman DaemonSet via the RUST_LOG environment variable.
96+
The RUST_LOG environment variable controls logging with the syntax: RUST_LOG=[target][=][level][,...].
97+
For further information, see https://docs.rs/env_logger/latest/env_logger/.
98+
maxLength: 1024
99+
minLength: 1
82100
type: string
83101
namespace:
84102
description: |-
85-
Namespace holds the namespace where bpfman-operator resources shall be
86-
deployed.
103+
namespace specifies the namespace where bpfman-operator resources will be deployed.
104+
If not specified, resources will be deployed in the default bpfman namespace.
105+
maxLength: 256
106+
minLength: 1
87107
type: string
88108
required:
89-
- configuration
90-
- image
109+
- agent
91110
type: object
92111
status:
93-
description: status reflects the status of the bpfman-operator configuration.
112+
description: status reflects the observed state of the bpfman-operator.
94113
properties:
95114
components:
96115
additionalProperties:
116+
description: ConfigComponentStatus holds the status of a single
117+
Config component.
97118
type: string
98-
description: components stores the status of all components.
119+
description: |-
120+
components represents the operational status of each individual bpfman-operator component such as the deployed
121+
DaemonSets.
99122
type: object
100123
conditions:
101-
description: conditions store the status conditions of the bpfman-operator
102-
components.
124+
description: conditions represents the current state conditions of
125+
the bpfman-operator and its components.
103126
items:
104127
description: "Condition contains details for one aspect of the current
105128
state of this API Resource.\n---\nThis struct is intended for
@@ -167,11 +190,14 @@ spec:
167190
- status
168191
- type
169192
type: object
193+
maxItems: 1023
170194
type: array
171195
x-kubernetes-list-map-keys:
172196
- type
173197
x-kubernetes-list-type: map
174198
type: object
199+
required:
200+
- spec
175201
type: object
176202
served: true
177203
storage: true

controllers/bpfman-operator/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,12 @@ func (r *BpfmanConfigReconciler) handleDeletion(ctx context.Context, config *v1a
614614
return ctrl.Result{}, nil
615615
}
616616

617-
func healthProbeAddress(healthProbePort int) string {
618-
if healthProbePort <= 0 || healthProbePort > 65535 {
617+
func healthProbeAddress(healthProbePort int32) string {
618+
if healthProbePort < 0 || healthProbePort > 65535 {
619619
return ""
620620
}
621+
if healthProbePort == 0 {
622+
healthProbePort = internal.DefaultHealthProbePort
623+
}
621624
return fmt.Sprintf(":%d", healthProbePort)
622625
}

internal/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
BpfmanLogLevel = "bpfman.log.level"
4949
BpfmanAgentLogLevel = "bpfman.agent.log.level"
5050
BpfmanAgentHealthProbeAddress = "bpfman.agent.healthprobeaddr"
51+
DefaultHealthProbePort = 8175
5152
APIPrefix = "bpfman.io"
5253
)
5354

0 commit comments

Comments
 (0)