|
1 | 1 | package container |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "strconv" |
4 | 5 | "strings" |
5 | 6 |
|
6 | 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
@@ -1054,6 +1055,36 @@ func schemaNodeConfig() *schema.Schema { |
1054 | 1055 | }, |
1055 | 1056 | }, |
1056 | 1057 | }, |
| 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 | + }, |
1057 | 1088 | }, |
1058 | 1089 | }, |
1059 | 1090 | }, |
@@ -2024,9 +2055,55 @@ func expandSwapConfig(v interface{}) *container.SwapConfig { |
2024 | 2055 | if v, ok := cfg["boot_disk_profile"]; ok { |
2025 | 2056 | swapConfig.BootDiskProfile = expandBootDiskProfile(v) |
2026 | 2057 | } |
| 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 | + } |
2027 | 2064 | return swapConfig |
2028 | 2065 | } |
2029 | 2066 |
|
| 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 | + |
2030 | 2107 | func expandBootDiskProfile(v interface{}) *container.BootDiskProfile { |
2031 | 2108 | if v == nil { |
2032 | 2109 | return nil |
@@ -3117,6 +3194,32 @@ func flattenSwapConfig(v interface{}) []map[string]interface{} { |
3117 | 3194 | }, |
3118 | 3195 | } |
3119 | 3196 | } |
| 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 | + } |
3120 | 3223 | return []map[string]interface{}{transformed} |
3121 | 3224 | } |
3122 | 3225 |
|
|
0 commit comments