-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
api_version_set.go
74 lines (58 loc) · 1.48 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package migration
import (
"context"
"log"
"strings"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/pluginsdk"
)
var _ pluginsdk.StateUpgrade = ApiVersionSetV0ToV1{}
type ApiVersionSetV0ToV1 struct {
}
func (ApiVersionSetV0ToV1) Schema() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
"resource_group_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
"api_management_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
"display_name": {
Type: pluginsdk.TypeString,
Required: true,
},
"versioning_scheme": {
Type: pluginsdk.TypeString,
Required: true,
},
"description": {
Type: pluginsdk.TypeString,
Optional: true,
},
"version_header_name": {
Type: pluginsdk.TypeString,
Optional: true,
},
"version_query_name": {
Type: pluginsdk.TypeString,
Optional: true,
},
}
}
func (ApiVersionSetV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
return func(ctx context.Context, 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
}
}