Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Factory - Global Parameters, bug fix while reading editted or existing global parameter values #13519

Merged
merged 7 commits into from Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions internal/services/datafactory/data_factory_resource.go
Expand Up @@ -2,7 +2,10 @@ package datafactory

import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
Expand Down Expand Up @@ -606,12 +609,23 @@ func flattenDataFactoryGlobalParameters(input map[string]*datafactory.GlobalPara
if len(input) == 0 {
return []interface{}{}
}

result := make([]interface{}, 0)
for name, item := range input {
var valueResult string
typeResult := strings.Title(string(item.Type))

if (typeResult == "Array" || typeResult == "Object") && reflect.TypeOf(item.Value).Name() != "string" {
j, _ := json.Marshal(item.Value)
valueResult = string(j)
} else {
valueResult = fmt.Sprintf("%v", item.Value)
}

result = append(result, map[string]interface{}{
"name": name,
"type": string(item.Type),
"value": item.Value,
"type": typeResult,
"value": valueResult,
})
}
return result
Expand Down
4 changes: 2 additions & 2 deletions internal/services/datafactory/data_factory_resource_test.go
Expand Up @@ -675,13 +675,13 @@ resource "azurerm_data_factory" "test" {
global_parameter {
name = "arrayVal"
type = "Array"
value = "[\"a\", \"b\", \"c\"]"
value = jsonencode(["a", "b", "c"])
}

global_parameter {
name = "objectVal"
type = "Object"
value = "{'name': 'value'}"
value = jsonencode({ name : "value" })
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/data_factory.html.markdown
Expand Up @@ -77,6 +77,8 @@ A `global_parameter` block supports the following:

* `value` - (Required) Specifies the global parameter value.

-> **Note:** For type `Array` and `Object` it is recommended to use `jsonencode()` for the value

---

A `identity` block supports the following:
Expand Down