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

refactor: Fix README generation for internal submodules #43

Merged
merged 1 commit into from
Apr 25, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ repos:
- args:
- --args=--config=.terraform-docs.yml
id: terraform_docs
- args:
- --args=--config=.terraform-docs-internal.yml
- --hook-config=--path-to-file=.README.md
files: ^modules/test_infrastructure/
id: terraform_docs
- args:
- --args=--only=terraform_deprecated_interpolation
- --args=--only=terraform_deprecated_index
Expand Down
130 changes: 130 additions & 0 deletions .terraform-docs-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
formatter: "markdown document" # this is required
version: ""
header-from: ".header.md"

output:
file: .README.md
mode: replace

sort:
enabled: false

settings:
indent: 3
lockfile: false

content: |-
{{ .Header }}

## Module's Required Inputs

Name | Type | Description
--- | --- | ---
{{- range .Module.Inputs }}
{{- if .Required }}
[`{{ .Name }}`](#{{ .Name }}) | `{{ (split "(" .Type.Raw)._0 }}` | {{ (split "." .Description.Raw)._0 }}.
{{- end }}
{{- end }}

{{ $optional := false -}}
{{ range .Module.Inputs }}{{ if not .Required }}{{ $optional = true -}}{{ end -}}{{ end -}}

{{ if $optional -}}
## Module's Optional Inputs

Name | Type | Description
--- | --- | ---
{{- range .Module.Inputs }}
{{- if not .Required }}
[`{{ .Name }}`](#{{ .Name }}) | `{{ (split "(" .Type.Raw)._0 }}` | {{ (split "." .Description.Raw)._0 }}.
{{- end -}}
{{ end -}}
{{ end }}

{{ if ne (len .Module.Outputs) 0 -}}
## Module's Outputs

Name | Description
--- | ---
{{- range .Module.Outputs }}
`{{ .Name }}` | {{ .Description.Raw }}
{{- end }}
{{- end }}

## Module's Nameplate

{{ if ne (len .Module.Requirements) 0 -}}
Requirements needed by this module:
{{ range .Module.Requirements }}
- `{{ .Name }}`{{ if .Version }}, version: {{ .Version }}{{ end }}
{{- end }}
{{- end }}

{{ if ne (len .Module.Providers) 0 -}}
Providers used in this module:
{{ range .Module.Providers }}
- `{{ .Name }}`{{ if .Version }}, version: {{ .Version }}{{ end }}
{{- end }}
{{- end }}

{{ if ne (len .Module.ModuleCalls) 0 -}}
Modules used in this module:
Name | Version | Source | Description
--- | --- | --- | ---
{{- range .Module.ModuleCalls }}
`{{ .Name }}` | {{ if .Version }}{{ .Version }}{{ else }}-{{ end }} | {{ .Source }} | {{ .Description }}
{{- end }}
{{- end }}

{{ if ne (len .Module.Resources) 0 -}}
Resources used in this module:
{{ range .Module.Resources }}
- `{{ .Type }}` ({{ .Mode }})
{{- end }}
{{- end }}

## Inputs/Outpus details

### Required Inputs

{{ range .Module.Inputs -}}
{{ if .Required -}}
#### {{ .Name }}

{{ .Description }}

Type: {{ if lt (len (split "\n" .Type.Raw)) 2 }}{{ .Type }}{{ else }}

```hcl
{{ .Type }}
```
{{ end }}

<sup>[back to list](#modules-required-inputs)</sup>

{{ end -}}
{{- end -}}

{{ if $optional -}}
### Optional Inputs

{{ range .Module.Inputs -}}
{{ if not .Required -}}
#### {{ .Name }}

{{ .Description }}

Type: {{ if lt (len (split "\n" .Type.Raw)) 2 }}{{ .Type }}{{ else }}

```hcl
{{ .Type }}
```
{{ end }}

Default value: `{{ .Default }}`

<sup>[back to list](#modules-optional-inputs)</sup>

{{ end }}
{{- end -}}
{{ end -}}
24 changes: 2 additions & 22 deletions modules/test_infrastructure/.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Name | Type | Description
[`spoke_vms`](#spoke_vms) | `map` | A map defining spoke VMs for testing.
[`bastions`](#bastions) | `map` | A map containing Azure Bastion definition.


## Module's Optional Inputs

Name | Type | Description
Expand All @@ -29,8 +28,6 @@ Name | Type | Description
[`tags`](#tags) | `map` | The map of tags to assign to all created resources.
[`load_balancers`](#load_balancers) | `map` | A map containing configuration for all (both private and public) Load Balancers.



## Module's Outputs

Name | Description
Expand All @@ -42,17 +39,14 @@ private IP address otherwise.

## Module's Nameplate


Requirements needed by this module:

- `terraform`, version: >= 1.5, < 2.0
- `azurerm`, version: ~> 3.80

- `azurerm`, version: ~> 3.98

Providers used in this module:

- `azurerm`, version: ~> 3.80

- `azurerm`, version: ~> 3.98

Modules used in this module:
Name | Version | Source | Description
Expand All @@ -61,7 +55,6 @@ Name | Version | Source | Description
`vnet_peering` | - | ../vnet_peering | https://registry.terraform.io/modules/PaloAltoNetworks/swfw-modules/azurerm/latest/submodules/vnet_peering
`load_balancer` | - | ../loadbalancer | https://registry.terraform.io/modules/PaloAltoNetworks/swfw-modules/azurerm/latest/submodules/loadbalancer


Resources used in this module:

- `bastion_host` (managed)
Expand All @@ -76,8 +69,6 @@ Resources used in this module:

### Required Inputs



#### resource_group_name

The name of the Resource Group to use.
Expand All @@ -94,7 +85,6 @@ Type: string

<sup>[back to list](#modules-required-inputs)</sup>


#### vnets

A map defining VNETs.
Expand Down Expand Up @@ -171,7 +161,6 @@ map(object({

<sup>[back to list](#modules-required-inputs)</sup>


#### authentication

A map defining authentication details for spoke VMs.
Expand Down Expand Up @@ -278,11 +267,8 @@ map(object({

<sup>[back to list](#modules-required-inputs)</sup>



### Optional Inputs


#### create_resource_group

When set to `true` it will cause a Resource Group creation. Name of the newly specified RG is controlled by
Expand All @@ -296,8 +282,6 @@ Default value: `true`

<sup>[back to list](#modules-optional-inputs)</sup>



#### tags

The map of tags to assign to all created resources.
Expand All @@ -308,7 +292,6 @@ Default value: `map[]`

<sup>[back to list](#modules-optional-inputs)</sup>


#### load_balancers

A map containing configuration for all (both private and public) Load Balancers.
Expand Down Expand Up @@ -408,7 +391,4 @@ Default value: `map[]`

<sup>[back to list](#modules-optional-inputs)</sup>




<!-- END_TF_DOCS -->