mirror of
https://github.com/netbirdio/kubernetes-operator.git
synced 2026-05-22 17:11:40 -07:00
Add validation of setup key duration (#199)
This adds more validation to the setup key duration to make sure the unit and format is correct.
This commit is contained in:
@@ -15,8 +15,10 @@ type SetupKeySpec struct {
|
||||
Ephemeral bool `json:"ephemeral"`
|
||||
|
||||
// Duration sets how long the setup key is valid for.
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="duration is immutable"
|
||||
// +optional
|
||||
// +kubebuilder:validation:Type=string
|
||||
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(m|h))+$"
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="duration is immutable"
|
||||
Duration *metav1.Duration `json:"duration,omitempty"`
|
||||
|
||||
// AutoGroups are groups that will be automatically assigned to peers using setup key.
|
||||
|
||||
@@ -2,6 +2,7 @@ apiVersion: netbird.io/v1alpha1
|
||||
kind: SetupKey
|
||||
metadata:
|
||||
name: test
|
||||
namespace: netbird
|
||||
namespace: default
|
||||
spec:
|
||||
name: test
|
||||
ephemeral: true
|
||||
|
||||
@@ -77,6 +77,7 @@ spec:
|
||||
type: array
|
||||
duration:
|
||||
description: Duration sets how long the setup key is valid for.
|
||||
pattern: ^([0-9]+(\.[0-9]+)?(m|h))+$
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: duration is immutable
|
||||
|
||||
Reference in New Issue
Block a user