-
Notifications
You must be signed in to change notification settings - Fork 16
Add BMCUserSet type and controller implementation
#662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
157f2d5
cfa5612
ee6f5f3
6e0ea42
887644c
067ff87
82d412b
26779f3
389f8b8
c41e0da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // BMCUserTemplate defines the template for the BMCUser Resource to be applied to the BMCs. | ||
| type BMCUserTemplate struct { | ||
| // Username of the BMC user. | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| UserName string `json:"userName"` | ||
| // RoleID is the ID of the role to assign to the user. | ||
| // The available roles depend on the BMC implementation. | ||
| // For Redfish, common role IDs are "Administrator", "Operator", "ReadOnly". | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| RoleID string `json:"roleID"` | ||
| // Description is an optional description for the BMC user. | ||
| Description string `json:"description,omitempty"` | ||
| // RotationPeriod defines how often the password should be rotated. | ||
| // if not set, the password will not be rotated. | ||
| RotationPeriod *metav1.Duration `json:"rotationPeriod,omitempty"` | ||
| // BMCSecretRef references the BMCSecret containing the credentials for this user. | ||
| // If not set, the operator will generate a secure password based on BMC manufacturer requirements. | ||
| BMCSecretRef *corev1.LocalObjectReference `json:"bmcSecretRef,omitempty"` | ||
| } | ||
|
|
||
| // BMCUserSetSpec defines the desired state of BMCUserSet. | ||
| type BMCUserSetSpec struct { | ||
| // BMCSelector specifies a label selector to identify the BMCs that are to be selected. | ||
| // +required | ||
| BMCSelector metav1.LabelSelector `json:"bmcSelector"` | ||
|
|
||
| // BMCUserTemplate defines the template for the BMCUser Resource to be applied to the BMCs. | ||
| // +required | ||
| BMCUserTemplate BMCUserTemplate `json:"bmcUserTemplate"` | ||
| } | ||
|
|
||
| // BMCUserSetStatus defines the observed state of BMCUserSet. | ||
| type BMCUserSetStatus struct { | ||
| // FullyLabeledBMCs is the number of BMC in the set. | ||
| FullyLabeledBMCs int32 `json:"fullyLabeledBMCs,omitempty"` | ||
| // AvailableBMCUsers is the number of BMCUsers currently created by the set. | ||
| AvailableBMCUsers int32 `json:"availableBMCUsers,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:scope=Cluster | ||
| // +kubebuilder:printcolumn:name="UserName",type=string,JSONPath=`.spec.bmcUserTemplate.userName` | ||
| // +kubebuilder:printcolumn:name="RoleID",type=string,JSONPath=`.spec.bmcUserTemplate.roleID` | ||
| // +kubebuilder:printcolumn:name="TotalBMCs",type="integer",JSONPath=`.status.fullyLabeledBMCs` | ||
| // +kubebuilder:printcolumn:name="AvailableBMCUsers",type="integer",JSONPath=`.status.availableBMCUsers` | ||
| // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
|
|
||
| // BMCUserSet is the Schema for the bmcusersets API. | ||
| type BMCUserSet struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec BMCUserSetSpec `json:"spec,omitempty"` | ||
| Status BMCUserSetStatus `json:"status,omitempty"` | ||
|
Comment on lines
+62
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the root
Suggested fix- Spec BMCUserSetSpec `json:"spec,omitempty"`
+ // +required
+ Spec BMCUserSetSpec `json:"spec"`
Status BMCUserSetStatus `json:"status,omitempty"`Based on learnings: "When a Kubernetes controller (reconciler) errors out and does not proceed if a CRD spec field is nil/empty, that field should not be treated as optional in the API schema." 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // BMCUserSetList contains a list of BMCUserSet. | ||
| type BMCUserSetList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []BMCUserSet `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&BMCUserSet{}, &BMCUserSetList{}) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.