Skip to content

Commit fab5577

Browse files
FrankYang0529github-actions[bot]
authored andcommitted
feat: add reserved memory field (#1510)
Signed-off-by: PoAn Yang <poan.yang@suse.com> (cherry picked from commit c1b4fa0)
1 parent 502e648 commit fab5577

2 files changed

Lines changed: 31 additions & 17 deletions

File tree

rancher2/schema_machine_config_v2_harvester.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func machineConfigV2HarvesterFields() map[string]*schema.Schema {
3030
Default: "4",
3131
Description: "Memory size (in GiB)",
3232
},
33+
"reserved_memory_size": {
34+
Type: schema.TypeString,
35+
Optional: true,
36+
Description: "Reserved memory size (in MiB)",
37+
},
3338
"disk_size": {
3439
Type: schema.TypeString,
3540
Optional: true,

rancher2/structure_machine_config_v2_harvester.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@ const (
1515
//Types
1616

1717
type machineConfigV2Harvester struct {
18-
metav1.TypeMeta `json:",inline"`
19-
metav1.ObjectMeta `json:"metadata,omitempty"`
20-
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
21-
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
22-
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
23-
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
24-
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
25-
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
26-
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
27-
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
28-
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
29-
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
30-
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
31-
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
32-
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
33-
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
34-
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
18+
metav1.TypeMeta `json:",inline"`
19+
metav1.ObjectMeta `json:"metadata,omitempty"`
20+
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
21+
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
22+
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
23+
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
24+
ReservedMemorySize string `json:"reservedMemorySize,omitempty" yaml:"reservedMemorySize,omitempty"`
25+
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
26+
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
27+
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
28+
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
29+
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
30+
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
31+
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
32+
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
33+
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
34+
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
35+
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
3536
}
3637

3738
type MachineConfigV2Harvester struct {
@@ -64,6 +65,10 @@ func flattenMachineConfigV2Harvester(in *MachineConfigV2Harvester) []interface{}
6465
obj["memory_size"] = in.MemorySize
6566
}
6667

68+
if len(in.ReservedMemorySize) > 0 {
69+
obj["reserved_memory_size"] = in.ReservedMemorySize
70+
}
71+
6772
if len(in.DiskSize) > 0 {
6873
obj["disk_size"] = in.DiskSize
6974
}
@@ -145,6 +150,10 @@ func expandMachineConfigV2Harvester(p []interface{}, source *MachineConfigV2) *M
145150
obj.MemorySize = v
146151
}
147152

153+
if v, ok := in["reserved_memory_size"].(string); ok && len(v) > 0 {
154+
obj.ReservedMemorySize = v
155+
}
156+
148157
if v, ok := in["disk_size"].(string); ok && len(v) > 0 {
149158
obj.DiskSize = v
150159
}

0 commit comments

Comments
 (0)