mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00: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"`
|
Ephemeral bool `json:"ephemeral"`
|
||||||
|
|
||||||
// Duration sets how long the setup key is valid for.
|
// Duration sets how long the setup key is valid for.
|
||||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="duration is immutable"
|
|
||||||
// +optional
|
// +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"`
|
Duration *metav1.Duration `json:"duration,omitempty"`
|
||||||
|
|
||||||
// AutoGroups are groups that will be automatically assigned to peers using setup key.
|
// AutoGroups are groups that will be automatically assigned to peers using setup key.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: netbird.io/v1alpha1
|
|||||||
kind: SetupKey
|
kind: SetupKey
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: test
|
||||||
namespace: netbird
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
name: test
|
name: test
|
||||||
|
ephemeral: true
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ spec:
|
|||||||
type: array
|
type: array
|
||||||
duration:
|
duration:
|
||||||
description: Duration sets how long the setup key is valid for.
|
description: Duration sets how long the setup key is valid for.
|
||||||
|
pattern: ^([0-9]+(\.[0-9]+)?(m|h))+$
|
||||||
type: string
|
type: string
|
||||||
x-kubernetes-validations:
|
x-kubernetes-validations:
|
||||||
- message: duration is immutable
|
- message: duration is immutable
|
||||||
|
|||||||
Reference in New Issue
Block a user