fix array validation for global maintenance window and protected role names (#3120)
* change type of maintenance windows in config crd * fix default array type for protected role names
This commit is contained in:
parent
26af5a7900
commit
9030520e24
|
|
@ -706,6 +706,10 @@ spec:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
maintenance_windows:
|
maintenance_windows:
|
||||||
|
items:
|
||||||
|
pattern: ^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\
|
||||||
|
*$
|
||||||
|
type: string
|
||||||
type: array
|
type: array
|
||||||
major_version_upgrade:
|
major_version_upgrade:
|
||||||
description: MajorVersionUpgradeConfiguration defines how to execute
|
description: MajorVersionUpgradeConfiguration defines how to execute
|
||||||
|
|
@ -851,7 +855,9 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
protected_role_names:
|
protected_role_names:
|
||||||
default: '["admin", "cron_admin"]'
|
default:
|
||||||
|
- admin
|
||||||
|
- cron_admin
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
|
|
@ -706,6 +706,10 @@ spec:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
maintenance_windows:
|
maintenance_windows:
|
||||||
|
items:
|
||||||
|
pattern: ^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\
|
||||||
|
*$
|
||||||
|
type: string
|
||||||
type: array
|
type: array
|
||||||
major_version_upgrade:
|
major_version_upgrade:
|
||||||
description: MajorVersionUpgradeConfiguration defines how to execute
|
description: MajorVersionUpgradeConfiguration defines how to execute
|
||||||
|
|
@ -851,7 +855,9 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
protected_role_names:
|
protected_role_names:
|
||||||
default: '["admin", "cron_admin"]'
|
default:
|
||||||
|
- admin
|
||||||
|
- cron_admin
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ type TeamsAPIConfiguration struct {
|
||||||
PamRoleName string `json:"pam_role_name,omitempty"`
|
PamRoleName string `json:"pam_role_name,omitempty"`
|
||||||
// +kubebuilder:default="https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees"
|
// +kubebuilder:default="https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees"
|
||||||
PamConfiguration string `json:"pam_configuration,omitempty"`
|
PamConfiguration string `json:"pam_configuration,omitempty"`
|
||||||
// +kubebuilder:default="[\"admin\", \"cron_admin\"]"
|
// +kubebuilder:default={"admin", "cron_admin"}
|
||||||
ProtectedRoles []string `json:"protected_role_names,omitempty"`
|
ProtectedRoles []string `json:"protected_role_names,omitempty"`
|
||||||
PostgresSuperuserTeams []string `json:"postgres_superuser_teams,omitempty"`
|
PostgresSuperuserTeams []string `json:"postgres_superuser_teams,omitempty"`
|
||||||
// +kubebuilder:default=true
|
// +kubebuilder:default=true
|
||||||
|
|
@ -426,10 +426,10 @@ type OperatorConfigurationData struct {
|
||||||
RepairPeriod Duration `json:"repair_period,omitempty"`
|
RepairPeriod Duration `json:"repair_period,omitempty"`
|
||||||
// +kubebuilder:default=true
|
// +kubebuilder:default=true
|
||||||
EnableMaintenanceWindows *bool `json:"enable_maintenance_windows,omitempty"`
|
EnableMaintenanceWindows *bool `json:"enable_maintenance_windows,omitempty"`
|
||||||
// +kubebuilder:validation:Schemaless
|
|
||||||
// +kubebuilder:validation:Type=array
|
// +kubebuilder:validation:Type=array
|
||||||
MaintenanceWindows []MaintenanceWindow `json:"maintenance_windows,omitempty"`
|
// +kubebuilder:validation:items:Pattern=`^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ *$`
|
||||||
SetMemoryRequestToLimit bool `json:"set_memory_request_to_limit,omitempty"`
|
MaintenanceWindows []string `json:"maintenance_windows,omitempty"`
|
||||||
|
SetMemoryRequestToLimit bool `json:"set_memory_request_to_limit,omitempty"`
|
||||||
// +kubebuilder:default=true
|
// +kubebuilder:default=true
|
||||||
ShmVolume *bool `json:"enable_shm_volume,omitempty"`
|
ShmVolume *bool `json:"enable_shm_volume,omitempty"`
|
||||||
SidecarImages map[string]string `json:"sidecar_docker_images,omitempty"` // deprecated in favour of SidecarContainers
|
SidecarImages map[string]string `json:"sidecar_docker_images,omitempty"` // deprecated in favour of SidecarContainers
|
||||||
|
|
|
||||||
|
|
@ -706,6 +706,10 @@ spec:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
maintenance_windows:
|
maintenance_windows:
|
||||||
|
items:
|
||||||
|
pattern: ^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\
|
||||||
|
*$
|
||||||
|
type: string
|
||||||
type: array
|
type: array
|
||||||
major_version_upgrade:
|
major_version_upgrade:
|
||||||
description: MajorVersionUpgradeConfiguration defines how to execute
|
description: MajorVersionUpgradeConfiguration defines how to execute
|
||||||
|
|
@ -851,7 +855,9 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
protected_role_names:
|
protected_role_names:
|
||||||
default: '["admin", "cron_admin"]'
|
default:
|
||||||
|
- admin
|
||||||
|
- cron_admin
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
|
|
||||||
|
|
@ -440,10 +440,8 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData
|
||||||
}
|
}
|
||||||
if in.MaintenanceWindows != nil {
|
if in.MaintenanceWindows != nil {
|
||||||
in, out := &in.MaintenanceWindows, &out.MaintenanceWindows
|
in, out := &in.MaintenanceWindows, &out.MaintenanceWindows
|
||||||
*out = make([]MaintenanceWindow, len(*in))
|
*out = make([]string, len(*in))
|
||||||
for i := range *in {
|
copy(*out, *in)
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if in.ShmVolume != nil {
|
if in.ShmVolume != nil {
|
||||||
in, out := &in.ShmVolume, &out.ShmVolume
|
in, out := &in.ShmVolume, &out.ShmVolume
|
||||||
|
|
|
||||||
|
|
@ -51,16 +51,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||||
result.SidecarImages = fromCRD.SidecarImages
|
result.SidecarImages = fromCRD.SidecarImages
|
||||||
result.SidecarContainers = fromCRD.SidecarContainers
|
result.SidecarContainers = fromCRD.SidecarContainers
|
||||||
result.EnableMaintenanceWindows = util.CoalesceBool(fromCRD.EnableMaintenanceWindows, util.True())
|
result.EnableMaintenanceWindows = util.CoalesceBool(fromCRD.EnableMaintenanceWindows, util.True())
|
||||||
if len(fromCRD.MaintenanceWindows) > 0 {
|
result.MaintenanceWindows = fromCRD.MaintenanceWindows
|
||||||
result.MaintenanceWindows = make([]string, 0, len(fromCRD.MaintenanceWindows))
|
|
||||||
for _, window := range fromCRD.MaintenanceWindows {
|
|
||||||
w, err := window.MarshalJSON()
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("could not marshal configured maintenance window: %v", err))
|
|
||||||
}
|
|
||||||
result.MaintenanceWindows = append(result.MaintenanceWindows, string(w))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// user config
|
// user config
|
||||||
result.SuperUsername = util.Coalesce(fromCRD.PostgresUsersConfiguration.SuperUsername, "postgres")
|
result.SuperUsername = util.Coalesce(fromCRD.PostgresUsersConfiguration.SuperUsername, "postgres")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue