diff --git a/tools/importer-rest-api-specs/components/terraform/examples/resource_test.go b/tools/importer-rest-api-specs/components/terraform/examples/resource_test.go index b939f264423..d7095d3d7b7 100644 --- a/tools/importer-rest-api-specs/components/terraform/examples/resource_test.go +++ b/tools/importer-rest-api-specs/components/terraform/examples/resource_test.go @@ -113,3 +113,85 @@ resource "azurerm_load_test" "example" { } testhelpers.AssertTemplatedCodeMatches(t, expected, *actual) } + +func TestResourceExampleFromTests_WithTemplate_FleetMember(t *testing.T) { + input := resourcemanager.TerraformResourceTestsDefinition{ + BasicConfiguration: ` +resource "azurerm_kubernetes_fleet_member" "test" { + kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id + kubernetes_fleet_id = azurerm_kubernetes_fleet_manager.test.id + name = "acctestkfm-${var.random_string}" +} +`, + TemplateConfiguration: pointer.To(` +variable "primary_location" {} +variable "random_integer" {} +variable "random_string" {} + +resource "azurerm_kubernetes_cluster" "test" { + name = "acctestaks${var.random_string}" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + dns_prefix = "acctestaks${var.random_string}" + + default_node_pool { + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + } + + identity { + type = "SystemAssigned" + } +} + + +resource "azurerm_kubernetes_fleet_manager" "test" { + name = "acctestkfm${var.random_string}" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + + +resource "azurerm_resource_group" "test" { + name = "acctestrg-${var.random_integer}" + location = var.primary_location +} +`), + } + expected := ` +resource "azurerm_kubernetes_cluster" "example" { + name = "example" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + dns_prefix = "acctestaksexample" + default_node_pool { + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + } + identity { + type = "SystemAssigned" + } +} +resource "azurerm_kubernetes_fleet_manager" "example" { + name = "example" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name +} +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} +resource "azurerm_kubernetes_fleet_member" "example" { + kubernetes_cluster_id = azurerm_kubernetes_cluster.example.id + kubernetes_fleet_id = azurerm_kubernetes_fleet_manager.example.id + name = "example" +} +` + actual, err := ResourceExampleFromTests(input) + if err != nil { + t.Fatalf(err.Error()) + } + testhelpers.AssertTemplatedCodeMatches(t, expected, *actual) +} diff --git a/tools/importer-rest-api-specs/components/terraform/examples/variable_replacements.go b/tools/importer-rest-api-specs/components/terraform/examples/variable_replacements.go index 8119380cc0d..af905c55d20 100644 --- a/tools/importer-rest-api-specs/components/terraform/examples/variable_replacements.go +++ b/tools/importer-rest-api-specs/components/terraform/examples/variable_replacements.go @@ -75,6 +75,5 @@ func updatedValueForAttribute(resourceKey, fieldKey string, value string) (*hclw return &updatedValue, nil } - out := hclwrite.TokensForValue(cty.StringVal("example-value")) - return &out, nil + return nil, nil }