From 81f1939aea741ed84c47813b0972e09c0ac80e1d Mon Sep 17 00:00:00 2001 From: Gerrit Date: Fri, 31 May 2024 11:21:36 +0200 Subject: [PATCH] Firewall auto updates (#118) * Firewall image auto updates. * Update spec. --- api/models/models_v1_machine_hardware.go | 128 ++++++++++++++++++ api/models/models_v1_metal_cpu.go | 122 +++++++++++++++++ api/models/models_v1_metal_g_p_u.go | 88 ++++++++++++ api/models/models_v1_size_constraint.go | 35 +---- api/models/v1_maintenance_auto_update.go | 17 +++ ...n.go => v1beta1_observability_rotation.go} | 20 +-- .../v1beta1_shoot_credentials_rotation.go | 2 +- cloud-api.json | 83 ++++++++++-- 8 files changed, 441 insertions(+), 54 deletions(-) create mode 100644 api/models/models_v1_metal_cpu.go create mode 100644 api/models/models_v1_metal_g_p_u.go rename api/models/{v1beta1_shoot_observability_rotation.go => v1beta1_observability_rotation.go} (50%) diff --git a/api/models/models_v1_machine_hardware.go b/api/models/models_v1_machine_hardware.go index f57a296..30249ce 100644 --- a/api/models/models_v1_machine_hardware.go +++ b/api/models/models_v1_machine_hardware.go @@ -24,10 +24,18 @@ type ModelsV1MachineHardware struct { // Required: true CPUCores *int32 `json:"cpu_cores"` + // cpus + // Required: true + Cpus []*ModelsV1MetalCPU `json:"cpus"` + // disks // Required: true Disks []*ModelsV1MachineBlockDevice `json:"disks"` + // gpus + // Required: true + Gpus []*ModelsV1MetalGPU `json:"gpus"` + // memory // Required: true Memory *int64 `json:"memory"` @@ -45,10 +53,18 @@ func (m *ModelsV1MachineHardware) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCpus(formats); err != nil { + res = append(res, err) + } + if err := m.validateDisks(formats); err != nil { res = append(res, err) } + if err := m.validateGpus(formats); err != nil { + res = append(res, err) + } + if err := m.validateMemory(formats); err != nil { res = append(res, err) } @@ -72,6 +88,33 @@ func (m *ModelsV1MachineHardware) validateCPUCores(formats strfmt.Registry) erro return nil } +func (m *ModelsV1MachineHardware) validateCpus(formats strfmt.Registry) error { + + if err := validate.Required("cpus", "body", m.Cpus); err != nil { + return err + } + + for i := 0; i < len(m.Cpus); i++ { + if swag.IsZero(m.Cpus[i]) { // not required + continue + } + + if m.Cpus[i] != nil { + if err := m.Cpus[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cpus" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cpus" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *ModelsV1MachineHardware) validateDisks(formats strfmt.Registry) error { if err := validate.Required("disks", "body", m.Disks); err != nil { @@ -99,6 +142,33 @@ func (m *ModelsV1MachineHardware) validateDisks(formats strfmt.Registry) error { return nil } +func (m *ModelsV1MachineHardware) validateGpus(formats strfmt.Registry) error { + + if err := validate.Required("gpus", "body", m.Gpus); err != nil { + return err + } + + for i := 0; i < len(m.Gpus); i++ { + if swag.IsZero(m.Gpus[i]) { // not required + continue + } + + if m.Gpus[i] != nil { + if err := m.Gpus[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gpus" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gpus" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *ModelsV1MachineHardware) validateMemory(formats strfmt.Registry) error { if err := validate.Required("memory", "body", m.Memory); err != nil { @@ -139,10 +209,18 @@ func (m *ModelsV1MachineHardware) validateNics(formats strfmt.Registry) error { func (m *ModelsV1MachineHardware) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateCpus(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateDisks(ctx, formats); err != nil { res = append(res, err) } + if err := m.contextValidateGpus(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateNics(ctx, formats); err != nil { res = append(res, err) } @@ -153,6 +231,31 @@ func (m *ModelsV1MachineHardware) ContextValidate(ctx context.Context, formats s return nil } +func (m *ModelsV1MachineHardware) contextValidateCpus(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Cpus); i++ { + + if m.Cpus[i] != nil { + + if swag.IsZero(m.Cpus[i]) { // not required + return nil + } + + if err := m.Cpus[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cpus" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cpus" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *ModelsV1MachineHardware) contextValidateDisks(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Disks); i++ { @@ -178,6 +281,31 @@ func (m *ModelsV1MachineHardware) contextValidateDisks(ctx context.Context, form return nil } +func (m *ModelsV1MachineHardware) contextValidateGpus(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Gpus); i++ { + + if m.Gpus[i] != nil { + + if swag.IsZero(m.Gpus[i]) { // not required + return nil + } + + if err := m.Gpus[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("gpus" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("gpus" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *ModelsV1MachineHardware) contextValidateNics(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Nics); i++ { diff --git a/api/models/models_v1_metal_cpu.go b/api/models/models_v1_metal_cpu.go new file mode 100644 index 0000000..73fb0f2 --- /dev/null +++ b/api/models/models_v1_metal_cpu.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ModelsV1MetalCPU models v1 metal CPU +// +// swagger:model models.V1MetalCPU +type ModelsV1MetalCPU struct { + + // cores + // Required: true + Cores *int64 `json:"cores"` + + // model + // Required: true + Model *string `json:"model"` + + // threads + // Required: true + Threads *int64 `json:"threads"` + + // vendor + // Required: true + Vendor *string `json:"vendor"` +} + +// Validate validates this models v1 metal CPU +func (m *ModelsV1MetalCPU) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCores(formats); err != nil { + res = append(res, err) + } + + if err := m.validateModel(formats); err != nil { + res = append(res, err) + } + + if err := m.validateThreads(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVendor(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ModelsV1MetalCPU) validateCores(formats strfmt.Registry) error { + + if err := validate.Required("cores", "body", m.Cores); err != nil { + return err + } + + return nil +} + +func (m *ModelsV1MetalCPU) validateModel(formats strfmt.Registry) error { + + if err := validate.Required("model", "body", m.Model); err != nil { + return err + } + + return nil +} + +func (m *ModelsV1MetalCPU) validateThreads(formats strfmt.Registry) error { + + if err := validate.Required("threads", "body", m.Threads); err != nil { + return err + } + + return nil +} + +func (m *ModelsV1MetalCPU) validateVendor(formats strfmt.Registry) error { + + if err := validate.Required("vendor", "body", m.Vendor); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this models v1 metal CPU based on context it is used +func (m *ModelsV1MetalCPU) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ModelsV1MetalCPU) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ModelsV1MetalCPU) UnmarshalBinary(b []byte) error { + var res ModelsV1MetalCPU + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/models_v1_metal_g_p_u.go b/api/models/models_v1_metal_g_p_u.go new file mode 100644 index 0000000..31e7d82 --- /dev/null +++ b/api/models/models_v1_metal_g_p_u.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ModelsV1MetalGPU models v1 metal g p u +// +// swagger:model models.V1MetalGPU +type ModelsV1MetalGPU struct { + + // model + // Required: true + Model *string `json:"model"` + + // vendor + // Required: true + Vendor *string `json:"vendor"` +} + +// Validate validates this models v1 metal g p u +func (m *ModelsV1MetalGPU) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateModel(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVendor(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ModelsV1MetalGPU) validateModel(formats strfmt.Registry) error { + + if err := validate.Required("model", "body", m.Model); err != nil { + return err + } + + return nil +} + +func (m *ModelsV1MetalGPU) validateVendor(formats strfmt.Registry) error { + + if err := validate.Required("vendor", "body", m.Vendor); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this models v1 metal g p u based on context it is used +func (m *ModelsV1MetalGPU) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ModelsV1MetalGPU) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ModelsV1MetalGPU) UnmarshalBinary(b []byte) error { + var res ModelsV1MetalGPU + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/models/models_v1_size_constraint.go b/api/models/models_v1_size_constraint.go index 187f237..2373cae 100644 --- a/api/models/models_v1_size_constraint.go +++ b/api/models/models_v1_size_constraint.go @@ -19,13 +19,14 @@ import ( // swagger:model models.V1SizeConstraint type ModelsV1SizeConstraint struct { + // identifier + Identifier string `json:"identifier,omitempty"` + // max - // Required: true - Max *int64 `json:"max"` + Max int64 `json:"max,omitempty"` // min - // Required: true - Min *int64 `json:"min"` + Min int64 `json:"min,omitempty"` // type // Required: true @@ -36,14 +37,6 @@ type ModelsV1SizeConstraint struct { func (m *ModelsV1SizeConstraint) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateMax(formats); err != nil { - res = append(res, err) - } - - if err := m.validateMin(formats); err != nil { - res = append(res, err) - } - if err := m.validateType(formats); err != nil { res = append(res, err) } @@ -54,24 +47,6 @@ func (m *ModelsV1SizeConstraint) Validate(formats strfmt.Registry) error { return nil } -func (m *ModelsV1SizeConstraint) validateMax(formats strfmt.Registry) error { - - if err := validate.Required("max", "body", m.Max); err != nil { - return err - } - - return nil -} - -func (m *ModelsV1SizeConstraint) validateMin(formats strfmt.Registry) error { - - if err := validate.Required("min", "body", m.Min); err != nil { - return err - } - - return nil -} - func (m *ModelsV1SizeConstraint) validateType(formats strfmt.Registry) error { if err := validate.Required("type", "body", m.Type); err != nil { diff --git a/api/models/v1_maintenance_auto_update.go b/api/models/v1_maintenance_auto_update.go index 57c4c79..a487914 100644 --- a/api/models/v1_maintenance_auto_update.go +++ b/api/models/v1_maintenance_auto_update.go @@ -19,6 +19,10 @@ import ( // swagger:model v1.MaintenanceAutoUpdate type V1MaintenanceAutoUpdate struct { + // firewall image + // Required: true + FirewallImage *bool `json:"FirewallImage"` + // kubernetes version // Required: true KubernetesVersion *bool `json:"KubernetesVersion"` @@ -32,6 +36,10 @@ type V1MaintenanceAutoUpdate struct { func (m *V1MaintenanceAutoUpdate) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateFirewallImage(formats); err != nil { + res = append(res, err) + } + if err := m.validateKubernetesVersion(formats); err != nil { res = append(res, err) } @@ -46,6 +54,15 @@ func (m *V1MaintenanceAutoUpdate) Validate(formats strfmt.Registry) error { return nil } +func (m *V1MaintenanceAutoUpdate) validateFirewallImage(formats strfmt.Registry) error { + + if err := validate.Required("FirewallImage", "body", m.FirewallImage); err != nil { + return err + } + + return nil +} + func (m *V1MaintenanceAutoUpdate) validateKubernetesVersion(formats strfmt.Registry) error { if err := validate.Required("KubernetesVersion", "body", m.KubernetesVersion); err != nil { diff --git a/api/models/v1beta1_shoot_observability_rotation.go b/api/models/v1beta1_observability_rotation.go similarity index 50% rename from api/models/v1beta1_shoot_observability_rotation.go rename to api/models/v1beta1_observability_rotation.go index 35cd170..e40a8ed 100644 --- a/api/models/v1beta1_shoot_observability_rotation.go +++ b/api/models/v1beta1_observability_rotation.go @@ -12,10 +12,10 @@ import ( "github.com/go-openapi/swag" ) -// V1beta1ShootObservabilityRotation v1beta1 shoot observability rotation +// V1beta1ObservabilityRotation v1beta1 observability rotation // -// swagger:model v1beta1.ShootObservabilityRotation -type V1beta1ShootObservabilityRotation struct { +// swagger:model v1beta1.ObservabilityRotation +type V1beta1ObservabilityRotation struct { // last completion time LastCompletionTime string `json:"lastCompletionTime,omitempty"` @@ -24,18 +24,18 @@ type V1beta1ShootObservabilityRotation struct { LastInitiationTime string `json:"lastInitiationTime,omitempty"` } -// Validate validates this v1beta1 shoot observability rotation -func (m *V1beta1ShootObservabilityRotation) Validate(formats strfmt.Registry) error { +// Validate validates this v1beta1 observability rotation +func (m *V1beta1ObservabilityRotation) Validate(formats strfmt.Registry) error { return nil } -// ContextValidate validates this v1beta1 shoot observability rotation based on context it is used -func (m *V1beta1ShootObservabilityRotation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validates this v1beta1 observability rotation based on context it is used +func (m *V1beta1ObservabilityRotation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation -func (m *V1beta1ShootObservabilityRotation) MarshalBinary() ([]byte, error) { +func (m *V1beta1ObservabilityRotation) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -43,8 +43,8 @@ func (m *V1beta1ShootObservabilityRotation) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *V1beta1ShootObservabilityRotation) UnmarshalBinary(b []byte) error { - var res V1beta1ShootObservabilityRotation +func (m *V1beta1ObservabilityRotation) UnmarshalBinary(b []byte) error { + var res V1beta1ObservabilityRotation if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/api/models/v1beta1_shoot_credentials_rotation.go b/api/models/v1beta1_shoot_credentials_rotation.go index 29094e3..aa96081 100644 --- a/api/models/v1beta1_shoot_credentials_rotation.go +++ b/api/models/v1beta1_shoot_credentials_rotation.go @@ -28,7 +28,7 @@ type V1beta1ShootCredentialsRotation struct { Kubeconfig *V1beta1ShootKubeconfigRotation `json:"kubeconfig,omitempty"` // observability - Observability *V1beta1ShootObservabilityRotation `json:"observability,omitempty"` + Observability *V1beta1ObservabilityRotation `json:"observability,omitempty"` // service account key ServiceAccountKey *V1beta1ServiceAccountKeyRotation `json:"serviceAccountKey,omitempty"` diff --git a/cloud-api.json b/cloud-api.json index 3d4982c..8b8d8db 100644 --- a/cloud-api.json +++ b/cloud-api.json @@ -634,12 +634,24 @@ "format": "int32", "type": "integer" }, + "cpus": { + "items": { + "$ref": "#/definitions/models.V1MetalCPU" + }, + "type": "array" + }, "disks": { "items": { "$ref": "#/definitions/models.V1MachineBlockDevice" }, "type": "array" }, + "gpus": { + "items": { + "$ref": "#/definitions/models.V1MetalGPU" + }, + "type": "array" + }, "memory": { "format": "int64", "type": "integer" @@ -653,7 +665,9 @@ }, "required": [ "cpu_cores", + "cpus", "disks", + "gpus", "memory", "nics" ] @@ -887,6 +901,44 @@ "connected" ] }, + "models.V1MetalCPU": { + "properties": { + "cores": { + "format": "int64", + "type": "integer" + }, + "model": { + "type": "string" + }, + "threads": { + "format": "int64", + "type": "integer" + }, + "vendor": { + "type": "string" + } + }, + "required": [ + "cores", + "model", + "threads", + "vendor" + ] + }, + "models.V1MetalGPU": { + "properties": { + "model": { + "type": "string" + }, + "vendor": { + "type": "string" + } + }, + "required": [ + "model", + "vendor" + ] + }, "models.V1PartitionBootConfiguration": { "properties": { "commandline": { @@ -974,6 +1026,9 @@ }, "models.V1SizeConstraint": { "properties": { + "identifier": { + "type": "string" + }, "max": { "format": "int64", "type": "integer" @@ -987,8 +1042,6 @@ } }, "required": [ - "max", - "min", "type" ] }, @@ -2965,6 +3018,9 @@ }, "v1.MaintenanceAutoUpdate": { "properties": { + "FirewallImage": { + "type": "boolean" + }, "KubernetesVersion": { "type": "boolean" }, @@ -2973,6 +3029,7 @@ } }, "required": [ + "FirewallImage", "KubernetesVersion", "MachineImage" ] @@ -6008,6 +6065,16 @@ "type" ] }, + "v1beta1.ObservabilityRotation": { + "properties": { + "lastCompletionTime": { + "type": "string" + }, + "lastInitiationTime": { + "type": "string" + } + } + }, "v1beta1.ServiceAccountKeyRotation": { "properties": { "lastCompletionTime": { @@ -6063,7 +6130,7 @@ "$ref": "#/definitions/v1beta1.ShootKubeconfigRotation" }, "observability": { - "$ref": "#/definitions/v1beta1.ShootObservabilityRotation" + "$ref": "#/definitions/v1beta1.ObservabilityRotation" }, "serviceAccountKey": { "$ref": "#/definitions/v1beta1.ServiceAccountKeyRotation" @@ -6083,16 +6150,6 @@ } } }, - "v1beta1.ShootObservabilityRotation": { - "properties": { - "lastCompletionTime": { - "type": "string" - }, - "lastInitiationTime": { - "type": "string" - } - } - }, "v1beta1.ShootSSHKeypairRotation": { "properties": { "lastCompletionTime": {