/
api_version_set.go
57 lines (43 loc) · 1.24 KB
/
api_version_set.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
package migration
import (
"log"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)
func ApiVersionSetUpgradeV0Schema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"name": azure.SchemaApiManagementChildName(),
"resource_group_name": azure.SchemaResourceGroupName(),
"api_management_name": azure.SchemaApiManagementName(),
"display_name": {
Type: schema.TypeString,
Required: true,
},
"versioning_scheme": {
Type: schema.TypeString,
Required: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
},
"version_header_name": {
Type: schema.TypeString,
Optional: true,
},
"version_query_name": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
func ApiVersionSetUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
oldId := rawState["id"].(string)
newId := strings.Replace(rawState["id"].(string), "/api-version-set/", "/apiVersionSets/", 1)
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId)
rawState["id"] = newId
return rawState, nil
}