Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Apr 22, 2024
1 parent 9aa318b commit 3488c14
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions cmd/migrate_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,13 @@ resource "azapi_resource" "test2" {
parent_id = azurerm_resource_group.test.id
type = "Microsoft.Automation/automationAccounts@2020-01-13-preview"
location = azurerm_resource_group.test.location
body = jsonencode({
body = {
properties = {
sku = {
name = jsondecode(azapi_resource.test.output).properties.sku.name
name = azapi_resource.test.output.properties.sku.name
}
}
})
}
}
resource "azurerm_automation_account" "test1" {
Expand All @@ -634,19 +634,19 @@ resource "azapi_update_resource" "test" {
resource_id = azurerm_automation_account.test1.id
type = "Microsoft.Automation/automationAccounts@2020-01-13-preview"
response_export_values = ["properties.sku"]
body = jsonencode({
body = {
tags = {
key = var.Label
}
})
}
}
output "accountName" {
value = jsondecode(azapi_resource.test.output).name
value = azapi_resource.test.output.name
}
output "patchAccountSKU" {
value = jsondecode(azapi_update_resource.test.output).properties.sku.name
value = azapi_update_resource.test.output.properties.sku.name
}
`, template(), randomResourceName(), randomResourceName())
}
Expand Down
4 changes: 2 additions & 2 deletions tf/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func (t *Terraform) ListGenericResources(p *tfjson.Plan) []types.GenericResource
for j, instance := range resource.Instances {
resources[i].Instances[j].Outputs = getOutputsForAddress(resource.OldAddress(instance.Index), refValueMap)
for _, output := range resources[i].Instances[j].Outputs {
prop := strings.TrimPrefix(output.OldName, fmt.Sprintf("jsondecode(%s.output).", resource.OldAddress(instance.Index)))
prop = strings.TrimPrefix(prop, fmt.Sprintf("%s.output.", resource.OldAddress(instance.Index)))
prop := strings.TrimPrefix(output.OldName, fmt.Sprintf("%s.output.", resource.OldAddress(instance.Index)))
prop = strings.TrimPrefix(prop, fmt.Sprintf("jsondecode(%s.output).", resource.OldAddress(instance.Index)))
if strings.HasPrefix(prop, "identity.userAssignedIdentities") {
prop = "identity.userAssignedIdentities"
}
Expand Down
4 changes: 2 additions & 2 deletions tf/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func getId(value interface{}) string {
func getOutputsForAddress(address string, refValueMap map[string]interface{}) []types.Output {
res := make([]types.Output, 0)
for key, value := range refValueMap {
if strings.HasPrefix(key, fmt.Sprintf("jsondecode(%s.output)", address)) {
if strings.HasPrefix(key, fmt.Sprintf("jsondecode(%s.output).", address)) {
res = append(res, types.Output{
OldName: key,
Value: value,
})
}
if strings.HasPrefix(key, fmt.Sprintf("%s.output", address)) {
if strings.HasPrefix(key, fmt.Sprintf("%s.output.", address)) {
res = append(res, types.Output{
OldName: key,
Value: value,
Expand Down

0 comments on commit 3488c14

Please sign in to comment.