Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize resource id for signalr service #155

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/armtemplate/armtemplate_hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func populateManagedResourcesByPath(res Resource, paths ...string) (*Resource, [
// API interaction with ARM, where a non-nil client builder is required.
func (res ResourceId) ProviderId(sub, rg string, b *client.ClientBuilder) (string, error) {
switch res.Type {
case "Microsoft.SignalRService/SignalR":
return res.providerIdForSignalR(sub, rg, b)
case "microsoft.insights/webtests":
return res.providerIdForInsightsWebtests(sub, rg, b)
case "Microsoft.Network/frontdoors":
Expand All @@ -142,6 +144,12 @@ func (res ResourceId) ProviderId(sub, rg string, b *client.ClientBuilder) (strin
}
}

func (res ResourceId) providerIdForSignalR(sub, rg string, b *client.ClientBuilder) (string, error) {
// See issue: https://github.com/Azure/aztfy/issues/154
res.Type = "Microsoft.SignalRService/signalR"
return res.ID(sub, rg), nil
}

func (res ResourceId) providerIdForFrontDoor(sub, rg string, b *client.ClientBuilder) (string, error) {
// See issue: https://github.com/Azure/aztfy/issues/118
res.Type = "Microsoft.Network/frontDoors"
Expand Down
44 changes: 44 additions & 0 deletions internal/test/case_signalr_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package test

import (
"encoding/json"
"fmt"

"github.com/Azure/aztfy/internal/resmap"
)

type CaseSignalRService struct{}

func (CaseSignalRService) Tpl(d Data) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "%[1]s"
location = "WestEurope"
}
resource "azurerm_signalr_service" "test" {
name = "test-%[2]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
name = "Free_F1"
capacity = 1
}
}
`, d.RandomRgName(), d.RandomStringOfLength(8))
}

func (CaseSignalRService) ResourceMapping(d Data) (resmap.ResourceMapping, error) {
rm := fmt.Sprintf(`{
"/subscriptions/%[1]s/resourceGroups/%[2]s": "azurerm_resource_group.test",
"/subscriptions/%[1]s/resourceGroups/%[2]s/providers/Microsoft.SignalRService/signalR/test-%[3]s": "azurerm_signalr_service.test"
}
`, d.subscriptionId, d.RandomRgName(), d.RandomStringOfLength(8))
m := resmap.ResourceMapping{}
if err := json.Unmarshal([]byte(rm), &m); err != nil {
return nil, err
}
return m, nil
}
7 changes: 7 additions & 0 deletions internal/test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ func TestComputeVMDisk(t *testing.T) {
runCase(t, d, c)
}

func TestSignalRService(t *testing.T) {
t.Parallel()
precheck(t)
c, d := CaseSignalRService{}, NewData()
runCase(t, d, c)
}

func TestApplicationInsightWebTest(t *testing.T) {
t.Parallel()
precheck(t)
Expand Down