forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscription_pricing.go
36 lines (27 loc) · 918 Bytes
/
subscription_pricing.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
package migration
import (
"context"
"log"
"strings"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/tf/pluginsdk"
)
var _ pluginsdk.StateUpgrade = SubscriptionPricingV0ToV1{}
type SubscriptionPricingV0ToV1 struct{}
func (SubscriptionPricingV0ToV1) Schema() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"tier": {
Type: pluginsdk.TypeString,
Required: true,
},
}
}
func (SubscriptionPricingV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
log.Println("[DEBUG] Migrating ResourceType from v0 to v1 format")
oldId := rawState["id"].(string)
newId := strings.Replace(oldId, "/default", "/VirtualMachines", 1)
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId)
rawState["id"] = newId
return rawState, nil
}
}