forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo_database.go
54 lines (42 loc) · 1.15 KB
/
mongo_database.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
package migration
import (
"context"
"log"
"strings"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/tf/pluginsdk"
)
var _ pluginsdk.StateUpgrade = MongoDatabaseV0ToV1{}
type MongoDatabaseV0ToV1 struct{}
func (MongoDatabaseV0ToV1) 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,
},
"account_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
"throughput": {
Type: pluginsdk.TypeInt,
Optional: true,
Computed: true,
},
}
}
func (MongoDatabaseV0ToV1) 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), "apis/mongodb/databases", "mongodbDatabases", 1)
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId)
rawState["id"] = newId
return rawState, nil
}
}