forked from microsoft/terraform-provider-azuredevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceendpoint_azurerm_migration_v1_to_v2.go
110 lines (96 loc) · 2.36 KB
/
serviceendpoint_azurerm_migration_v1_to_v2.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package migration
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
//https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/state-migration
func ServiceEndpointAzureRmSchemaV1ToV2() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"project_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"service_endpoint_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
},
"authorization": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"resource_group": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"azurerm_subscription_id": {
Type: schema.TypeString,
Optional: true,
},
"azurerm_subscription_name": {
Type: schema.TypeString,
Optional: true,
},
"azurerm_management_group_id": {
Type: schema.TypeString,
Optional: true,
},
"azurerm_management_group_name": {
Type: schema.TypeString,
Optional: true,
},
"credentials": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{"resource_group"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"serviceprincipalid": {
Type: schema.TypeString,
Required: true,
},
"serviceprincipalkey": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"serviceprincipalkey_hash": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"environment": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"service_endpoint_authentication_scheme": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}
}
func ServiceEndpointAzureRmStateUpgradeV1ToV2() schema.StateUpgradeFunc {
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
if _, ok := rawState["service_endpoint_authentication_scheme"]; !ok {
rawState["service_endpoint_authentication_scheme"] = "ServicePrincipal"
}
return rawState, nil
}
}