Skip to content

Commit

Permalink
Correctly handle list items
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Aug 7, 2024
1 parent 5125d1c commit b366ae8
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 4 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go 1.21.12

replace github.com/pulumi/pulumi-terraform-bridge/x/muxer => ./x/muxer

replace github.com/russross/blackfriday/v2 => github.com/iwahbe/blackfriday/v2 v2.0.0-20240807104053-35a06272bc79

require (
github.com/apparentlymart/go-cidr v1.1.0
github.com/blang/semver v3.5.1+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,8 @@ github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/iwahbe/blackfriday/v2 v2.0.0-20240807104053-35a06272bc79 h1:xVkaiHC+I1xCrb2L+fnzaLZsC5GwFmIqMRZnLjvodd8=
github.com/iwahbe/blackfriday/v2 v2.0.0-20240807104053-35a06272bc79/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI=
Expand Down Expand Up @@ -1933,8 +1935,6 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
Expand Down
6 changes: 5 additions & 1 deletion pkg/tfgen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ func splitByMdHeaders(text string, level int) [][]string {
//
// h2
// ---
contract.Ignore(foundHeader)
if !foundHeader {
// Since we have missed the header, we should reset our search so
// we don't miss the next one.
idx = 0
}
return bf.GoToNext
})

Expand Down
115 changes: 114 additions & 1 deletion pkg/tfgen/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ content
}),
},
{
input: readTestFile(t, "split_file.md"),
input: readTestFile(t, "alternative_header.md"),
level: 2,
expected: autogold.Expect([][]string{
{
Expand All @@ -798,13 +798,126 @@ content
"",
"* `default_action` - (Optional) Specifies the default action for the account access. Possible values are `Allow` and `Deny`. Defaults to `Deny`.",
"",
},
{
"* alternative rule",
"---",
"",
"",
},
}),
},
{
input: readTestFile(t, "container_app_environment_custom_domain.md"),
level: 2,
expected: autogold.Expect([][]string{
{
"---",
`subcategory: "Container Apps"`,
`layout: "azurerm"`,
`page_title: "Azure Resource Manager: azurerm_container_app_environment_custom_domain"`,
"description: |-",
" Manages a Container App Environment Custom Domain.",
"---",
"",
"# azurerm_container_app_environment_custom_domain",
"",
"Manages a Container App Environment Custom Domain Suffix.",
"",
},
{
"## Example Usage",
"",
"```hcl",
`resource "azurerm_resource_group" "example" {`,
` name = "example-resources"`,
` location = "West Europe"`,
"}",
"",
`resource "azurerm_log_analytics_workspace" "example" {`,
` name = "acctest-01"`,
" location = azurerm_resource_group.example.location",
" resource_group_name = azurerm_resource_group.example.name",
` sku = "PerGB2018"`,
" retention_in_days = 30",
"}",
"",
`resource "azurerm_container_app_environment" "example" {`,
` name = "my-environment"`,
" location = azurerm_resource_group.example.location",
" resource_group_name = azurerm_resource_group.example.name",
" log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id",
"}",
"",
`resource "azurerm_container_app_environment_custom_domain" "example" {`,
" container_app_environment_id = azurerm_container_app_environment.example.id",
` certificate_blob_base64 = filebase64("testacc.pfx")`,
` certificate_password = "TestAcc"`,
` dns_suffix = "acceptancetest.contoso.com"`,
"}",
"```",
"",
},
{
"## Arguments Reference",
"",
"The following arguments are supported:",
"",
"* `container_app_environment_id` - (Required) The ID of the Container Apps Managed Environment. Changing this forces a new resource to be created.",
"",
"* `certificate_blob_base64` - (Required) The bundle of Private Key and Certificate for the Custom DNS Suffix as a base64 encoded PFX or PEM.",
"",
"* `certificate_password` - (Required) The password for the Certificate bundle.",
"",
"* `dns_suffix` - (Required) Custom DNS Suffix for the Container App Environment.",
},
{
"## Timeouts",
"",
"The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:",
"",
"* `create` - (Defaults to 30 minutes) Used when creating the Container App Environment.",
"* `update` - (Defaults to 30 minutes) Used when updating the Container App Environment.",
"* `read` - (Defaults to 5 minutes) Used when retrieving the Container App Environment.",
"* `delete` - (Defaults to 30 minutes) Used when deleting the Container App Environment.",
"",
},
{

"## Import",
"",
"A Container App Environment Custom Domain Suffix can be imported using the `resource id` of its parent container ontainer App Environment , e.g.",
"",
"```shell",
`terraform import azurerm_container_app_environment_custom_domain.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.App/managedEnvironments/myEnvironment"`,
"```",
"",
},
}),
},
{
input: `## Header 1
content 1
##
content 2
## header 3
content 3
`,
level: 2,
expected: autogold.Expect([][]string{
{
"## Header 1",
"content 1",
"## ",
"content 2",
},
{
"## header 3",
"content 3",
"",
},
}),
},
}

for _, tt := range tests {
Expand Down
File renamed without changes.
70 changes: 70 additions & 0 deletions pkg/tfgen/test_data/container_app_environment_custom_domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
subcategory: "Container Apps"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_container_app_environment_custom_domain"
description: |-
Manages a Container App Environment Custom Domain.
---

# azurerm_container_app_environment_custom_domain

Manages a Container App Environment Custom Domain Suffix.

## Example Usage

```hcl
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_log_analytics_workspace" "example" {
name = "acctest-01"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "PerGB2018"
retention_in_days = 30
}
resource "azurerm_container_app_environment" "example" {
name = "my-environment"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
}
resource "azurerm_container_app_environment_custom_domain" "example" {
container_app_environment_id = azurerm_container_app_environment.example.id
certificate_blob_base64 = filebase64("testacc.pfx")
certificate_password = "TestAcc"
dns_suffix = "acceptancetest.contoso.com"
}
```

## Arguments Reference

The following arguments are supported:

* `container_app_environment_id` - (Required) The ID of the Container Apps Managed Environment. Changing this forces a new resource to be created.

* `certificate_blob_base64` - (Required) The bundle of Private Key and Certificate for the Custom DNS Suffix as a base64 encoded PFX or PEM.

* `certificate_password` - (Required) The password for the Certificate bundle.

* `dns_suffix` - (Required) Custom DNS Suffix for the Container App Environment.
## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:

* `create` - (Defaults to 30 minutes) Used when creating the Container App Environment.
* `update` - (Defaults to 30 minutes) Used when updating the Container App Environment.
* `read` - (Defaults to 5 minutes) Used when retrieving the Container App Environment.
* `delete` - (Defaults to 30 minutes) Used when deleting the Container App Environment.

## Import

A Container App Environment Custom Domain Suffix can be imported using the `resource id` of its parent container ontainer App Environment , e.g.

```shell
terraform import azurerm_container_app_environment_custom_domain.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.App/managedEnvironments/myEnvironment"
```

0 comments on commit b366ae8

Please sign in to comment.