Skip to content

Commit

Permalink
Merge pull request #100 from Azure/branch-240419-body-dynamic-schema
Browse files Browse the repository at this point in the history
Branch 240419 body dynamic schema
  • Loading branch information
ms-henglu authored May 8, 2024
2 parents 67fe406 + 1fd654e commit 354a47c
Show file tree
Hide file tree
Showing 539 changed files with 4,716 additions and 3,459 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v0.14.0
FEATURES:
- Support generating and testing with `azapi` dynamic property feature.

BUG FIXES:
- Fix the bug that the default resource name is not randomly generated.

## v0.13.0
FEATURES:
- Support `credscan` command to scan the credentials in the testing configuration files.
Expand Down
4 changes: 4 additions & 0 deletions dependency/azapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dependency
import (
"embed"
"fmt"
"os"
"path"
"strings"
"sync"
Expand Down Expand Up @@ -42,6 +43,9 @@ func LoadAzapiDependencies() ([]Dependency, error) {
}
for _, entry := range entries {
filename := path.Join(dir, entry.Name(), "main.tf")
if _, err := StaticFiles.Open(filename); os.IsNotExist(err) {
filename = path.Join(dir, entry.Name(), "basic", "main.tf")
}
data, err := StaticFiles.ReadFile(filename)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "azapi_resource" "privateCloud" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
properties = {
internet = "Disabled"
managementCluster = {
Expand All @@ -42,7 +42,7 @@ resource "azapi_resource" "privateCloud" {
sku = {
name = "av36"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "azapi_resource" "privateCloud" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
properties = {
internet = "Disabled"
managementCluster = {
Expand All @@ -42,7 +42,7 @@ resource "azapi_resource" "privateCloud" {
sku = {
name = "av36"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "azapi_resource" "actionRule" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = "global"
body = jsonencode({
body = {
properties = {
actions = [
{
Expand All @@ -45,7 +45,7 @@ resource "azapi_resource" "actionRule" {
]
}

})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ resource "azapi_resource" "account" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
properties = {
publicNetworkAccess = "Enabled"
}

})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -46,7 +46,7 @@ resource "azapi_resource" "prometheusRuleGroup" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
properties = {
clusterName = ""
description = ""
Expand All @@ -66,7 +66,7 @@ resource "azapi_resource" "prometheusRuleGroup" {
]
}

})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "azapi_resource" "server" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
properties = {
asAdministrators = {
members = [
Expand All @@ -46,7 +46,7 @@ resource "azapi_resource" "server" {
sku = {
name = "B1"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ resource "azapi_resource" "service" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
identity = {
type = "None"
}
body = {
properties = {
certificates = [
]
Expand Down Expand Up @@ -67,7 +64,7 @@ resource "azapi_resource" "service" {
capacity = 1
name = "Developer"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
timeouts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ resource "azapi_resource" "service" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
identity = {
type = "None"
}
body = {
properties = {
certificates = [
]
Expand All @@ -55,7 +52,7 @@ resource "azapi_resource" "service" {
capacity = 0
name = "Consumption"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -64,13 +61,13 @@ resource "azapi_resource" "apiVersionSet" {
type = "Microsoft.ApiManagement/service/apiVersionSets@2021-08-01"
parent_id = azapi_resource.service.id
name = var.resource_name
body = jsonencode({
body = {
properties = {
description = "TestDescription1"
displayName = "TestApiVersionSet1230630032559674766"
versioningScheme = "Segment"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ resource "azapi_resource" "service" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
identity = {
type = "None"
}
body = {
properties = {
certificates = [
]
Expand All @@ -55,7 +52,7 @@ resource "azapi_resource" "service" {
capacity = 0
name = "Consumption"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -64,7 +61,7 @@ resource "azapi_resource" "api" {
type = "Microsoft.ApiManagement/service/apis@2021-08-01"
parent_id = azapi_resource.service.id
name = "${var.resource_name};rev=1"
body = jsonencode({
body = {
properties = {
apiRevisionDescription = ""
apiType = "http"
Expand All @@ -82,7 +79,7 @@ resource "azapi_resource" "api" {
subscriptionRequired = true
type = "http"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "azapi_resource" "component" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
body = {
kind = "web"
properties = {
Application_Type = "web"
Expand All @@ -43,7 +43,7 @@ resource "azapi_resource" "component" {
publicNetworkAccessForIngestion = "Enabled"
publicNetworkAccessForQuery = "Enabled"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -53,10 +53,7 @@ resource "azapi_resource" "service" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
identity = {
type = "None"
}
body = {
properties = {
certificates = [
]
Expand All @@ -77,7 +74,7 @@ resource "azapi_resource" "service" {
capacity = 0
name = "Consumption"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -86,7 +83,7 @@ resource "azapi_resource" "api" {
type = "Microsoft.ApiManagement/service/apis@2021-08-01"
parent_id = azapi_resource.service.id
name = "${var.resource_name};rev=1"
body = jsonencode({
body = {
properties = {
apiType = "http"
apiVersion = ""
Expand All @@ -95,7 +92,7 @@ resource "azapi_resource" "api" {
type = "http"
value = "http://conferenceapi.azurewebsites.net/?format=json"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -104,31 +101,33 @@ resource "azapi_resource" "logger" {
type = "Microsoft.ApiManagement/service/loggers@2021-08-01"
parent_id = azapi_resource.service.id
name = var.resource_name
body = jsonencode({
body = {
properties = {
credentials = {
instrumentationKey = jsondecode(azapi_resource.component.output).properties.InstrumentationKey
instrumentationKey = azapi_resource.component.output.properties.InstrumentationKey
}
description = ""
isBuffered = true
loggerType = "applicationInsights"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
ignore_body_changes = ["properties.credentials.instrumentationKey"]
lifecycle {
ignore_changes = [body.properties.credentials.instrumentationKey]
}
}

resource "azapi_resource" "diagnostic" {
type = "Microsoft.ApiManagement/service/apis/diagnostics@2021-08-01"
parent_id = azapi_resource.api.id
name = "applicationinsights"
body = jsonencode({
body = {
properties = {
loggerId = azapi_resource.logger.id
operationNameFormat = "Name"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ resource "azapi_resource" "service" {
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = jsonencode({
identity = {
type = "None"
}
body = {
properties = {
certificates = [
]
Expand All @@ -55,7 +52,7 @@ resource "azapi_resource" "service" {
capacity = 0
name = "Consumption"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -64,7 +61,7 @@ resource "azapi_resource" "api" {
type = "Microsoft.ApiManagement/service/apis@2021-08-01"
parent_id = azapi_resource.service.id
name = "${var.resource_name};rev=1"
body = jsonencode({
body = {
properties = {
apiRevisionDescription = ""
apiType = "http"
Expand All @@ -82,7 +79,7 @@ resource "azapi_resource" "api" {
subscriptionRequired = true
type = "http"
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Expand All @@ -91,7 +88,7 @@ resource "azapi_resource" "policy" {
type = "Microsoft.ApiManagement/service/apis/policies@2021-08-01"
parent_id = azapi_resource.api.id
name = "policy"
body = jsonencode({
body = {
properties = {
format = "xml"
value = <<-EOT
Expand All @@ -103,9 +100,11 @@ resource "azapi_resource" "policy" {
</policies>
EOT
}
})
}
schema_validation_enabled = false
response_export_values = ["*"]
ignore_body_changes = ["properties.value"]
lifecycle {
ignore_changes = [body.properties.value]
}
}

Loading

0 comments on commit 354a47c

Please sign in to comment.