Skip to content

Commit 6e57cd7

Browse files
committed
2 parents 39a3e97 + 602278b commit 6e57cd7

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

mmv1/third_party/tgc_next/pkg/services/container/node_config.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package container
22

33
import (
4+
"strconv"
45
"strings"
56

67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -1054,6 +1055,36 @@ func schemaNodeConfig() *schema.Schema {
10541055
},
10551056
},
10561057
},
1058+
"dedicated_local_ssd_profile": {
1059+
Type: schema.TypeList,
1060+
Optional: true,
1061+
MaxItems: 1,
1062+
Description: `Swap disk profile for dedicated local SSD`,
1063+
Elem: &schema.Resource{
1064+
Schema: map[string]*schema.Schema{
1065+
"disk_count": {
1066+
Type: schema.TypeInt,
1067+
Optional: true,
1068+
Description: `Disk count`,
1069+
},
1070+
},
1071+
},
1072+
},
1073+
"ephemeral_local_ssd_profile": {
1074+
Type: schema.TypeList,
1075+
Optional: true,
1076+
MaxItems: 1,
1077+
Description: `Swap disk profile for ephemeral local SSD`,
1078+
Elem: &schema.Resource{
1079+
Schema: map[string]*schema.Schema{
1080+
"swap_size_gib": {
1081+
Type: schema.TypeInt,
1082+
Optional: true,
1083+
Description: `Swap size in GiB`,
1084+
},
1085+
},
1086+
},
1087+
},
10571088
},
10581089
},
10591090
},
@@ -2024,9 +2055,55 @@ func expandSwapConfig(v interface{}) *container.SwapConfig {
20242055
if v, ok := cfg["boot_disk_profile"]; ok {
20252056
swapConfig.BootDiskProfile = expandBootDiskProfile(v)
20262057
}
2058+
if v, ok := cfg["dedicated_local_ssd_profile"]; ok {
2059+
swapConfig.DedicatedLocalSsdProfile = expandDedicatedLocalSsdProfile(v)
2060+
}
2061+
if v, ok := cfg["ephemeral_local_ssd_profile"]; ok {
2062+
swapConfig.EphemeralLocalSsdProfile = expandEphemeralLocalSsdProfile(v)
2063+
}
20272064
return swapConfig
20282065
}
20292066

2067+
func expandEphemeralLocalSsdProfile(v interface{}) *container.EphemeralLocalSsdProfile {
2068+
if v == nil {
2069+
return nil
2070+
}
2071+
ls := v.([]interface{})
2072+
if len(ls) == 0 {
2073+
return nil
2074+
}
2075+
if ls[0] == nil {
2076+
return &container.EphemeralLocalSsdProfile{}
2077+
}
2078+
cfg := ls[0].(map[string]interface{})
2079+
2080+
profile := &container.EphemeralLocalSsdProfile{}
2081+
if v, ok := cfg["swap_size_gib"]; ok {
2082+
profile.SwapSizeGib = int64(v.(int))
2083+
}
2084+
return profile
2085+
}
2086+
2087+
func expandDedicatedLocalSsdProfile(v interface{}) *container.DedicatedLocalSsdProfile {
2088+
if v == nil {
2089+
return nil
2090+
}
2091+
ls := v.([]interface{})
2092+
if len(ls) == 0 {
2093+
return nil
2094+
}
2095+
if ls[0] == nil {
2096+
return &container.DedicatedLocalSsdProfile{}
2097+
}
2098+
cfg := ls[0].(map[string]interface{})
2099+
2100+
profile := &container.DedicatedLocalSsdProfile{}
2101+
if v, ok := cfg["disk_count"]; ok {
2102+
profile.DiskCount = int64(v.(int))
2103+
}
2104+
return profile
2105+
}
2106+
20302107
func expandBootDiskProfile(v interface{}) *container.BootDiskProfile {
20312108
if v == nil {
20322109
return nil
@@ -3117,6 +3194,32 @@ func flattenSwapConfig(v interface{}) []map[string]interface{} {
31173194
},
31183195
}
31193196
}
3197+
if dlsp, ok := c["dedicatedLocalSsdProfile"].(map[string]interface{}); ok {
3198+
diskCount := dlsp["diskCount"]
3199+
if strCount, ok := diskCount.(string); ok {
3200+
if intCount, err := strconv.Atoi(strCount); err == nil {
3201+
diskCount = intCount
3202+
}
3203+
}
3204+
transformed["dedicated_local_ssd_profile"] = []map[string]interface{}{
3205+
{
3206+
"disk_count": diskCount,
3207+
},
3208+
}
3209+
}
3210+
if elsp, ok := c["ephemeralLocalSsdProfile"].(map[string]interface{}); ok {
3211+
swapSizeGib := elsp["swapSizeGib"]
3212+
if strSize, ok := swapSizeGib.(string); ok {
3213+
if intSize, err := strconv.Atoi(strSize); err == nil {
3214+
swapSizeGib = intSize
3215+
}
3216+
}
3217+
transformed["ephemeral_local_ssd_profile"] = []map[string]interface{}{
3218+
{
3219+
"swap_size_gib": swapSizeGib,
3220+
},
3221+
}
3222+
}
31203223
return []map[string]interface{}{transformed}
31213224
}
31223225

0 commit comments

Comments
 (0)