Skip to content

Commit e12916e

Browse files
committed
Make Config API compliant with OpenShift API standards
Update ConfigSpec and AgentSpec field documentation to follow OpenShift API conventions (lowercase first letter). Remove redundant kubebuilder validation tags and make HealthProbePort optional with a default value of 8175 applied via the controller instead of via the API. Signed-off-by: Andreas Karis <[email protected]>
1 parent e5feba2 commit e12916e

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

apis/v1alpha1/config_types.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,46 @@ type Config struct {
3838
Status ConfigStatus `json:"status,omitempty"`
3939
}
4040

41-
// Spec defines the desired state of the bpfman-operator.
41+
// spec defines the desired state of the bpfman-operator.
4242
type ConfigSpec struct {
43-
// Agent holds the configuration for the bpfman agent.
43+
// agent holds the configuration for the bpfman agent.
4444
// +required
45-
Agent AgentSpec `json:"agent,omitempty"`
46-
// Configuration holds the content of bpfman.toml.
45+
Agent AgentSpec `json:"agent"`
46+
// configuration holds the content of bpfman.toml.
4747
// +required
48-
// +kubebuilder:validation:Required
4948
// +kubebuilder:validation:MinLength=1
5049
Configuration string `json:"configuration"`
51-
// Image holds the image of the bpfman DaemonSets.
50+
// image sets the image of the bpfman DaemonSets.
5251
// +required
53-
// +kubebuilder:validation:Required
5452
// +kubebuilder:validation:MinLength=1
5553
Image string `json:"image"`
56-
// LogLevel holds the log level for the bpfman-operator.
54+
// logLevel sets the log level for the bpfman's DaemonSets via the RUST_LOG environment variable.
55+
// The RUST_LOG environment variable controls logging with the syntax: RUST_LOG=[target][=][level][,...].
56+
// For further information, see https://docs.rs/env_logger/latest/env_logger/.
5757
// +optional
5858
LogLevel string `json:"logLevel,omitempty"`
59-
// Namespace holds the namespace where bpfman-operator resources shall be
60-
// deployed.
59+
// namespace sets the namespace where bpfman-operator resources shall be
60+
// deployed. If not specified, resources will be deployed in the default
61+
// bpfman namespace.
62+
// +optional
6163
Namespace string `json:"namespace,omitempty"`
6264
}
6365

6466
// AgentSpec defines the desired state of the bpfman agent.
6567
type AgentSpec struct {
66-
// HealthProbePort holds the health probe bind port for the bpfman agent.
68+
// healthProbePort configures the health probe bind port for the bpfman agent.
69+
// If unspecified, the default port will be used.
6770
// +optional
68-
// +kubebuilder:default=8175
69-
// +kubebuilder:validation:Minimum=1
71+
// +kubebuilder:validation:Minimum=0
7072
// +kubebuilder:validation:Maximum=65535
71-
HealthProbePort int `json:"healthProbePort"`
72-
// Image holds the image for the bpfman agent.
73+
HealthProbePort int32 `json:"healthProbePort,omitempty"`
74+
// image holds the image for the bpfman agent.
7375
// +required
74-
// +kubebuilder:validation:Required
75-
// +kubebuilder:validation:MinLength=1
7676
Image string `json:"image"`
77-
// LogLevel holds the log level for the bpfman agent.
77+
// logLevel holds the log level for the bpfman agent.
78+
// Valid values are: "", "info", "debug", "trace".
7879
// +optional
80+
// +kubebuilder:validation:Enum="";info;debug;trace
7981
LogLevel string `json:"logLevel,omitempty"`
8082
}
8183

@@ -101,10 +103,14 @@ type ConfigList struct {
101103
Items []Config `json:"items"`
102104
}
103105

106+
// ConfigComponentStatus holds the status of a single Config component.
104107
type ConfigComponentStatus string
105108

106109
const (
107-
ConfigStatusUnknown ConfigComponentStatus = "Unknown"
110+
// ConfigStatusUnknown indicates the component state cannot be determined.
111+
ConfigStatusUnknown ConfigComponentStatus = "Unknown"
112+
// ConfigStatusProgressing indicates the component is being updated or reconciled.
108113
ConfigStatusProgressing ConfigComponentStatus = "Progressing"
109-
ConfigStatusReady ConfigComponentStatus = "Ready"
114+
// ConfigStatusReady indicates the component is fully operational and ready.
115+
ConfigStatusReady ConfigComponentStatus = "Ready"
110116
)

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)