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

Branch 240419 body dynamic schema #100

Merged
merged 3 commits into from
May 8, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
Loading