Skip to content

Commit

Permalink
fix zone issue (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonhuang-google authored Mar 16, 2023
1 parent b77ae29 commit 2fa644e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cai2hcl/compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ func (c *ComputeInstanceConverter) convertResourceData(asset *caiasset.Asset) (*
hclData["metadata"] = convertMetadata(instance.Metadata)

if instance.Zone == "" {
instance.Zone = parseFieldValue(asset.Name, "zones")
hclData["zone"] = parseFieldValue(asset.Name, "zones")
} else {
hclData["zone"] = parseFieldValue(instance.Zone, "zones")
}
hclData["zone"] = instance.Zone

ctyVal, err := mapToCtyValWithSchema(hclData, c.schema)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion testdata/full_compute_instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
"bar",
"foo"
]
}
},
"zone": "projects/test-project/zones/us-central1-a"
}
}
},
Expand Down

0 comments on commit 2fa644e

Please sign in to comment.