forked from hashicorp/terraform-provider-azurerm
/
batch_account.go
45 lines (33 loc) · 1.08 KB
/
batch_account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package batch
import (
"fmt"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch"
)
// expandBatchAccountKeyVaultReference expands Batch account KeyVault reference
func expandBatchAccountKeyVaultReference(list []interface{}) (*batch.KeyVaultReference, error) {
if len(list) == 0 {
return nil, fmt.Errorf("Error: key vault reference should be defined")
}
keyVaultRef := list[0].(map[string]interface{})
keyVaultRefID := keyVaultRef["id"].(string)
keyVaultRefURL := keyVaultRef["url"].(string)
ref := &batch.KeyVaultReference{
ID: &keyVaultRefID,
URL: &keyVaultRefURL,
}
return ref, nil
}
// flattenBatchAccountKeyvaultReference flattens a Batch account keyvault reference
func flattenBatchAccountKeyvaultReference(keyVaultReference *batch.KeyVaultReference) interface{} {
result := make(map[string]interface{})
if keyVaultReference == nil {
return []interface{}{}
}
if keyVaultReference.ID != nil {
result["id"] = *keyVaultReference.ID
}
if keyVaultReference.URL != nil {
result["url"] = *keyVaultReference.URL
}
return []interface{}{result}
}