Skip to content

Commit

Permalink
importify gke tests (hashicorp#1204)
Browse files Browse the repository at this point in the history
* importify gke tests

* fix typo

* add in missed tests after merge

* remove import-specific tests

* fixes based on tests that failed
  • Loading branch information
danawillow authored and Ashish Amarnath committed Mar 20, 2018
1 parent e36c684 commit dae8465
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 584 deletions.
34 changes: 0 additions & 34 deletions google/import_container_cluster_test.go

This file was deleted.

34 changes: 0 additions & 34 deletions google/import_container_node_pool_test.go

This file was deleted.

15 changes: 13 additions & 2 deletions google/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func expandNodeConfig(v interface{}) *containerBeta.NodeConfig {
nc.MinCpuPlatform = v.(string)
}

if v, ok := nodeConfig["workload_metadata_config"]; ok {
if v, ok := nodeConfig["workload_metadata_config"]; ok && len(v.([]interface{})) > 0 {
conf := v.([]interface{})[0].(map[string]interface{})
nc.WorkloadMetadataConfig = &containerBeta.WorkloadMetadataConfig{
NodeMetadata: conf["node_metadata"].(string),
Expand All @@ -260,7 +260,7 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
config = append(config, map[string]interface{}{
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"guest_accelerator": c.Accelerators,
"guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators),
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
Expand All @@ -279,6 +279,17 @@ func flattenNodeConfig(c *containerBeta.NodeConfig) []map[string]interface{} {
return config
}

func flattenContainerGuestAccelerators(c []*containerBeta.AcceleratorConfig) []map[string]interface{} {
result := []map[string]interface{}{}
for _, accel := range c {
result = append(result, map[string]interface{}{
"count": accel.AcceleratorCount,
"type": accel.AcceleratorType,
})
}
return result
}

func flattenWorkloadMetadataConfig(c *containerBeta.WorkloadMetadataConfig) []map[string]interface{} {
result := []map[string]interface{}{}
if c != nil {
Expand Down
Loading

0 comments on commit dae8465

Please sign in to comment.