github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/machine_configuration.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 "github.com/go-openapi/validate" 14 ) 15 16 // MachineConfiguration Describes the number of vCPUs, memory size, Hyperthreading capabilities and the CPU template. 17 // swagger:model MachineConfiguration 18 type MachineConfiguration struct { 19 20 // cpu template 21 CPUTemplate CPUTemplate `json:"cpu_template,omitempty"` 22 23 // Flag for enabling/disabling Hyperthreading 24 // Required: true 25 HtEnabled *bool `json:"ht_enabled"` 26 27 // Memory size of VM 28 // Required: true 29 MemSizeMib *int64 `json:"mem_size_mib"` 30 31 // Number of vCPUs (either 1 or an even number) 32 // Required: true 33 // Maximum: 32 34 // Minimum: 1 35 VcpuCount *int64 `json:"vcpu_count"` 36 } 37 38 // Validate validates this machine configuration 39 func (m *MachineConfiguration) Validate(formats strfmt.Registry) error { 40 var res []error 41 42 if err := m.validateCPUTemplate(formats); err != nil { 43 res = append(res, err) 44 } 45 46 if err := m.validateHtEnabled(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if err := m.validateMemSizeMib(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateVcpuCount(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if len(res) > 0 { 59 return errors.CompositeValidationError(res...) 60 } 61 return nil 62 } 63 64 func (m *MachineConfiguration) validateCPUTemplate(formats strfmt.Registry) error { 65 66 if swag.IsZero(m.CPUTemplate) { // not required 67 return nil 68 } 69 70 if err := m.CPUTemplate.Validate(formats); err != nil { 71 if ve, ok := err.(*errors.Validation); ok { 72 return ve.ValidateName("cpu_template") 73 } 74 return err 75 } 76 77 return nil 78 } 79 80 func (m *MachineConfiguration) validateHtEnabled(formats strfmt.Registry) error { 81 82 if err := validate.Required("ht_enabled", "body", m.HtEnabled); err != nil { 83 return err 84 } 85 86 return nil 87 } 88 89 func (m *MachineConfiguration) validateMemSizeMib(formats strfmt.Registry) error { 90 91 if err := validate.Required("mem_size_mib", "body", m.MemSizeMib); err != nil { 92 return err 93 } 94 95 return nil 96 } 97 98 func (m *MachineConfiguration) validateVcpuCount(formats strfmt.Registry) error { 99 100 if err := validate.Required("vcpu_count", "body", m.VcpuCount); err != nil { 101 return err 102 } 103 104 if err := validate.MinimumInt("vcpu_count", "body", int64(*m.VcpuCount), 1, false); err != nil { 105 return err 106 } 107 108 if err := validate.MaximumInt("vcpu_count", "body", int64(*m.VcpuCount), 32, false); err != nil { 109 return err 110 } 111 112 return nil 113 } 114 115 // MarshalBinary interface implementation 116 func (m *MachineConfiguration) MarshalBinary() ([]byte, error) { 117 if m == nil { 118 return nil, nil 119 } 120 return swag.WriteJSON(m) 121 } 122 123 // UnmarshalBinary interface implementation 124 func (m *MachineConfiguration) UnmarshalBinary(b []byte) error { 125 var res MachineConfiguration 126 if err := swag.ReadJSON(b, &res); err != nil { 127 return err 128 } 129 *m = res 130 return nil 131 }