@@ -5,29 +5,39 @@ import (
5
5
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
6
6
)
7
7
8
- func ConvertStorageContext (context []interface {}) map [string ]interface {} {
8
+ func convertStorageContext (context []interface {}, auth map [string ]interface {}) map [string ]interface {} {
9
+ data := make (map [string ]interface {})
10
+ data ["auth" ] = auth
11
+ return data
12
+ }
13
+
14
+ func ConvertJsonConfigStorageContext (context []interface {}) map [string ]interface {} {
9
15
contextData := context [0 ].(map [string ]interface {})
10
16
contextAuth := contextData ["auth" ].([]interface {})[0 ].(map [string ]interface {})
11
- data := make (map [string ]interface {})
12
17
auth := make (map [string ]interface {})
13
18
auth ["type" ] = contextAuth ["type" ]
14
19
auth ["jsonConfig" ] = contextAuth ["json_config" ]
15
- data ["auth" ] = auth
16
- return data
20
+ return convertStorageContext (context , auth )
21
+ }
22
+
23
+ func ConvertAzureStorageContext (context []interface {}) map [string ]interface {} {
24
+ contextData := context [0 ].(map [string ]interface {})
25
+ contextAuth := contextData ["auth" ].([]interface {})[0 ].(map [string ]interface {})
26
+ auth := make (map [string ]interface {})
27
+ auth ["type" ] = contextAuth ["type" ]
28
+ auth ["account_name" ] = contextAuth ["account_name" ]
29
+ auth ["account_key" ] = contextAuth ["account_key" ]
30
+ return convertStorageContext (context , auth )
17
31
}
18
32
19
- func FlattenStorageContextConfig (spec cfClient.ContextSpec ) []interface {} {
33
+ func flattenStorageContextConfig (spec cfClient.ContextSpec , auth map [ string ] interface {} ) []interface {} {
20
34
21
35
var res = make ([]interface {}, 0 )
22
36
m := make (map [string ]interface {})
23
37
24
38
dataList := make ([]interface {}, 0 )
25
39
data := make (map [string ]interface {})
26
40
27
- auth := make (map [string ]interface {})
28
- auth ["json_config" ] = spec .Data ["auth" ].(map [string ]interface {})["jsonConfig" ]
29
- auth ["type" ] = spec .Data ["type" ]
30
-
31
41
authList := make ([]interface {}, 0 )
32
42
authList = append (authList , auth )
33
43
@@ -41,6 +51,22 @@ func FlattenStorageContextConfig(spec cfClient.ContextSpec) []interface{} {
41
51
42
52
}
43
53
54
+ func FlattenJsonConfigStorageContextConfig (spec cfClient.ContextSpec ) []interface {} {
55
+ auth := make (map [string ]interface {})
56
+ auth ["json_config" ] = spec .Data ["auth" ].(map [string ]interface {})["jsonConfig" ]
57
+ auth ["type" ] = spec .Data ["type" ]
58
+ return flattenStorageContextConfig (spec , auth )
59
+ }
60
+
61
+ func FlattenAzureStorageContextConfig (spec cfClient.ContextSpec ) []interface {} {
62
+ auth := make (map [string ]interface {})
63
+ authParams := spec .Data ["auth" ].(map [string ]interface {})
64
+ auth ["account_name" ] = authParams ["account_name" ]
65
+ auth ["account_key" ] = authParams ["account_key" ]
66
+ auth ["type" ] = spec .Data ["type" ]
67
+ return flattenStorageContextConfig (spec , auth )
68
+ }
69
+
44
70
func storageSchema (authSchema * schema.Schema ) * schema.Schema {
45
71
return & schema.Schema {
46
72
Type : schema .TypeList ,
0 commit comments