Skip to content

Commit bf7f88e

Browse files
Merge pull request hashicorp#14150 from hashicorp/pandora-signalr-regen
signalr - regenerate embedded sdk
2 parents 3072fa8 + 853d95e commit bf7f88e

24 files changed

+1413
-799
lines changed

internal/services/network/private_endpoint_resource.go

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/sdk/2020-05-01/signalr"
11+
1012
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-02-01/network"
1113
"github.com/hashicorp/go-azure-helpers/lang/response"
1214
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
@@ -623,6 +625,11 @@ func flattenPrivateLinkEndpointServiceConnection(serviceConnections *[]network.P
623625
privateConnectionId = serverId.ID()
624626
}
625627
}
628+
if strings.Contains(strings.ToLower(privateConnectionId), "microsoft.signalrservice") {
629+
if serviceId, err := signalr.ParseSignalRIDInsensitively(privateConnectionId); err == nil {
630+
privateConnectionId = serviceId.ID()
631+
}
632+
}
626633
attrs["private_connection_resource_id"] = privateConnectionId
627634
}
628635

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package migration
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
8+
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/sdk/2020-05-01/signalr"
9+
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
10+
)
11+
12+
var _ pluginsdk.StateUpgrade = NetworkAclV0ToV1{}
13+
14+
type NetworkAclV0ToV1 struct {
15+
}
16+
17+
func (n NetworkAclV0ToV1) Schema() map[string]*pluginsdk.Schema {
18+
return map[string]*pluginsdk.Schema{
19+
"signalr_service_id": {
20+
Type: pluginsdk.TypeString,
21+
Required: true,
22+
ForceNew: true,
23+
},
24+
25+
"default_action": {
26+
Type: pluginsdk.TypeString,
27+
Required: true,
28+
},
29+
30+
"public_network": {
31+
Type: pluginsdk.TypeList,
32+
Required: true,
33+
MaxItems: 1,
34+
Elem: &pluginsdk.Resource{
35+
Schema: map[string]*pluginsdk.Schema{
36+
"allowed_request_types": {
37+
Type: pluginsdk.TypeSet,
38+
Optional: true,
39+
ConflictsWith: []string{"public_network.0.denied_request_types"},
40+
Elem: &pluginsdk.Schema{
41+
Type: pluginsdk.TypeString,
42+
},
43+
},
44+
45+
"denied_request_types": {
46+
Type: pluginsdk.TypeSet,
47+
Optional: true,
48+
ConflictsWith: []string{"public_network.0.allowed_request_types"},
49+
Elem: &pluginsdk.Schema{
50+
Type: pluginsdk.TypeString,
51+
},
52+
},
53+
},
54+
},
55+
},
56+
57+
"private_endpoint": {
58+
Type: pluginsdk.TypeSet,
59+
Optional: true,
60+
Elem: &pluginsdk.Resource{
61+
Schema: map[string]*pluginsdk.Schema{
62+
"id": {
63+
Type: pluginsdk.TypeString,
64+
Required: true,
65+
},
66+
67+
"allowed_request_types": {
68+
Type: pluginsdk.TypeSet,
69+
Optional: true,
70+
Elem: &pluginsdk.Schema{
71+
Type: pluginsdk.TypeString,
72+
},
73+
},
74+
75+
"denied_request_types": {
76+
Type: pluginsdk.TypeSet,
77+
Optional: true,
78+
Elem: &pluginsdk.Schema{
79+
Type: pluginsdk.TypeString,
80+
},
81+
},
82+
},
83+
},
84+
},
85+
}
86+
}
87+
88+
func (n NetworkAclV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
89+
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
90+
log.Println("[DEBUG] Migrating SignalR Network ACL from v0 to v1 format")
91+
92+
// the old segment is `SignalR` but should be `signalR`
93+
oldId := rawState["id"].(string)
94+
parsed, err := signalr.ParseSignalRIDInsensitively(oldId)
95+
if err != nil {
96+
return rawState, fmt.Errorf("parsing Old Resource ID %q: %+v", oldId, err)
97+
}
98+
99+
newId := parsed.ID()
100+
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId)
101+
rawState["id"] = newId
102+
103+
// SignalR Service ID is the same as ID, but let's call the values out specifically
104+
oldServiceId := rawState["signalr_service_id"].(string)
105+
newServiceId := parsed.ID()
106+
log.Printf("[DEBUG] Updating SignalR Service ID from %q to %q", oldServiceId, newServiceId)
107+
rawState["signalr_service_id"] = newId
108+
109+
return rawState, nil
110+
}
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
package migration
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
8+
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/sdk/2020-05-01/signalr"
9+
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
10+
)
11+
12+
var _ pluginsdk.StateUpgrade = ServiceV0ToV1{}
13+
14+
type ServiceV0ToV1 struct {
15+
}
16+
17+
func (s ServiceV0ToV1) Schema() map[string]*pluginsdk.Schema {
18+
return map[string]*pluginsdk.Schema{
19+
"name": {
20+
Type: pluginsdk.TypeString,
21+
Required: true,
22+
ForceNew: true,
23+
},
24+
25+
"location": {
26+
Type: pluginsdk.TypeString,
27+
Required: true,
28+
ForceNew: true,
29+
},
30+
31+
"resource_group_name": {
32+
Type: pluginsdk.TypeString,
33+
Required: true,
34+
ForceNew: true,
35+
},
36+
37+
"sku": {
38+
Type: pluginsdk.TypeList,
39+
Required: true,
40+
MaxItems: 1,
41+
Elem: &pluginsdk.Resource{
42+
Schema: map[string]*pluginsdk.Schema{
43+
"name": {
44+
Type: pluginsdk.TypeString,
45+
Required: true,
46+
},
47+
48+
"capacity": {
49+
Type: pluginsdk.TypeInt,
50+
Required: true,
51+
},
52+
},
53+
},
54+
},
55+
56+
"features": {
57+
Type: pluginsdk.TypeSet,
58+
Optional: true,
59+
Computed: true,
60+
Elem: &pluginsdk.Resource{
61+
Schema: map[string]*pluginsdk.Schema{
62+
"flag": {
63+
Type: pluginsdk.TypeString,
64+
Required: true,
65+
},
66+
67+
"value": {
68+
Type: pluginsdk.TypeString,
69+
Required: true,
70+
},
71+
},
72+
},
73+
},
74+
75+
"upstream_endpoint": {
76+
Type: pluginsdk.TypeSet,
77+
Optional: true,
78+
Elem: &pluginsdk.Resource{
79+
Schema: map[string]*pluginsdk.Schema{
80+
"category_pattern": {
81+
Type: pluginsdk.TypeList,
82+
Required: true,
83+
Elem: &pluginsdk.Schema{
84+
Type: pluginsdk.TypeString,
85+
},
86+
},
87+
88+
"event_pattern": {
89+
Type: pluginsdk.TypeList,
90+
Required: true,
91+
Elem: &pluginsdk.Schema{
92+
Type: pluginsdk.TypeString,
93+
},
94+
},
95+
96+
"hub_pattern": {
97+
Type: pluginsdk.TypeList,
98+
Required: true,
99+
Elem: &pluginsdk.Schema{
100+
Type: pluginsdk.TypeString,
101+
},
102+
},
103+
104+
"url_template": {
105+
Type: pluginsdk.TypeString,
106+
Required: true,
107+
},
108+
},
109+
},
110+
},
111+
112+
"cors": {
113+
Type: pluginsdk.TypeList,
114+
Optional: true,
115+
Computed: true,
116+
Elem: &pluginsdk.Resource{
117+
Schema: map[string]*pluginsdk.Schema{
118+
"allowed_origins": {
119+
Type: pluginsdk.TypeSet,
120+
Required: true,
121+
Elem: &pluginsdk.Schema{
122+
Type: pluginsdk.TypeString,
123+
},
124+
},
125+
},
126+
},
127+
},
128+
129+
"hostname": {
130+
Type: pluginsdk.TypeString,
131+
Computed: true,
132+
},
133+
134+
"ip_address": {
135+
Type: pluginsdk.TypeString,
136+
Computed: true,
137+
},
138+
139+
"public_port": {
140+
Type: pluginsdk.TypeInt,
141+
Computed: true,
142+
},
143+
144+
"server_port": {
145+
Type: pluginsdk.TypeInt,
146+
Computed: true,
147+
},
148+
149+
"primary_access_key": {
150+
Type: pluginsdk.TypeString,
151+
Computed: true,
152+
Sensitive: true,
153+
},
154+
155+
"primary_connection_string": {
156+
Type: pluginsdk.TypeString,
157+
Computed: true,
158+
Sensitive: true,
159+
},
160+
161+
"secondary_access_key": {
162+
Type: pluginsdk.TypeString,
163+
Computed: true,
164+
Sensitive: true,
165+
},
166+
167+
"secondary_connection_string": {
168+
Type: pluginsdk.TypeString,
169+
Computed: true,
170+
Sensitive: true,
171+
},
172+
173+
"tags": {
174+
Type: pluginsdk.TypeMap,
175+
Optional: true,
176+
Elem: &pluginsdk.Schema{
177+
Type: pluginsdk.TypeString,
178+
},
179+
},
180+
}
181+
}
182+
183+
func (s ServiceV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
184+
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
185+
log.Println("[DEBUG] Migrating SignalR from v0 to v1 format")
186+
187+
// the old segment is `SignalR` but should be `signalR`
188+
oldId := rawState["id"].(string)
189+
parsed, err := signalr.ParseSignalRIDInsensitively(oldId)
190+
if err != nil {
191+
return rawState, fmt.Errorf("parsing Old Resource ID %q: %+v", oldId, err)
192+
}
193+
194+
newId := parsed.ID()
195+
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId)
196+
rawState["id"] = newId
197+
198+
return rawState, nil
199+
}
200+
}

0 commit comments

Comments
 (0)