forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hashicorp#14150 from hashicorp/pandora-signalr-regen
signalr - regenerate embedded sdk
- Loading branch information
Showing
24 changed files
with
1,413 additions
and
799 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
internal/services/signalr/migration/network_acl_v0_to_v1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package migration | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/sdk/2020-05-01/signalr" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
) | ||
|
||
var _ pluginsdk.StateUpgrade = NetworkAclV0ToV1{} | ||
|
||
type NetworkAclV0ToV1 struct { | ||
} | ||
|
||
func (n NetworkAclV0ToV1) Schema() map[string]*pluginsdk.Schema { | ||
return map[string]*pluginsdk.Schema{ | ||
"signalr_service_id": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"default_action": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"public_network": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
MaxItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"allowed_request_types": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
ConflictsWith: []string{"public_network.0.denied_request_types"}, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
|
||
"denied_request_types": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
ConflictsWith: []string{"public_network.0.allowed_request_types"}, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"private_endpoint": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"id": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"allowed_request_types": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
|
||
"denied_request_types": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (n NetworkAclV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { | ||
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
log.Println("[DEBUG] Migrating SignalR Network ACL from v0 to v1 format") | ||
|
||
// the old segment is `SignalR` but should be `signalR` | ||
oldId := rawState["id"].(string) | ||
parsed, err := signalr.ParseSignalRIDInsensitively(oldId) | ||
if err != nil { | ||
return rawState, fmt.Errorf("parsing Old Resource ID %q: %+v", oldId, err) | ||
} | ||
|
||
newId := parsed.ID() | ||
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | ||
rawState["id"] = newId | ||
|
||
// SignalR Service ID is the same as ID, but let's call the values out specifically | ||
oldServiceId := rawState["signalr_service_id"].(string) | ||
newServiceId := parsed.ID() | ||
log.Printf("[DEBUG] Updating SignalR Service ID from %q to %q", oldServiceId, newServiceId) | ||
rawState["signalr_service_id"] = newId | ||
|
||
return rawState, nil | ||
} | ||
} |
200 changes: 200 additions & 0 deletions
200
internal/services/signalr/migration/service_v0_to_v1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
package migration | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/sdk/2020-05-01/signalr" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
) | ||
|
||
var _ pluginsdk.StateUpgrade = ServiceV0ToV1{} | ||
|
||
type ServiceV0ToV1 struct { | ||
} | ||
|
||
func (s ServiceV0ToV1) Schema() map[string]*pluginsdk.Schema { | ||
return map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"location": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"resource_group_name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
|
||
"sku": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
MaxItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"capacity": { | ||
Type: pluginsdk.TypeInt, | ||
Required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"features": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"flag": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"value": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"upstream_endpoint": { | ||
Type: pluginsdk.TypeSet, | ||
Optional: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"category_pattern": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
|
||
"event_pattern": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
|
||
"hub_pattern": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
|
||
"url_template": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"cors": { | ||
Type: pluginsdk.TypeList, | ||
Optional: true, | ||
Computed: true, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"allowed_origins": { | ||
Type: pluginsdk.TypeSet, | ||
Required: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
"hostname": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"ip_address": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"public_port": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"server_port": { | ||
Type: pluginsdk.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"primary_access_key": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
}, | ||
|
||
"primary_connection_string": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
}, | ||
|
||
"secondary_access_key": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
}, | ||
|
||
"secondary_connection_string": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
}, | ||
|
||
"tags": { | ||
Type: pluginsdk.TypeMap, | ||
Optional: true, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (s ServiceV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { | ||
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
log.Println("[DEBUG] Migrating SignalR from v0 to v1 format") | ||
|
||
// the old segment is `SignalR` but should be `signalR` | ||
oldId := rawState["id"].(string) | ||
parsed, err := signalr.ParseSignalRIDInsensitively(oldId) | ||
if err != nil { | ||
return rawState, fmt.Errorf("parsing Old Resource ID %q: %+v", oldId, err) | ||
} | ||
|
||
newId := parsed.ID() | ||
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | ||
rawState["id"] = newId | ||
|
||
return rawState, nil | ||
} | ||
} |
Oops, something went wrong.