Skip to content

Commit

Permalink
Migrate to CRD validation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Nov 8, 2024
1 parent 8d37e2d commit bc71558
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 706 deletions.
3 changes: 0 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,4 @@ resources:
kind: ServerClaim
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
version: v1alpha1
webhooks:
validation: true
webhookVersion: v1
version: "3"
5 changes: 5 additions & 0 deletions api/v1alpha1/bmc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ const (
)

// BMCSpec defines the desired state of BMC
// +kubebuilder:validation:XValidation:rule="has(self.access) != has(self.endpointRef)",message="exactly one of access or endpointRef needs to be set"
type BMCSpec struct {
// EndpointRef is a reference to the Kubernetes object that contains the endpoint information for the BMC.
// This reference is typically used to locate the BMC endpoint within the cluster.
// +optional
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="endpointRef is immutable"
EndpointRef *v1.LocalObjectReference `json:"endpointRef"`

// Endpoint allows inline configuration of network access details for the BMC.
// Use this field if access settings like address are to be configured directly within the BMC resource.
// +optional
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="access is immutable"
Endpoint *InlineEndpoint `json:"access,omitempty"`

// BMCSecretRef is a reference to the Kubernetes Secret object that contains the credentials
Expand Down
84 changes: 0 additions & 84 deletions api/v1alpha1/bmc_webhook.go

This file was deleted.

162 changes: 0 additions & 162 deletions api/v1alpha1/bmc_webhook_test.go

This file was deleted.

6 changes: 6 additions & 0 deletions api/v1alpha1/serverclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import (
)

// ServerClaimSpec defines the desired state of ServerClaim.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.serverRef) || has(self.serverRef)", message="serverRef is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.serverSelector) || has(self.serverSelector)", message="serverSelector is required once set"
type ServerClaimSpec struct {
// Power specifies the desired power state of the server.
Power Power `json:"power"`

// ServerRef is a reference to a specific server to be claimed.
// This field is optional and can be omitted if the server is to be selected using ServerSelector.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverRef is immutable"
ServerRef *v1.LocalObjectReference `json:"serverRef,omitempty"`

// ServerSelector specifies a label selector to identify the server to be claimed.
// This field is optional and can be omitted if a specific server is referenced using ServerRef.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverSelector is immutable"
ServerSelector *metav1.LabelSelector `json:"serverSelector,omitempty"`

// IgnitionSecretRef is a reference to the Kubernetes Secret object that contains
Expand Down
76 changes: 0 additions & 76 deletions api/v1alpha1/serverclaim_webhook.go

This file was deleted.

Loading

0 comments on commit bc71558

Please sign in to comment.