From 0e544feb240e0679f61670e0086fdda95e4f40bf Mon Sep 17 00:00:00 2001 From: Heng Lu Date: Thu, 25 Jul 2024 10:40:07 +0800 Subject: [PATCH] fix tests --- .../TestExecuteCommand_basic/expect.tf | 126 +++++++++++++++--- .../TestExecuteCommand_basic/input.json | 2 +- .../expect.tf | 12 +- .../input.json | 8 +- .../expect.tf | 6 +- .../input.json | 2 +- 6 files changed, 125 insertions(+), 31 deletions(-) diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_basic/expect.tf b/internal/langserver/handlers/testdata/TestExecuteCommand_basic/expect.tf index 701a9a3d..77417a78 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_basic/expect.tf +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_basic/expect.tf @@ -1,37 +1,131 @@ /* Note: This is a generated HCL content from the JSON input which is based on the latest API version available. To import the resource, please run the following command: -terraform import azapi_resource.automationAccount /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctest1660/providers/Microsoft.Automation/automationAccounts/hengluacctest5030?api-version=2023-11-01 +terraform import azapi_resource.managedCluster /subscriptions/0000000/resourcegroups/acctestRG-aks-240626160102776968/providers/Microsoft.ContainerService/managedClusters/acctestaks240626160102776968?api-version=2024-04-02-preview Or add the below config: import { - id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctest1660/providers/Microsoft.Automation/automationAccounts/hengluacctest5030?api-version=2023-11-01" - to = azapi_resource.automationAccount + id = "/subscriptions/0000000/resourcegroups/acctestRG-aks-240626160102776968/providers/Microsoft.ContainerService/managedClusters/acctestaks240626160102776968?api-version=2024-04-02-preview" + to = azapi_resource.managedCluster } */ -resource "azapi_resource" "automationAccount" { - type = "Microsoft.Automation/automationAccounts@2023-11-01" - parent_id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctest1660" - name = "hengluacctest5030" - location = "westeurope" +resource "azapi_resource" "managedCluster" { + type = "Microsoft.ContainerService/managedClusters@2024-04-02-preview" + parent_id = "/subscriptions/0000000/resourceGroups/acctestRG-aks-240626160102776968" + name = "acctestaks240626160102776968" + location = "eastus" identity { type = "SystemAssigned" identity_ids = [] } body = { properties = { - encryption = { - identity = { - userAssignedIdentity = null + agentPoolProfiles = [{ + count = 3 + enableAutoScaling = false + enableEncryptionAtHost = false + enableFIPS = false + enableNodePublicIP = false + enableUltraSSD = false + kubeletDiskType = "OS" + maxPods = 30 + mode = "System" + name = "np" + orchestratorVersion = "1.28" + osDiskSizeGB = 128 + osDiskType = "Managed" + osSKU = "Ubuntu" + osType = "Linux" + powerState = { + code = "Running" + } + scaleDownMode = "Delete" + type = "VirtualMachineScaleSets" + upgradeSettings = { + maxSurge = "10%" + } + vmSize = "Standard_DS2_v2" + }] + autoUpgradeProfile = { + nodeOSUpgradeChannel = "NodeImage" + upgradeChannel = "none" + } + azureMonitorProfile = { + metrics = { + enabled = false + kubeStateMetrics = {} + } + } + disableLocalAccounts = false + dnsPrefix = "acctestaks240626160102776968" + enableRBAC = true + kubernetesVersion = "1.28" + linuxProfile = { + adminUsername = "acctestuser240626160102776968" + ssh = { + publicKeys = [{ + keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" + }] } - keySource = "Microsoft.Automation" } - sku = { - capacity = null - family = null - name = "Basic" + networkProfile = { + dnsServiceIP = "10.10.0.10" + ipFamilies = ["IPv4"] + loadBalancerProfile = { + backendPoolType = "nodeIPConfiguration" + managedOutboundIPs = { + count = 1 + } + } + loadBalancerSku = "standard" + networkDataplane = "azure" + networkPlugin = "azure" + networkPolicy = "azure" + outboundType = "loadBalancer" + serviceCidr = "10.10.0.0/16" + serviceCidrs = ["10.10.0.0/16"] + } + nodeResourceGroup = "MC_acctestRG-aks-240626160102776968_acctestaks240626160102776968_eastus" + oidcIssuerProfile = { + enabled = false + } + securityProfile = { + imageCleaner = { + enabled = false + intervalHours = 48 + } } + servicePrincipalProfile = { + clientId = "msi" + } + storageProfile = { + diskCSIDriver = { + enabled = true + } + fileCSIDriver = { + enabled = true + } + snapshotController = { + enabled = true + } + } + supportPlan = "KubernetesOfficial" + windowsProfile = { + adminUsername = "azureuser" + enableCSIProxy = true + gmsaProfile = { + dnsServer = "" + enabled = true + rootDomainName = "" + } + licenseType = "None" + } + workloadAutoScalerProfile = {} + } + sku = { + name = "Base" + tier = "Free" } } } diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_basic/input.json b/internal/langserver/handlers/testdata/TestExecuteCommand_basic/input.json index a3fab441..503495bf 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_basic/input.json +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_basic/input.json @@ -1,5 +1,5 @@ { - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/acctestRG-aks-240626160102776968/providers/Microsoft.ContainerService/managedClusters/acctestaks240626160102776968", + "id": "/subscriptions/0000000/resourcegroups/acctestRG-aks-240626160102776968/providers/Microsoft.ContainerService/managedClusters/acctestaks240626160102776968", "location": "eastus", "name": "acctestaks240626160102776968", "type": "Microsoft.ContainerService/ManagedClusters", diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/expect.tf b/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/expect.tf index 271f3c76..81f32d43 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/expect.tf +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/expect.tf @@ -1,24 +1,24 @@ /* Note: This is a generated HCL content from the JSON input which is based on the latest API version available. To import the resource, please run the following command: -terraform import azapi_resource.subnet /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447?api-version=2023-11-01 +terraform import azapi_resource.subnet /subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447?api-version=2024-01-01 Or add the below config: import { - id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447?api-version=2023-11-01" + id = "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447?api-version=2024-01-01" to = azapi_resource.subnet } */ resource "azapi_resource" "subnet" { - type = "Microsoft.Network/virtualNetworks/subnets@2023-11-01" - parent_id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447" + type = "Microsoft.Network/virtualNetworks/subnets@2024-01-01" + parent_id = "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447" name = "acctest-sn-private-240530173443928447" body = { properties = { addressPrefix = "10.0.2.0/24" delegations = [{ - id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447/delegations/acctest" + id = "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447/delegations/acctest" name = "acctest" properties = { serviceName = "Microsoft.Databricks/workspaces" @@ -26,7 +26,7 @@ resource "azapi_resource" "subnet" { type = "Microsoft.Network/virtualNetworks/subnets/delegations" }] networkSecurityGroup = { - id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/networkSecurityGroups/acctest-nsg-240530173443928447" + id = "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/networkSecurityGroups/acctest-nsg-240530173443928447" } privateEndpointNetworkPolicies = "Enabled" privateLinkServiceNetworkPolicies = "Enabled" diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/input.json b/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/input.json index 4f6bf89a..aaf124a7 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/input.json +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_nestedResource/input.json @@ -1,23 +1,23 @@ { "name": "acctest-sn-private-240530173443928447", - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447", + "id": "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447", "etag": "W/\"b1dbffb3-0a4f-42a8-ac22-0b6a04d76810\"", "properties": { "provisioningState": "Succeeded", "addressPrefix": "10.0.2.0/24", "networkSecurityGroup": { - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/networkSecurityGroups/acctest-nsg-240530173443928447" + "id": "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/networkSecurityGroups/acctest-nsg-240530173443928447" }, "networkIntentPolicies": [ { - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/ACCTESTRG-DATABRICKS-240530173443928447/providers/Microsoft.Network/networkIntentPolicies/ADB-EASTUS-DP-TO-CP-PL-2D0CEECC9F3EDAAC0D844BB8" + "id": "/subscriptions/0000000/resourceGroups/ACCTESTRG-DATABRICKS-240530173443928447/providers/Microsoft.Network/networkIntentPolicies/ADB-EASTUS-DP-TO-CP-PL-2D0CEECC9F3EDAAC0D844BB8" } ], "serviceEndpoints": [], "delegations": [ { "name": "acctest", - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447/delegations/acctest", + "id": "/subscriptions/0000000/resourceGroups/acctestRG-databricks-240530173443928447/providers/Microsoft.Network/virtualNetworks/acctest-vnet-240530173443928447/subnets/acctest-sn-private-240530173443928447/delegations/acctest", "etag": "W/\"b1dbffb3-0a4f-42a8-ac22-0b6a04d76810\"", "properties": { "provisioningState": "Succeeded", diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/expect.tf b/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/expect.tf index 35340f85..ff809cf9 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/expect.tf +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/expect.tf @@ -1,18 +1,18 @@ /* Note: This is a generated HCL content from the JSON input which is based on the latest API version available. To import the resource, please run the following command: -terraform import azapi_resource.resourceGroup /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6?api-version=2024-03-01 +terraform import azapi_resource.resourceGroup /subscriptions/0000000/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6?api-version=2024-03-01 Or add the below config: import { - id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6?api-version=2024-03-01" + id = "/subscriptions/0000000/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6?api-version=2024-03-01" to = azapi_resource.resourceGroup } */ resource "azapi_resource" "resourceGroup" { type = "Microsoft.Resources/resourceGroups@2024-03-01" - parent_id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590" + parent_id = "/subscriptions/0000000" name = "app-rg5wg5lo7sa2hxrh6bs6" location = "eastus" body = { diff --git a/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/input.json b/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/input.json index 1ae08756..64046afb 100644 --- a/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/input.json +++ b/internal/langserver/handlers/testdata/TestExecuteCommand_resourceGroup/input.json @@ -1,5 +1,5 @@ { - "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6", + "id": "/subscriptions/0000000/resourceGroups/app-rg5wg5lo7sa2hxrh6bs6", "name": "app-rg5wg5lo7sa2hxrh6bs6", "type": "Microsoft.Resources/resourceGroups", "location": "eastus",