diff --git a/config/resources/containerservice.hcl b/config/resources/containerservice.hcl index 75989828cf5..0ba0a3e4ec3 100644 --- a/config/resources/containerservice.hcl +++ b/config/resources/containerservice.hcl @@ -46,4 +46,21 @@ HERE } } } + + api "2023-10-15" { + package "FleetMembers" { + definition "kubernetes_fleet_member" { + id = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{memberName}" + display_name = "Kubernetes Fleet Member" + website_subcategory = "Container" + description = "Manages a Kubernetes Fleet Member" + overrides "cluster_resource_id" { + updated_name = "kubernetes_cluster_id" + } + overrides "fleet_id" { + updated_name = "kubernetes_fleet_id" + } + } + } + } } diff --git a/tools/importer-rest-api-specs/components/parser/resourceids/common_id_kubernetes_fleet.go b/tools/importer-rest-api-specs/components/parser/resourceids/common_id_kubernetes_fleet.go new file mode 100644 index 00000000000..72729ff23af --- /dev/null +++ b/tools/importer-rest-api-specs/components/parser/resourceids/common_id_kubernetes_fleet.go @@ -0,0 +1,28 @@ +package resourceids + +import ( + "github.com/hashicorp/pandora/tools/importer-rest-api-specs/models" + "github.com/hashicorp/pandora/tools/sdk/resourcemanager" +) + +var _ commonIdMatcher = commonIdKubernetesFleet{} + +type commonIdKubernetesFleet struct{} + +func (c commonIdKubernetesFleet) id() models.ParsedResourceId { + name := "KubernetesFleet" + return models.ParsedResourceId{ + CommonAlias: &name, + Constants: map[string]resourcemanager.ConstantDetails{}, + Segments: []resourcemanager.ResourceIdSegment{ + models.StaticResourceIDSegment("subscriptions", "subscriptions"), + models.SubscriptionIDResourceIDSegment("subscriptionId"), + models.StaticResourceIDSegment("resourceGroups", "resourceGroups"), + models.ResourceGroupResourceIDSegment("resourceGroupName"), + models.StaticResourceIDSegment("providers", "providers"), + models.ResourceProviderResourceIDSegment("resourceProvider", "Microsoft.ContainerService"), + models.StaticResourceIDSegment("fleets", "fleets"), + models.UserSpecifiedResourceIDSegment("fleetName"), + }, + } +} diff --git a/tools/importer-rest-api-specs/components/testing/dependencies.go b/tools/importer-rest-api-specs/components/testing/dependencies.go index f39a4ab343c..bb6386cec74 100644 --- a/tools/importer-rest-api-specs/components/testing/dependencies.go +++ b/tools/importer-rest-api-specs/components/testing/dependencies.go @@ -16,6 +16,7 @@ type testDependencies struct { needsKeyVaultAccessPolicy bool needsKeyVaultKey bool needsKubernetesCluster bool + needsKubernetesFleetManager bool needsMachineLearningWorkspace bool needsNetworkInterface bool needsPublicIP bool @@ -88,6 +89,13 @@ func (d *testDependencies) setNeedsKubernetesCluster() { d.variables.needsRandomString = true } +func (d *testDependencies) setNeedsKubernetesFleetManager() { + d.setNeedsResourceGroup() + d.needsKubernetesFleetManager = true + + d.variables.needsRandomString = true +} + func (d *testDependencies) setNeedsMachineLearningWorkspace() { d.setNeedsResourceGroup() d.setNeedsKeyVault() @@ -164,6 +172,7 @@ func DetermineDependencies(field, providerPrefix string, dependencies *testDepen "key_vault_access_policy_id": {dependencies.setNeedsKeyVaultAccessPolicy, fmt.Sprintf("%s_key_vault_access_policy.test.id", providerPrefix)}, "key_vault_key_id": {dependencies.setNeedsKeyVaultKey, fmt.Sprintf("%s_key_vault_key.test.id", providerPrefix)}, "kubernetes_cluster_id": {dependencies.setNeedsKubernetesCluster, fmt.Sprintf("%s_kubernetes_cluster.test.id", providerPrefix)}, + "kubernetes_fleet_id": {dependencies.setNeedsKubernetesFleetManager, fmt.Sprintf("%s_kubernetes_fleet_manager.test.id", providerPrefix)}, "machine_learning_workspace_id": {dependencies.setNeedsMachineLearningWorkspace, fmt.Sprintf("%s_machine_learning_workspace.test.id", providerPrefix)}, "network_interface_id": {dependencies.setNeedsNetworkInterface, fmt.Sprintf("%s_network_interface.test.id", providerPrefix)}, "storage_account_id": {dependencies.setNeedsStorageAccount, fmt.Sprintf("%s_storage_account.test.id", providerPrefix)}, diff --git a/tools/importer-rest-api-specs/components/testing/dependencies_template.go b/tools/importer-rest-api-specs/components/testing/dependencies_template.go index c055042564e..193f76b1318 100644 --- a/tools/importer-rest-api-specs/components/testing/dependencies_template.go +++ b/tools/importer-rest-api-specs/components/testing/dependencies_template.go @@ -163,6 +163,19 @@ resource "%[1]s_kubernetes_cluster" "test" { `, tb.providerPrefix)) } + if dependencies.needsKubernetesFleetManager { + components = append(components, fmt.Sprintf(` +resource "%[1]s_kubernetes_fleet_manager" "test" { + name = "acctestkfm${var.random_string}" + location = %[1]s_resource_group.test.location + resource_group_name = %[1]s_resource_group.test.name + hub_profile { + dns_prefix = "val-${var.random_string}" + } +} +`, tb.providerPrefix)) + } + if dependencies.needsMachineLearningWorkspace { components = append(components, fmt.Sprintf(` resource "%[1]s_machine_learning_workspace" "test" { diff --git a/tools/importer-rest-api-specs/components/testing/dependencies_template_test.go b/tools/importer-rest-api-specs/components/testing/dependencies_template_test.go index fff63e8c233..62ebf0e63e7 100644 --- a/tools/importer-rest-api-specs/components/testing/dependencies_template_test.go +++ b/tools/importer-rest-api-specs/components/testing/dependencies_template_test.go @@ -338,3 +338,23 @@ resource "example_virtual_network" "test" { actual := builder.generateTemplateConfigForDependencies(dependencies) testhelpers.AssertTemplatedCodeMatches(t, expected, actual) } + +func TestDependenciesTemplate_NeedsKubernetesFleetManager(t *testing.T) { + builder := NewTestBuilder("example", "resource", resourcemanager.TerraformResourceDetails{}) + dependencies := testDependencies{ + variables: testVariables{}, + needsKubernetesFleetManager: true, + } + expected := ` +resource "example_kubernetes_fleet_manager" "test" { + name = "acctestkfm${var.random_string}" + location = example_resource_group.test.location + resource_group_name = example_resource_group.test.name + hub_profile { + dns_prefix = "val-${var.random_string}" + } +} +` + actual := builder.generateTemplateConfigForDependencies(dependencies) + testhelpers.AssertTemplatedCodeMatches(t, expected, actual) +}