Skip to content

Commit 462c4ce

Browse files
authored
importify gke tests (#1204)
* importify gke tests * fix typo * add in missed tests after merge * remove import-specific tests * fixes based on tests that failed
1 parent 684029c commit 462c4ce

5 files changed

+355
-584
lines changed

google/import_container_cluster_test.go

-34
This file was deleted.

google/import_container_node_pool_test.go

-34
This file was deleted.

google/node_config.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func expandNodeConfig(v interface{}) *containerBeta.NodeConfig {
240240
nc.MinCpuPlatform = v.(string)
241241
}
242242

243-
if v, ok := nodeConfig["workload_metadata_config"]; ok {
243+
if v, ok := nodeConfig["workload_metadata_config"]; ok && len(v.([]interface{})) > 0 {
244244
conf := v.([]interface{})[0].(map[string]interface{})
245245
nc.WorkloadMetadataConfig = &containerBeta.WorkloadMetadataConfig{
246246
NodeMetadata: conf["node_metadata"].(string),
@@ -260,7 +260,7 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
260260
config = append(config, map[string]interface{}{
261261
"machine_type": c.MachineType,
262262
"disk_size_gb": c.DiskSizeGb,
263-
"guest_accelerator": c.Accelerators,
263+
"guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators),
264264
"local_ssd_count": c.LocalSsdCount,
265265
"service_account": c.ServiceAccount,
266266
"metadata": c.Metadata,
@@ -279,6 +279,17 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
279279
return config
280280
}
281281

282+
func flattenContainerGuestAccelerators(c []*containerBeta.AcceleratorConfig) []map[string]interface{} {
283+
result := []map[string]interface{}{}
284+
for _, accel := range c {
285+
result = append(result, map[string]interface{}{
286+
"count": accel.AcceleratorCount,
287+
"type": accel.AcceleratorType,
288+
})
289+
}
290+
return result
291+
}
292+
282293
func flattenWorkloadMetadataConfig(c *containerBeta.WorkloadMetadataConfig) []map[string]interface{} {
283294
result := []map[string]interface{}{}
284295
if c != nil {

0 commit comments

Comments
 (0)