diff --git a/cmd/root.go b/cmd/root.go index a7319d9..08fc20d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -57,8 +57,8 @@ func NewCommand() *cobra.Command { // flags cmd.PersistentFlags().StringVarP(&config.File, "config", "c", ".terraform-docs.yml", "config file name") - cmd.PersistentFlags().StringSliceVar(&config.Sections.Show, "show", []string{}, "show section [header, inputs, outputs, providers, requirements, resources]") - cmd.PersistentFlags().StringSliceVar(&config.Sections.Hide, "hide", []string{}, "hide section [header, inputs, outputs, providers, requirements, resources]") + cmd.PersistentFlags().StringSliceVar(&config.Sections.Show, "show", []string{}, "show section [header, inputs, modules, outputs, providers, requirements, resources]") + cmd.PersistentFlags().StringSliceVar(&config.Sections.Hide, "hide", []string{}, "hide section [header, inputs, modules, outputs, providers, requirements, resources]") cmd.PersistentFlags().BoolVar(&config.Sections.ShowAll, "show-all", true, "show all sections") cmd.PersistentFlags().BoolVar(&config.Sections.HideAll, "hide-all", false, "hide all sections (default false)") diff --git a/docs/CONFIG_FILE.md b/docs/CONFIG_FILE.md index e0c222d..999f89b 100644 --- a/docs/CONFIG_FILE.md +++ b/docs/CONFIG_FILE.md @@ -11,16 +11,20 @@ sections: hide: - header - inputs + - modules - outputs - providers - requirements + - resources show-all: true show: - header - inputs + - modules - outputs - providers - requirements + - resources output-values: enabled: false diff --git a/docs/FORMATS_GUIDE.md b/docs/FORMATS_GUIDE.md index 37fe7b9..b6e3b46 100644 --- a/docs/FORMATS_GUIDE.md +++ b/docs/FORMATS_GUIDE.md @@ -16,11 +16,11 @@ terraform-docs [PATH] [flags] -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") -h, --help help for terraform-docs - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -44,4 +44,4 @@ terraform-docs [PATH] [flags] * [terraform-docs xml](/docs/formats/xml.md) - Generate XML of inputs and outputs * [terraform-docs yaml](/docs/formats/yaml.md) - Generate YAML of inputs and outputs -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/asciidoc-document.md b/docs/formats/asciidoc-document.md index 2be3f3f..39bdfba 100644 --- a/docs/formats/asciidoc-document.md +++ b/docs/formats/asciidoc-document.md @@ -21,14 +21,14 @@ terraform-docs asciidoc document [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") --required show Required column or section (default true) --sensitive show Sensitive column or section (default true) - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -105,6 +105,28 @@ generates the following output: - tls + == Modules + + The following Modules are called: + + === bar + + Source: baz + + Version: 4.5.6 + + === baz + + Source: baz + + Version: 4.5.6 + + === foo + + Source: bar + + Version: 1.2.3 + == Resources The following resources are used by this module: @@ -434,4 +456,4 @@ generates the following output: Description: It's unquoted output. -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/asciidoc-table.md b/docs/formats/asciidoc-table.md index 1736958..2e2d9bf 100644 --- a/docs/formats/asciidoc-table.md +++ b/docs/formats/asciidoc-table.md @@ -21,14 +21,14 @@ terraform-docs asciidoc table [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") --required show Required column or section (default true) --sensitive show Sensitive column or section (default true) - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -104,6 +104,16 @@ generates the following output: |tls |n/a |=== + == Modules + + [cols="a,a,a",options="header,autowidth"] + |=== + |Name|Source|Version| + |bar|baz|4.5.6 + |baz|baz|4.5.6 + |foo|bar|1.2.3 + |=== + == Resources [cols="a",options="header,autowidth"] @@ -390,4 +400,4 @@ generates the following output: |unquoted |It's unquoted output. |=== -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/asciidoc.md b/docs/formats/asciidoc.md index 561eb23..f0f0469 100644 --- a/docs/formats/asciidoc.md +++ b/docs/formats/asciidoc.md @@ -24,11 +24,11 @@ terraform-docs asciidoc [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -40,4 +40,4 @@ terraform-docs asciidoc [PATH] [flags] * [terraform-docs asciidoc document](/docs/formats/asciidoc-document.md) - Generate AsciiDoc document of inputs and outputs * [terraform-docs asciidoc table](/docs/formats/asciidoc-table.md) - Generate AsciiDoc tables of inputs and outputs -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/json.md b/docs/formats/json.md index 81fde89..ffe1bea 100644 --- a/docs/formats/json.md +++ b/docs/formats/json.md @@ -22,11 +22,11 @@ terraform-docs json [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -289,6 +289,23 @@ generates the following output: "required": false } ], + "modules": [ + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + } + ], "outputs": [ { "name": "output-0.12", @@ -368,4 +385,4 @@ generates the following output: ] } -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/markdown-document.md b/docs/formats/markdown-document.md index 595a88a..6bf6a05 100644 --- a/docs/formats/markdown-document.md +++ b/docs/formats/markdown-document.md @@ -22,14 +22,14 @@ terraform-docs markdown document [PATH] [flags] -c, --config string config file name (default ".terraform-docs.yml") --escape escape special characters (default true) --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") --required show Required column or section (default true) --sensitive show Sensitive column or section (default true) - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -106,6 +106,28 @@ generates the following output: - tls + ## Modules + + The following Modules are called: + + ### bar + + Source: baz + + Version: 4.5.6 + + ### baz + + Source: baz + + Version: 4.5.6 + + ### foo + + Source: bar + + Version: 1.2.3 + ## Resources The following resources are used by this module: @@ -435,4 +457,4 @@ generates the following output: Description: It's unquoted output. -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/markdown-table.md b/docs/formats/markdown-table.md index f8e4955..34a4d10 100644 --- a/docs/formats/markdown-table.md +++ b/docs/formats/markdown-table.md @@ -22,14 +22,14 @@ terraform-docs markdown table [PATH] [flags] -c, --config string config file name (default ".terraform-docs.yml") --escape escape special characters (default true) --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") --required show Required column or section (default true) --sensitive show Sensitive column or section (default true) - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -101,6 +101,14 @@ generates the following output: | null | n/a | | tls | n/a | + ## Modules + + | Name | Source | Version | + |------|--------|---------| + | bar | baz | 4.5.6 | + | baz | baz | 4.5.6 | + | foo | bar | 1.2.3 | + ## Resources | Name | @@ -154,4 +162,4 @@ generates the following output: | output-2 | It's output number two. | | unquoted | It's unquoted output. | -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/markdown.md b/docs/formats/markdown.md index 85cd58b..e25974b 100644 --- a/docs/formats/markdown.md +++ b/docs/formats/markdown.md @@ -25,11 +25,11 @@ terraform-docs markdown [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -41,4 +41,4 @@ terraform-docs markdown [PATH] [flags] * [terraform-docs markdown document](/docs/formats/markdown-document.md) - Generate Markdown document of inputs and outputs * [terraform-docs markdown table](/docs/formats/markdown-table.md) - Generate Markdown tables of inputs and outputs -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/pretty.md b/docs/formats/pretty.md index 40de2c2..d760cd7 100644 --- a/docs/formats/pretty.md +++ b/docs/formats/pretty.md @@ -22,11 +22,11 @@ terraform-docs pretty [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -93,6 +93,11 @@ generates the following output: provider.tls + modulecall.bar (baz,4.5.6) + modulecall.baz (baz,4.5.6) + modulecall.foo (bar,1.2.3) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) @@ -237,4 +242,4 @@ generates the following output: output.unquoted It's unquoted output. -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/tfvars-hcl.md b/docs/formats/tfvars-hcl.md index effe55f..9487098 100644 --- a/docs/formats/tfvars-hcl.md +++ b/docs/formats/tfvars-hcl.md @@ -21,11 +21,11 @@ terraform-docs tfvars hcl [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -99,4 +99,4 @@ generates the following output: unquoted = "" with-url = "" -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/tfvars-json.md b/docs/formats/tfvars-json.md index 63dd580..b69adb0 100644 --- a/docs/formats/tfvars-json.md +++ b/docs/formats/tfvars-json.md @@ -21,11 +21,11 @@ terraform-docs tfvars json [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -101,4 +101,4 @@ generates the following output: "with-url": "" } -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/tfvars.md b/docs/formats/tfvars.md index 6bfc4b0..cc415cf 100644 --- a/docs/formats/tfvars.md +++ b/docs/formats/tfvars.md @@ -17,11 +17,11 @@ Generate terraform.tfvars of inputs ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -33,4 +33,4 @@ Generate terraform.tfvars of inputs * [terraform-docs tfvars hcl](/docs/formats/tfvars-hcl.md) - Generate HCL format of terraform.tfvars of inputs * [terraform-docs tfvars json](/docs/formats/tfvars-json.md) - Generate JSON format of terraform.tfvars of inputs -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/toml.md b/docs/formats/toml.md index 591ddfb..b4f2049 100644 --- a/docs/formats/toml.md +++ b/docs/formats/toml.md @@ -21,11 +21,11 @@ terraform-docs toml [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -273,6 +273,21 @@ generates the following output: default = "" required = false + [[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + + [[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + + [[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + [[outputs]] name = "output-0.12" description = "terraform 0.12 only" @@ -342,4 +357,4 @@ generates the following output: mode = "managed" version = "latest" -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/xml.md b/docs/formats/xml.md index 988e612..9747ac2 100644 --- a/docs/formats/xml.md +++ b/docs/formats/xml.md @@ -21,11 +21,11 @@ terraform-docs xml [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -288,6 +288,23 @@ generates the following output: false + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + + foo + bar + 1.2.3 + + output-0.12 @@ -367,4 +384,4 @@ generates the following output: -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/docs/formats/yaml.md b/docs/formats/yaml.md index 0ae3ad3..9be52a3 100644 --- a/docs/formats/yaml.md +++ b/docs/formats/yaml.md @@ -21,11 +21,11 @@ terraform-docs yaml [PATH] [flags] ``` -c, --config string config file name (default ".terraform-docs.yml") --header-from string relative path of a file to read header from (default "main.tf") - --hide strings hide section [header, inputs, outputs, providers, requirements, resources] + --hide strings hide section [header, inputs, modules, outputs, providers, requirements, resources] --hide-all hide all sections (default false) --output-values inject output values into outputs (default false) --output-values-from string inject output values from file into outputs (default "") - --show strings show section [header, inputs, outputs, providers, requirements, resources] + --show strings show section [header, inputs, modules, outputs, providers, requirements, resources] --show-all show all sections (default true) --sort sort items (default true) --sort-by-required sort items by name and print required ones first (default false) @@ -264,6 +264,16 @@ generates the following output: description: The description contains url. https://www.domain.com/foo/bar_baz.html default: "" required: false + modules: + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 + - name: foo + source: bar + version: 1.2.3 outputs: - name: output-0.12 description: terraform 0.12 only @@ -310,4 +320,4 @@ generates the following output: mode: managed version: latest -###### Auto generated by spf13/cobra on 29-Jan-2021 +###### Auto generated by spf13/cobra on 9-Feb-2021 diff --git a/examples/.terraform-docs.yml b/examples/.terraform-docs.yml index 53bfa12..0130f91 100644 --- a/examples/.terraform-docs.yml +++ b/examples/.terraform-docs.yml @@ -6,6 +6,7 @@ sections: - header - inputs - providers + - modules sort: enabled: true by: diff --git a/examples/main.tf b/examples/main.tf index ed76609..ad823fd 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -57,3 +57,18 @@ data "aws_caller_identity" "ident" { } resource "null_resource" "foo" {} + +module "foo" { + source = "bar" + version = "1.2.3" +} + +module "bar" { + source = "baz" + version = "4.5.6" +} + +module "baz" { + source = "baz" + version = "4.5.6" +} \ No newline at end of file diff --git a/go.mod b/go.mod index febb7cf..c2a36b0 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.6.1 - github.com/terraform-docs/plugin-sdk v0.0.0-20210202231042-605acf0f17df + github.com/terraform-docs/plugin-sdk v0.0.0-20210208180642-7974eb48f24e github.com/terraform-docs/terraform-config-inspect v0.0.0-20210126151735-6ef25af8884f gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 mvdan.cc/xurls/v2 v2.2.0 diff --git a/go.sum b/go.sum index b1b68dd..b279b3b 100644 --- a/go.sum +++ b/go.sum @@ -229,8 +229,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/terraform-docs/plugin-sdk v0.0.0-20210202231042-605acf0f17df h1:yUhokDmChf3PV1lHRwT8gaCz5oc2WQnVQQ+VddI2EQI= -github.com/terraform-docs/plugin-sdk v0.0.0-20210202231042-605acf0f17df/go.mod h1:H9E+yVwyOGLXcR28wcWaDODqmhKanZF/uj1H4uCesVM= +github.com/terraform-docs/plugin-sdk v0.0.0-20210208180642-7974eb48f24e h1:MUYLCKtUTrvsEh9MlQqvlLnAQ96miDsOzG5dfj7fKrQ= +github.com/terraform-docs/plugin-sdk v0.0.0-20210208180642-7974eb48f24e/go.mod h1:H9E+yVwyOGLXcR28wcWaDODqmhKanZF/uj1H4uCesVM= github.com/terraform-docs/terraform-config-inspect v0.0.0-20210126151735-6ef25af8884f h1:WXgHENMC8JOyj6aRpOlnAnJkZ3ZAkPBOhqYrJ5GOhDE= github.com/terraform-docs/terraform-config-inspect v0.0.0-20210126151735-6ef25af8884f/go.mod h1:GtanFwTsRRXScYHOMb5h4K18XQBFeS2tXat9/LrPtPc= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/internal/cli/config.go b/internal/cli/config.go index 517ea52..dda71e6 100644 --- a/internal/cli/config.go +++ b/internal/cli/config.go @@ -33,6 +33,7 @@ type sections struct { header bool `yaml:"-"` inputs bool `yaml:"-"` + modulecalls bool `yaml:"-"` outputs bool `yaml:"-"` providers bool `yaml:"-"` requirements bool `yaml:"-"` @@ -55,6 +56,7 @@ func defaultSections() sections { header: false, inputs: false, + modulecalls: false, outputs: false, providers: false, requirements: false, @@ -63,17 +65,17 @@ func defaultSections() sections { } func (s *sections) validate() error { - items := []string{"header", "inputs", "outputs", "providers", "requirements", "resources"} + items := []string{"header", "inputs", "modules", "outputs", "providers", "requirements", "resources"} for _, item := range s.Show { switch item { - case items[0], items[1], items[2], items[3], items[4], items[5]: + case items[0], items[1], items[2], items[3], items[4], items[5], items[6]: default: return fmt.Errorf("'%s' is not a valid section", item) } } for _, item := range s.Hide { switch item { - case items[0], items[1], items[2], items[3], items[4], items[5]: + case items[0], items[1], items[2], items[3], items[4], items[5], items[6]: default: return fmt.Errorf("'%s' is not a valid section", item) } diff --git a/internal/format/asciidoc_document.go b/internal/format/asciidoc_document.go index 70b3622..f3760d6 100644 --- a/internal/format/asciidoc_document.go +++ b/internal/format/asciidoc_document.go @@ -149,10 +149,30 @@ const ( {{ end -}} ` + asciidocDocumentModulecallsTpl = ` + {{- if .Settings.ShowModuleCalls -}} + {{ indent 0 "=" }} Modules + {{ if not .Module.ModuleCalls }} + No Modules. + {{ else }} + The following Modules are called: + {{- range .Module.ModuleCalls }} + + {{ indent 1 "=" }} {{ name .Name }} + + Source: {{ .Source }} + + Version: {{ .Version }} + {{- end }} + {{ end }} + {{ end -}} + ` + asciidocDocumentTpl = ` {{- template "header" . -}} {{- template "requirements" . -}} {{- template "providers" . -}} + {{- template "modulecalls" . -}} {{- template "resources" . -}} {{- template "inputs" . -}} {{- template "outputs" . -}} @@ -191,6 +211,9 @@ func NewAsciidocDocument(settings *print.Settings) print.Engine { }, &template.Item{ Name: "outputs", Text: asciidocDocumentOutputsTpl, + }, &template.Item{ + Name: "modulecalls", + Text: asciidocDocumentModulecallsTpl, }) tt.CustomFunc(gotemplate.FuncMap{ "type": func(t string) string { diff --git a/internal/format/asciidoc_document_test.go b/internal/format/asciidoc_document_test.go index 1a098d2..cb0180f 100644 --- a/internal/format/asciidoc_document_test.go +++ b/internal/format/asciidoc_document_test.go @@ -143,6 +143,7 @@ func TestAsciidocDocumentNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,6 +169,7 @@ func TestAsciidocDocumentNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -188,11 +190,38 @@ func TestAsciidocDocumentNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestAsciidocDocumentNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("asciidoc", "document-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewAsciidocDocument(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestAsciidocDocumentNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -218,6 +247,7 @@ func TestAsciidocDocumentNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -243,6 +273,7 @@ func TestAsciidocDocumentNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -268,6 +299,7 @@ func TestAsciidocDocumentNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -293,6 +325,7 @@ func TestAsciidocDocumentOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,6 +351,7 @@ func TestAsciidocDocumentOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -338,11 +372,38 @@ func TestAsciidocDocumentOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestAsciidocDocumentOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("asciidoc", "document-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewAsciidocDocument(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestAsciidocDocumentOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -368,6 +429,7 @@ func TestAsciidocDocumentOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -393,6 +455,7 @@ func TestAsciidocDocumentOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -418,6 +481,7 @@ func TestAsciidocDocumentOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -605,10 +669,13 @@ func TestAsciidocDocumentOutputValuesNoSensitivity(t *testing.T) { func TestAsciidocDocumentEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, }).Build() options, err := terraform.NewOptions().WithOverwrite(&terraform.Options{ diff --git a/internal/format/asciidoc_table.go b/internal/format/asciidoc_table.go index 0df50c8..5652b88 100644 --- a/internal/format/asciidoc_table.go +++ b/internal/format/asciidoc_table.go @@ -127,10 +127,28 @@ const ( {{ end -}} ` + asciidocTableModulecallsTpl = ` + {{- if .Settings.ShowModuleCalls -}} + {{ indent 0 "=" }} Modules + {{ if not .Module.ModuleCalls }} + No Modules. + {{ else }} + [cols="a,a,a",options="header,autowidth"] + |=== + |Name|Source|Version| + {{- range .Module.ModuleCalls }} + |{{ .Name }}|{{ .Source }}|{{ .Version }} + {{- end }} + |=== + {{ end }} + {{ end -}} + ` + asciidocTableTpl = ` {{- template "header" . -}} {{- template "requirements" . -}} {{- template "providers" . -}} + {{- template "modulecalls" . -}} {{- template "resources" . -}} {{- template "inputs" . -}} {{- template "outputs" . -}} @@ -166,6 +184,9 @@ func NewAsciidocTable(settings *print.Settings) print.Engine { }, &template.Item{ Name: "outputs", Text: asciidocTableOutputsTpl, + }, &template.Item{ + Name: "modulecalls", + Text: asciidocTableModulecallsTpl, }) tt.CustomFunc(gotemplate.FuncMap{ "type": func(t string) string { diff --git a/internal/format/asciidoc_table_test.go b/internal/format/asciidoc_table_test.go index 4368a41..7a6ec64 100644 --- a/internal/format/asciidoc_table_test.go +++ b/internal/format/asciidoc_table_test.go @@ -143,6 +143,7 @@ func TestAsciidocTableNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,6 +169,7 @@ func TestAsciidocTableNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -188,11 +190,37 @@ func TestAsciidocTableNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestAsciidocTableNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("asciidoc", "table-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewAsciidocTable(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} func TestAsciidocTableNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -218,6 +246,7 @@ func TestAsciidocTableNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -243,6 +272,7 @@ func TestAsciidocTableNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -268,6 +298,7 @@ func TestAsciidocTableNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -293,6 +324,7 @@ func TestAsciidocTableOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,6 +350,7 @@ func TestAsciidocTableOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -338,11 +371,38 @@ func TestAsciidocTableOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestAsciidocTableOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("asciidoc", "table-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewAsciidocTable(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestAsciidocTableOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -368,6 +428,7 @@ func TestAsciidocTableOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -393,6 +454,7 @@ func TestAsciidocTableOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -418,6 +480,7 @@ func TestAsciidocTableOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -605,10 +668,13 @@ func TestAsciidocTableOutputValuesNoSensitivity(t *testing.T) { func TestAsciidocTableEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, }).Build() options, err := terraform.NewOptions().WithOverwrite(&terraform.Options{ diff --git a/internal/format/json.go b/internal/format/json.go index 41ee022..a380063 100644 --- a/internal/format/json.go +++ b/internal/format/json.go @@ -32,6 +32,7 @@ func (j *JSON) Print(module *terraform.Module, settings *print.Settings) (string copy := &terraform.Module{ Header: "", Inputs: make([]*terraform.Input, 0), + ModuleCalls: make([]*terraform.ModuleCall, 0), Outputs: make([]*terraform.Output, 0), Providers: make([]*terraform.Provider, 0), Requirements: make([]*terraform.Requirement, 0), @@ -44,6 +45,9 @@ func (j *JSON) Print(module *terraform.Module, settings *print.Settings) (string if settings.ShowInputs { copy.Inputs = module.Inputs } + if settings.ShowModuleCalls { + copy.ModuleCalls = module.ModuleCalls + } if settings.ShowOutputs { copy.Outputs = module.Outputs } diff --git a/internal/format/json_test.go b/internal/format/json_test.go index 57c806b..a95d72d 100644 --- a/internal/format/json_test.go +++ b/internal/format/json_test.go @@ -123,6 +123,7 @@ func TestJsonNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -148,6 +149,7 @@ func TestJsonNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,11 +170,38 @@ func TestJsonNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestJsonNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("json", "json-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewJSON(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestJsonNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -198,6 +227,7 @@ func TestJsonNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -223,6 +253,7 @@ func TestJsonNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -273,6 +304,7 @@ func TestJsonOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -298,6 +330,7 @@ func TestJsonOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,11 +351,38 @@ func TestJsonOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestJsonOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("json", "json-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewJSON(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestJsonOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -348,6 +408,7 @@ func TestJsonOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -373,6 +434,7 @@ func TestJsonOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -398,6 +460,7 @@ func TestJsonOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -518,10 +581,13 @@ func TestJsonHeaderFromFile(t *testing.T) { func TestJsonEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, }).Build() expected, err := testutil.GetExpected("json", "json-Empty") diff --git a/internal/format/markdown_document.go b/internal/format/markdown_document.go index 02396b7..1a19817 100644 --- a/internal/format/markdown_document.go +++ b/internal/format/markdown_document.go @@ -149,10 +149,31 @@ const ( {{ end -}} ` + documentModulecallsTpl = ` + {{- if .Settings.ShowModuleCalls -}} + {{ indent 0 "#" }} Modules + {{ if not .Module.ModuleCalls }} + No Modules. + {{ else }} + The following Modules are called: + {{- range .Module.ModuleCalls }} + + {{ indent 1 "#" }} {{ name .Name }} + + Source: {{ .Source }} + + Version: {{ .Version }} + + {{ end }} + {{ end }} + {{ end -}} + ` + documentTpl = ` {{- template "header" . -}} {{- template "requirements" . -}} {{- template "providers" . -}} + {{- template "modulecalls" . -}} {{- template "resources" . -}} {{- template "inputs" . -}} {{- template "outputs" . -}} @@ -190,6 +211,9 @@ func NewMarkdownDocument(settings *print.Settings) print.Engine { }, &template.Item{ Name: "outputs", Text: documentOutputsTpl, + }, &template.Item{ + Name: "modulecalls", + Text: documentModulecallsTpl, }) tt.CustomFunc(gotemplate.FuncMap{ "type": func(t string) string { diff --git a/internal/format/markdown_document_test.go b/internal/format/markdown_document_test.go index 990aa2b..9eafb23 100644 --- a/internal/format/markdown_document_test.go +++ b/internal/format/markdown_document_test.go @@ -143,6 +143,7 @@ func TestDocumentNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,6 +169,7 @@ func TestDocumentNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -188,11 +190,37 @@ func TestDocumentNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestDocumentNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + }).Build() + + expected, err := testutil.GetExpected("markdown", "document-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewMarkdownDocument(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestDocumentNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -218,6 +246,7 @@ func TestDocumentNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -243,6 +272,7 @@ func TestDocumentNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -293,6 +323,7 @@ func TestDocumentOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,6 +349,7 @@ func TestDocumentOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -338,11 +370,37 @@ func TestDocumentOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestDocumentOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + }).Build() + + expected, err := testutil.GetExpected("markdown", "document-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewMarkdownDocument(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestDocumentOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -368,6 +426,7 @@ func TestDocumentOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -393,6 +452,7 @@ func TestDocumentOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -625,10 +685,11 @@ func TestDocumentOutputValuesNoSensitivity(t *testing.T) { func TestDocumentEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowProviders: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, }).Build() options, err := terraform.NewOptions().WithOverwrite(&terraform.Options{ diff --git a/internal/format/markdown_table.go b/internal/format/markdown_table.go index dd5695b..f8c74aa 100644 --- a/internal/format/markdown_table.go +++ b/internal/format/markdown_table.go @@ -116,10 +116,26 @@ const ( {{ end -}} ` + tableModulecallsTpl = ` + {{- if .Settings.ShowModuleCalls -}} + {{ indent 0 "#" }} Modules + {{ if not .Module.ModuleCalls }} + No Modules. + {{ else }} + | Name | Source | Version | + |------|--------|---------| + {{- range .Module.ModuleCalls }} + | {{ .Name }} | {{ .Source }} | {{ .Version }} | + {{- end }} + {{ end }} + {{ end -}} + ` + tableTpl = ` {{- template "header" . -}} {{- template "requirements" . -}} {{- template "providers" . -}} + {{- template "modulecalls" . -}} {{- template "resources" . -}} {{- template "inputs" . -}} {{- template "outputs" . -}} @@ -154,6 +170,9 @@ func NewMarkdownTable(settings *print.Settings) print.Engine { }, &template.Item{ Name: "outputs", Text: tableOutputsTpl, + }, &template.Item{ + Name: "modulecalls", + Text: tableModulecallsTpl, }) tt.CustomFunc(gotemplate.FuncMap{ "type": func(t string) string { diff --git a/internal/format/markdown_table_test.go b/internal/format/markdown_table_test.go index 49b0b5c..bfb5bb7 100644 --- a/internal/format/markdown_table_test.go +++ b/internal/format/markdown_table_test.go @@ -143,6 +143,7 @@ func TestTableNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,6 +169,7 @@ func TestTableNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -188,11 +190,38 @@ func TestTableNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestTableNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("markdown", "table-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewMarkdownTable(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestTableNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -218,6 +247,7 @@ func TestTableNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -243,6 +273,7 @@ func TestTableNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -268,6 +299,7 @@ func TestTableNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -293,6 +325,7 @@ func TestTableOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,6 +351,7 @@ func TestTableOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -338,11 +372,38 @@ func TestTableOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestTableOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("markdown", "table-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewMarkdownTable(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestTableOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -368,6 +429,7 @@ func TestTableOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -393,6 +455,7 @@ func TestTableOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -418,6 +481,7 @@ func TestTableOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -625,10 +689,11 @@ func TestTableOutputValuesNoSensitivity(t *testing.T) { func TestTableEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowProviders: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, }).Build() options, err := terraform.NewOptions().WithOverwrite(&terraform.Options{ diff --git a/internal/format/pretty.go b/internal/format/pretty.go index 637b8a5..83fd9d9 100644 --- a/internal/format/pretty.go +++ b/internal/format/pretty.go @@ -98,10 +98,22 @@ const ( {{ end -}} ` + prettyModulecallsTpl = ` + {{- if .Settings.ShowModuleCalls -}} + {{- with .Module.ModuleCalls }} + {{- range . }} + {{- printf "modulecall.%s" .Name | colorize "\033[36m" }}{{ printf " (%s)" .FullName }} + {{ end -}} + {{- printf "\n\n" -}} + {{ end -}} + {{ end -}} + ` + prettyTpl = ` {{- template "header" . -}} {{- template "requirements" . -}} {{- template "providers" . -}} + {{- template "modulecalls" . -}} {{- template "resources" . -}} {{- template "inputs" . -}} {{- template "outputs" . -}} @@ -136,6 +148,9 @@ func NewPretty(settings *print.Settings) print.Engine { }, &template.Item{ Name: "outputs", Text: prettyOutputsTpl, + }, &template.Item{ + Name: "modulecalls", + Text: prettyModulecallsTpl, }) tt.CustomFunc(gotemplate.FuncMap{ "colorize": func(c string, s string) string { diff --git a/internal/format/pretty_test.go b/internal/format/pretty_test.go index 5ced0db..08c812f 100644 --- a/internal/format/pretty_test.go +++ b/internal/format/pretty_test.go @@ -123,6 +123,7 @@ func TestPrettyNoHeader(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -148,6 +149,7 @@ func TestPrettyNoInputs(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,11 +170,38 @@ func TestPrettyNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestPrettyNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithColor().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("pretty", "pretty-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewPretty(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestPrettyNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -198,6 +227,7 @@ func TestPrettyNoProviders(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -223,6 +253,7 @@ func TestPrettyNoRequirements(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -248,6 +279,7 @@ func TestPrettyNoResources(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -273,6 +305,7 @@ func TestPrettyOnlyHeader(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -298,6 +331,7 @@ func TestPrettyOnlyInputs(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,11 +352,38 @@ func TestPrettyOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestPrettyOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithColor().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("pretty", "pretty-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewPretty(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestPrettyOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -348,6 +409,7 @@ func TestPrettyOnlyProviders(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -373,6 +435,7 @@ func TestPrettyOnlyRequirements(t *testing.T) { settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -393,11 +456,12 @@ func TestPrettyOnlyRequirements(t *testing.T) { assert.Equal(expected, actual) } -func TestPrettyOnlyReources(t *testing.T) { +func TestPrettyOnlyResources(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().WithColor().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -518,10 +582,13 @@ func TestPrettyHeaderFromFile(t *testing.T) { func TestPrettyEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, }).Build() options, err := terraform.NewOptions().WithOverwrite(&terraform.Options{ diff --git a/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden index 43703ea..4527afd 100644 --- a/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden +++ b/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden index 174e617..2fed712 100644 --- a/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden +++ b/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden index cc5047d..249c184 100644 --- a/internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden +++ b/internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden index 6d81bae..05c2586 100644 --- a/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden +++ b/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-IndentationAboveAllowed.golden b/internal/format/testdata/asciidoc/document-IndentationAboveAllowed.golden index 4963b65..f7f6e54 100644 --- a/internal/format/testdata/asciidoc/document-IndentationAboveAllowed.golden +++ b/internal/format/testdata/asciidoc/document-IndentationAboveAllowed.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-IndentationBelowAllowed.golden b/internal/format/testdata/asciidoc/document-IndentationBelowAllowed.golden index 4963b65..f7f6e54 100644 --- a/internal/format/testdata/asciidoc/document-IndentationBelowAllowed.golden +++ b/internal/format/testdata/asciidoc/document-IndentationBelowAllowed.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-IndentationOfFour.golden b/internal/format/testdata/asciidoc/document-IndentationOfFour.golden index 910932c..53ca454 100644 --- a/internal/format/testdata/asciidoc/document-IndentationOfFour.golden +++ b/internal/format/testdata/asciidoc/document-IndentationOfFour.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +==== Modules + +The following Modules are called: + +===== foo + +Source: bar + +Version: 1.2.3 + +===== bar + +Source: baz + +Version: 4.5.6 + +===== baz + +Source: baz + +Version: 4.5.6 + ==== Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoHeader.golden b/internal/format/testdata/asciidoc/document-NoHeader.golden index 1ef582a..adeb5f0 100644 --- a/internal/format/testdata/asciidoc/document-NoHeader.golden +++ b/internal/format/testdata/asciidoc/document-NoHeader.golden @@ -20,6 +20,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoInputs.golden b/internal/format/testdata/asciidoc/document-NoInputs.golden index 5da9c7b..851de11 100644 --- a/internal/format/testdata/asciidoc/document-NoInputs.golden +++ b/internal/format/testdata/asciidoc/document-NoInputs.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoModulecalls.golden b/internal/format/testdata/asciidoc/document-NoModulecalls.golden new file mode 100644 index 0000000..4963b65 --- /dev/null +++ b/internal/format/testdata/asciidoc/document-NoModulecalls.golden @@ -0,0 +1,398 @@ +Usage: + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 + +Even inline **formatting** in _here_ is possible. +and some [link](https://domain.com/) + +* list item 3 +* list item 4 + +```hcl +module "foo_bar" { + source = "github.com/foo/bar" + + id = "1234567890" + name = "baz" + + zones = ["us-east-1", "us-west-1"] + + tags = { + Name = "baz" + Created-By = "first.last@email.com" + Date-Created = "20180101" + } +} +``` + +Here is some trailing text after code block, +followed by another line of text. + +| Name | Description | +|------|-----------------| +| Foo | Foo description | +| Bar | Bar description | + +== Requirements + +The following requirements are needed by this module: + +- terraform (>= 0.12) + +- aws (>= 2.15.0) + +- random (>= 2.2.0) + +== Providers + +The following providers are used by this module: + +- tls + +- aws (>= 2.15.0) + +- aws.ident (>= 2.15.0) + +- null + +== Resources + +The following resources are used by this module: + +- https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity[aws_caller_identity] +- https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource] +- https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key[tls_private_key] + +== Inputs + +The following input variables are supported: + +=== unquoted + +Description: n/a + +Type: `any` + +Default: n/a + +=== bool-3 + +Description: n/a + +Type: `bool` + +Default: `true` + +=== bool-2 + +Description: It's bool number two. + +Type: `bool` + +Default: `false` + +=== bool-1 + +Description: It's bool number one. + +Type: `bool` + +Default: `true` + +=== string-3 + +Description: n/a + +Type: `string` + +Default: `""` + +=== string-2 + +Description: It's string number two. + +Type: `string` + +Default: n/a + +=== string-1 + +Description: It's string number one. + +Type: `string` + +Default: `"bar"` + +=== string-special-chars + +Description: n/a + +Type: `string` + +Default: `"\\.<>[]{}_-"` + +=== number-3 + +Description: n/a + +Type: `number` + +Default: `"19"` + +=== number-4 + +Description: n/a + +Type: `number` + +Default: `15.75` + +=== number-2 + +Description: It's number number two. + +Type: `number` + +Default: n/a + +=== number-1 + +Description: It's number number one. + +Type: `number` + +Default: `42` + +=== map-3 + +Description: n/a + +Type: `map` + +Default: `{}` + +=== map-2 + +Description: It's map number two. + +Type: `map` + +Default: n/a + +=== map-1 + +Description: It's map number one. + +Type: `map` + +Default: +[source,json] +---- +{ + "a": 1, + "b": 2, + "c": 3 +} +---- + +=== list-3 + +Description: n/a + +Type: `list` + +Default: `[]` + +=== list-2 + +Description: It's list number two. + +Type: `list` + +Default: n/a + +=== list-1 + +Description: It's list number one. + +Type: `list` + +Default: +[source,json] +---- +[ + "a", + "b", + "c" +] +---- + +=== input_with_underscores + +Description: A variable with underscores. + +Type: `any` + +Default: n/a + +=== input-with-pipe + +Description: It includes v1 \| v2 \| v3 + +Type: `string` + +Default: `"v1"` + +=== input-with-code-block + +Description: This is a complicated one. We need a newline. +And an example in a code block +``` +default = [ + "machine rack01:neptune" +] +``` + +Type: `list` + +Default: +[source,json] +---- +[ + "name rack:location" +] +---- + +=== long_type + +Description: This description is itself markdown. + +It spans over multiple lines. + +Type: +[source,hcl] +---- +object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) +---- + +Default: +[source,json] +---- +{ + "bar": { + "bar": "bar", + "foo": "bar" + }, + "buzz": [ + "fizz", + "buzz" + ], + "fizz": [], + "foo": { + "bar": "foo", + "foo": "foo" + }, + "name": "hello" +} +---- + +=== no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + +=== with-url + +Description: The description contains url. https://www.domain.com/foo/bar_baz.html + +Type: `string` + +Default: `""` + +=== string_default_empty + +Description: n/a + +Type: `string` + +Default: `""` + +=== string_default_null + +Description: n/a + +Type: `string` + +Default: `null` + +=== string_no_default + +Description: n/a + +Type: `string` + +Default: n/a + +=== number_default_zero + +Description: n/a + +Type: `number` + +Default: `0` + +=== bool_default_false + +Description: n/a + +Type: `bool` + +Default: `false` + +=== list_default_empty + +Description: n/a + +Type: `list(string)` + +Default: `[]` + +=== object_default_empty + +Description: n/a + +Type: `object({})` + +Default: `{}` + +== Outputs + +The following outputs are exported: + +=== unquoted + +Description: It's unquoted output. + +=== output-2 + +Description: It's output number two. + +=== output-1 + +Description: It's output number one. + +=== output-0.12 + +Description: terraform 0.12 only \ No newline at end of file diff --git a/internal/format/testdata/asciidoc/document-NoOutputs.golden b/internal/format/testdata/asciidoc/document-NoOutputs.golden index 4ebb659..7320041 100644 --- a/internal/format/testdata/asciidoc/document-NoOutputs.golden +++ b/internal/format/testdata/asciidoc/document-NoOutputs.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoProviders.golden b/internal/format/testdata/asciidoc/document-NoProviders.golden index a0c892f..a845441 100644 --- a/internal/format/testdata/asciidoc/document-NoProviders.golden +++ b/internal/format/testdata/asciidoc/document-NoProviders.golden @@ -46,6 +46,28 @@ The following requirements are needed by this module: - random (>= 2.2.0) +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoRequirements.golden b/internal/format/testdata/asciidoc/document-NoRequirements.golden index 52cca80..3601fa6 100644 --- a/internal/format/testdata/asciidoc/document-NoRequirements.golden +++ b/internal/format/testdata/asciidoc/document-NoRequirements.golden @@ -48,6 +48,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-NoResources.golden b/internal/format/testdata/asciidoc/document-NoResources.golden index 8e96b2e..714c509 100644 --- a/internal/format/testdata/asciidoc/document-NoResources.golden +++ b/internal/format/testdata/asciidoc/document-NoResources.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Inputs The following input variables are supported: diff --git a/internal/format/testdata/asciidoc/document-OnlyModulecalls.golden b/internal/format/testdata/asciidoc/document-OnlyModulecalls.golden new file mode 100644 index 0000000..8552bbf --- /dev/null +++ b/internal/format/testdata/asciidoc/document-OnlyModulecalls.golden @@ -0,0 +1,21 @@ +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 \ No newline at end of file diff --git a/internal/format/testdata/asciidoc/document-OutputValues.golden b/internal/format/testdata/asciidoc/document-OutputValues.golden index efa6981..9eb1a66 100644 --- a/internal/format/testdata/asciidoc/document-OutputValues.golden +++ b/internal/format/testdata/asciidoc/document-OutputValues.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-OutputValuesNoSensitivity.golden b/internal/format/testdata/asciidoc/document-OutputValuesNoSensitivity.golden index f6dc002..e5d71a1 100644 --- a/internal/format/testdata/asciidoc/document-OutputValuesNoSensitivity.golden +++ b/internal/format/testdata/asciidoc/document-OutputValuesNoSensitivity.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-SortByName.golden b/internal/format/testdata/asciidoc/document-SortByName.golden index 7dcfe3f..8049e4c 100644 --- a/internal/format/testdata/asciidoc/document-SortByName.golden +++ b/internal/format/testdata/asciidoc/document-SortByName.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +== Modules + +The following Modules are called: + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + +=== foo + +Source: bar + +Version: 1.2.3 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-SortByRequired.golden b/internal/format/testdata/asciidoc/document-SortByRequired.golden index 5cc2559..3e27c0f 100644 --- a/internal/format/testdata/asciidoc/document-SortByRequired.golden +++ b/internal/format/testdata/asciidoc/document-SortByRequired.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +== Modules + +The following Modules are called: + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + +=== foo + +Source: bar + +Version: 1.2.3 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-SortByType.golden b/internal/format/testdata/asciidoc/document-SortByType.golden index c45d45b..35471a1 100644 --- a/internal/format/testdata/asciidoc/document-SortByType.golden +++ b/internal/format/testdata/asciidoc/document-SortByType.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document-WithRequired.golden b/internal/format/testdata/asciidoc/document-WithRequired.golden index 88db246..0b932de 100644 --- a/internal/format/testdata/asciidoc/document-WithRequired.golden +++ b/internal/format/testdata/asciidoc/document-WithRequired.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/document.golden b/internal/format/testdata/asciidoc/document.golden index 4963b65..f7f6e54 100644 --- a/internal/format/testdata/asciidoc/document.golden +++ b/internal/format/testdata/asciidoc/document.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +== Modules + +The following Modules are called: + +=== foo + +Source: bar + +Version: 1.2.3 + +=== bar + +Source: baz + +Version: 4.5.6 + +=== baz + +Source: baz + +Version: 4.5.6 + == Resources The following resources are used by this module: diff --git a/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden index 61f87db..d4fde86 100644 --- a/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden +++ b/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden @@ -28,6 +28,16 @@ esse cillum dolore eu fugiat nulla pariatur. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden index 6398732..eb179e5 100644 --- a/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden +++ b/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden @@ -28,6 +28,16 @@ esse cillum dolore eu fugiat nulla pariatur. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden index 730335e..b78260d 100644 --- a/internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden +++ b/internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden @@ -28,6 +28,16 @@ esse cillum dolore eu fugiat nulla pariatur. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden index ac85360..b7c171f 100644 --- a/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden +++ b/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden @@ -28,6 +28,16 @@ esse cillum dolore eu fugiat nulla pariatur. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-IndentationAboveAllowed.golden b/internal/format/testdata/asciidoc/table-IndentationAboveAllowed.golden index 91cc3f2..4f17522 100644 --- a/internal/format/testdata/asciidoc/table-IndentationAboveAllowed.golden +++ b/internal/format/testdata/asciidoc/table-IndentationAboveAllowed.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-IndentationBelowAllowed.golden b/internal/format/testdata/asciidoc/table-IndentationBelowAllowed.golden index 91cc3f2..4f17522 100644 --- a/internal/format/testdata/asciidoc/table-IndentationBelowAllowed.golden +++ b/internal/format/testdata/asciidoc/table-IndentationBelowAllowed.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-IndentationOfFour.golden b/internal/format/testdata/asciidoc/table-IndentationOfFour.golden index e67ba0b..3f5f9d1 100644 --- a/internal/format/testdata/asciidoc/table-IndentationOfFour.golden +++ b/internal/format/testdata/asciidoc/table-IndentationOfFour.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +==== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + ==== Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoHeader.golden b/internal/format/testdata/asciidoc/table-NoHeader.golden index fe849a6..4e9b2e9 100644 --- a/internal/format/testdata/asciidoc/table-NoHeader.golden +++ b/internal/format/testdata/asciidoc/table-NoHeader.golden @@ -19,6 +19,16 @@ |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoInputs.golden b/internal/format/testdata/asciidoc/table-NoInputs.golden index 314071f..9f5c409 100644 --- a/internal/format/testdata/asciidoc/table-NoInputs.golden +++ b/internal/format/testdata/asciidoc/table-NoInputs.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table.NoResources.golden b/internal/format/testdata/asciidoc/table-NoModulecalls.golden similarity index 89% rename from internal/format/testdata/asciidoc/table.NoResources.golden rename to internal/format/testdata/asciidoc/table-NoModulecalls.golden index 6ce177a..91cc3f2 100644 --- a/internal/format/testdata/asciidoc/table.NoResources.golden +++ b/internal/format/testdata/asciidoc/table-NoModulecalls.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Resources + +[cols="a",options="header,autowidth"] +|=== +|Name +|https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity[aws_caller_identity] +|https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource] +|https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key[tls_private_key] +|=== + == Inputs [cols="a,a,a,a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoOutputs.golden b/internal/format/testdata/asciidoc/table-NoOutputs.golden index d97c019..46d8e19 100644 --- a/internal/format/testdata/asciidoc/table-NoOutputs.golden +++ b/internal/format/testdata/asciidoc/table-NoOutputs.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoProviders.golden b/internal/format/testdata/asciidoc/table-NoProviders.golden index cdbea37..e9efa48 100644 --- a/internal/format/testdata/asciidoc/table-NoProviders.golden +++ b/internal/format/testdata/asciidoc/table-NoProviders.golden @@ -46,6 +46,16 @@ followed by another line of text. |random |>= 2.2.0 |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoRequirements.golden b/internal/format/testdata/asciidoc/table-NoRequirements.golden index b2b0aab..5b97496 100644 --- a/internal/format/testdata/asciidoc/table-NoRequirements.golden +++ b/internal/format/testdata/asciidoc/table-NoRequirements.golden @@ -47,6 +47,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-NoResources.golden b/internal/format/testdata/asciidoc/table-NoResources.golden index 6ce177a..395eb92 100644 --- a/internal/format/testdata/asciidoc/table-NoResources.golden +++ b/internal/format/testdata/asciidoc/table-NoResources.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Inputs [cols="a,a,a,a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-OnlyModulecalls.golden b/internal/format/testdata/asciidoc/table-OnlyModulecalls.golden new file mode 100644 index 0000000..3d96062 --- /dev/null +++ b/internal/format/testdata/asciidoc/table-OnlyModulecalls.golden @@ -0,0 +1,9 @@ +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== \ No newline at end of file diff --git a/internal/format/testdata/asciidoc/table-OutputValues.golden b/internal/format/testdata/asciidoc/table-OutputValues.golden index 0493bb9..8d8919b 100644 --- a/internal/format/testdata/asciidoc/table-OutputValues.golden +++ b/internal/format/testdata/asciidoc/table-OutputValues.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-OutputValuesNoSensitivity.golden b/internal/format/testdata/asciidoc/table-OutputValuesNoSensitivity.golden index fafaba3..867d07b 100644 --- a/internal/format/testdata/asciidoc/table-OutputValuesNoSensitivity.golden +++ b/internal/format/testdata/asciidoc/table-OutputValuesNoSensitivity.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-SortByName.golden b/internal/format/testdata/asciidoc/table-SortByName.golden index e60708a..5eb0b62 100644 --- a/internal/format/testdata/asciidoc/table-SortByName.golden +++ b/internal/format/testdata/asciidoc/table-SortByName.golden @@ -57,6 +57,16 @@ followed by another line of text. |tls |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|foo|bar|1.2.3 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-SortByRequired.golden b/internal/format/testdata/asciidoc/table-SortByRequired.golden index c8fe432..ff8ff67 100644 --- a/internal/format/testdata/asciidoc/table-SortByRequired.golden +++ b/internal/format/testdata/asciidoc/table-SortByRequired.golden @@ -57,6 +57,16 @@ followed by another line of text. |tls |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|foo|bar|1.2.3 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-SortByType.golden b/internal/format/testdata/asciidoc/table-SortByType.golden index e2e6d30..61bc61d 100644 --- a/internal/format/testdata/asciidoc/table-SortByType.golden +++ b/internal/format/testdata/asciidoc/table-SortByType.golden @@ -57,6 +57,16 @@ followed by another line of text. |tls |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table-WithRequired.golden b/internal/format/testdata/asciidoc/table-WithRequired.golden index 3edd49e..70b52ce 100644 --- a/internal/format/testdata/asciidoc/table-WithRequired.golden +++ b/internal/format/testdata/asciidoc/table-WithRequired.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/asciidoc/table.golden b/internal/format/testdata/asciidoc/table.golden index 91cc3f2..4f17522 100644 --- a/internal/format/testdata/asciidoc/table.golden +++ b/internal/format/testdata/asciidoc/table.golden @@ -57,6 +57,16 @@ followed by another line of text. |null |n/a |=== +== Modules + +[cols="a,a,a",options="header,autowidth"] +|=== +|Name|Source|Version| +|foo|bar|1.2.3 +|bar|baz|4.5.6 +|baz|baz|4.5.6 +|=== + == Resources [cols="a",options="header,autowidth"] diff --git a/internal/format/testdata/json/json-Empty.golden b/internal/format/testdata/json/json-Empty.golden index ee72607..b015014 100644 --- a/internal/format/testdata/json/json-Empty.golden +++ b/internal/format/testdata/json/json-Empty.golden @@ -1,6 +1,7 @@ { "header": "", "inputs": [], + "modules": [], "outputs": [], "providers": [], "requirements": [], diff --git a/internal/format/testdata/json/json-EscapeCharacters.golden b/internal/format/testdata/json/json-EscapeCharacters.golden index 7eb01e2..b8dbb72 100644 --- a/internal/format/testdata/json/json-EscapeCharacters.golden +++ b/internal/format/testdata/json/json-EscapeCharacters.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-HeaderFromADOCFile.golden b/internal/format/testdata/json/json-HeaderFromADOCFile.golden index 7d19d40..168f89c 100644 --- a/internal/format/testdata/json/json-HeaderFromADOCFile.golden +++ b/internal/format/testdata/json/json-HeaderFromADOCFile.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-HeaderFromMDFile.golden b/internal/format/testdata/json/json-HeaderFromMDFile.golden index 655240a..7fda4d7 100644 --- a/internal/format/testdata/json/json-HeaderFromMDFile.golden +++ b/internal/format/testdata/json/json-HeaderFromMDFile.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-HeaderFromTFFile.golden b/internal/format/testdata/json/json-HeaderFromTFFile.golden index 0a52770..18a99a5 100644 --- a/internal/format/testdata/json/json-HeaderFromTFFile.golden +++ b/internal/format/testdata/json/json-HeaderFromTFFile.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-HeaderFromTXTFile.golden b/internal/format/testdata/json/json-HeaderFromTXTFile.golden index 70877e9..60eb020 100644 --- a/internal/format/testdata/json/json-HeaderFromTXTFile.golden +++ b/internal/format/testdata/json/json-HeaderFromTXTFile.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-NoHeader.golden b/internal/format/testdata/json/json-NoHeader.golden index 325aa79..abd43df 100644 --- a/internal/format/testdata/json/json-NoHeader.golden +++ b/internal/format/testdata/json/json-NoHeader.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-NoInputs.golden b/internal/format/testdata/json/json-NoInputs.golden index 488a2bc..ac35127 100644 --- a/internal/format/testdata/json/json-NoInputs.golden +++ b/internal/format/testdata/json/json-NoInputs.golden @@ -1,6 +1,23 @@ { "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |", "inputs": [], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-NoModulecalls.golden b/internal/format/testdata/json/json-NoModulecalls.golden new file mode 100644 index 0000000..458ec32 --- /dev/null +++ b/internal/format/testdata/json/json-NoModulecalls.golden @@ -0,0 +1,325 @@ +{ + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |", + "inputs": [ + { + "name": "unquoted", + "type": "any", + "description": null, + "default": null, + "required": true + }, + { + "name": "bool-3", + "type": "bool", + "description": null, + "default": true, + "required": false + }, + { + "name": "bool-2", + "type": "bool", + "description": "It's bool number two.", + "default": false, + "required": false + }, + { + "name": "bool-1", + "type": "bool", + "description": "It's bool number one.", + "default": true, + "required": false + }, + { + "name": "string-3", + "type": "string", + "description": null, + "default": "", + "required": false + }, + { + "name": "string-2", + "type": "string", + "description": "It's string number two.", + "default": null, + "required": true + }, + { + "name": "string-1", + "type": "string", + "description": "It's string number one.", + "default": "bar", + "required": false + }, + { + "name": "string-special-chars", + "type": "string", + "description": null, + "default": "\\.<>[]{}_-", + "required": false + }, + { + "name": "number-3", + "type": "number", + "description": null, + "default": "19", + "required": false + }, + { + "name": "number-4", + "type": "number", + "description": null, + "default": 15.75, + "required": false + }, + { + "name": "number-2", + "type": "number", + "description": "It's number number two.", + "default": null, + "required": true + }, + { + "name": "number-1", + "type": "number", + "description": "It's number number one.", + "default": 42, + "required": false + }, + { + "name": "map-3", + "type": "map", + "description": null, + "default": {}, + "required": false + }, + { + "name": "map-2", + "type": "map", + "description": "It's map number two.", + "default": null, + "required": true + }, + { + "name": "map-1", + "type": "map", + "description": "It's map number one.", + "default": { + "a": 1, + "b": 2, + "c": 3 + }, + "required": false + }, + { + "name": "list-3", + "type": "list", + "description": null, + "default": [], + "required": false + }, + { + "name": "list-2", + "type": "list", + "description": "It's list number two.", + "default": null, + "required": true + }, + { + "name": "list-1", + "type": "list", + "description": "It's list number one.", + "default": [ + "a", + "b", + "c" + ], + "required": false + }, + { + "name": "input_with_underscores", + "type": "any", + "description": "A variable with underscores.", + "default": null, + "required": true + }, + { + "name": "input-with-pipe", + "type": "string", + "description": "It includes v1 | v2 | v3", + "default": "v1", + "required": false + }, + { + "name": "input-with-code-block", + "type": "list", + "description": "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n", + "default": [ + "name rack:location" + ], + "required": false + }, + { + "name": "long_type", + "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", + "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", + "default": { + "bar": { + "bar": "bar", + "foo": "bar" + }, + "buzz": [ + "fizz", + "buzz" + ], + "fizz": [], + "foo": { + "bar": "foo", + "foo": "foo" + }, + "name": "hello" + }, + "required": false + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "VALUE_WITH_UNDERSCORE", + "required": false + }, + { + "name": "with-url", + "type": "string", + "description": "The description contains url. https://www.domain.com/foo/bar_baz.html", + "default": "", + "required": false + }, + { + "name": "string_default_empty", + "type": "string", + "description": null, + "default": "", + "required": false + }, + { + "name": "string_default_null", + "type": "string", + "description": null, + "default": null, + "required": false + }, + { + "name": "string_no_default", + "type": "string", + "description": null, + "default": null, + "required": true + }, + { + "name": "number_default_zero", + "type": "number", + "description": null, + "default": 0, + "required": false + }, + { + "name": "bool_default_false", + "type": "bool", + "description": null, + "default": false, + "required": false + }, + { + "name": "list_default_empty", + "type": "list(string)", + "description": null, + "default": [], + "required": false + }, + { + "name": "object_default_empty", + "type": "object({})", + "description": null, + "default": {}, + "required": false + } + ], + "modules": [], + "outputs": [ + { + "name": "unquoted", + "description": "It's unquoted output." + }, + { + "name": "output-2", + "description": "It's output number two." + }, + { + "name": "output-1", + "description": "It's output number one." + }, + { + "name": "output-0.12", + "description": "terraform 0.12 only" + } + ], + "providers": [ + { + "name": "tls", + "alias": null, + "version": null + }, + { + "name": "aws", + "alias": null, + "version": ">= 2.15.0" + }, + { + "name": "aws", + "alias": "ident", + "version": ">= 2.15.0" + }, + { + "name": "null", + "alias": null, + "version": null + } + ], + "requirements": [ + { + "name": "terraform", + "version": ">= 0.12" + }, + { + "name": "aws", + "version": ">= 2.15.0" + }, + { + "name": "random", + "version": ">= 2.2.0" + } + ], + "resources": [ + { + "type": "caller_identity", + "providerName": "aws", + "provicerSource": "hashicorp/aws", + "mode": "data", + "version": "2.15.0" + }, + { + "type": "resource", + "providerName": "null", + "provicerSource": "hashicorp/null", + "mode": "managed", + "version": "latest" + }, + { + "type": "private_key", + "providerName": "tls", + "provicerSource": "hashicorp/tls", + "mode": "managed", + "version": "latest" + } + ] +} \ No newline at end of file diff --git a/internal/format/testdata/json/json-NoOutputs.golden b/internal/format/testdata/json/json-NoOutputs.golden index 647fa3d..4c5f996 100644 --- a/internal/format/testdata/json/json-NoOutputs.golden +++ b/internal/format/testdata/json/json-NoOutputs.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [], "providers": [ { diff --git a/internal/format/testdata/json/json-NoProviders.golden b/internal/format/testdata/json/json-NoProviders.golden index ee6a031..e2bc937 100644 --- a/internal/format/testdata/json/json-NoProviders.golden +++ b/internal/format/testdata/json/json-NoProviders.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-NoRequirements.golden b/internal/format/testdata/json/json-NoRequirements.golden index 855060f..b74df82 100644 --- a/internal/format/testdata/json/json-NoRequirements.golden +++ b/internal/format/testdata/json/json-NoRequirements.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-NoResources.golden b/internal/format/testdata/json/json-NoResources.golden index f8fd7bb..fda7953 100644 --- a/internal/format/testdata/json/json-NoResources.golden +++ b/internal/format/testdata/json/json-NoResources.golden @@ -244,6 +244,7 @@ "required": false } ], + "modules": [], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-OnlyHeader.golden b/internal/format/testdata/json/json-OnlyHeader.golden index f1c5aa2..52eceb8 100644 --- a/internal/format/testdata/json/json-OnlyHeader.golden +++ b/internal/format/testdata/json/json-OnlyHeader.golden @@ -1,6 +1,7 @@ { "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |", "inputs": [], + "modules": [], "outputs": [], "providers": [], "requirements": [], diff --git a/internal/format/testdata/json/json-OnlyInputs.golden b/internal/format/testdata/json/json-OnlyInputs.golden index 2b281d7..21feb1e 100644 --- a/internal/format/testdata/json/json-OnlyInputs.golden +++ b/internal/format/testdata/json/json-OnlyInputs.golden @@ -244,6 +244,7 @@ "required": false } ], + "modules": [], "outputs": [], "providers": [], "requirements": [], diff --git a/internal/format/testdata/json/json-OnlyModulecalls.golden b/internal/format/testdata/json/json-OnlyModulecalls.golden new file mode 100644 index 0000000..a39754a --- /dev/null +++ b/internal/format/testdata/json/json-OnlyModulecalls.golden @@ -0,0 +1,25 @@ +{ + "header": "", + "inputs": [], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], + "outputs": [], + "providers": [], + "requirements": [], + "resources": [] +} \ No newline at end of file diff --git a/internal/format/testdata/json/json-OnlyOutputs.golden b/internal/format/testdata/json/json-OnlyOutputs.golden index 7c9e5cb..20aa34e 100644 --- a/internal/format/testdata/json/json-OnlyOutputs.golden +++ b/internal/format/testdata/json/json-OnlyOutputs.golden @@ -1,6 +1,7 @@ { "header": "", "inputs": [], + "modules": [], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-OnlyProviders.golden b/internal/format/testdata/json/json-OnlyProviders.golden index 9af0f6f..f96a17c 100644 --- a/internal/format/testdata/json/json-OnlyProviders.golden +++ b/internal/format/testdata/json/json-OnlyProviders.golden @@ -1,6 +1,7 @@ { "header": "", "inputs": [], + "modules": [], "outputs": [], "providers": [ { diff --git a/internal/format/testdata/json/json-OnlyRequirements.golden b/internal/format/testdata/json/json-OnlyRequirements.golden index 6efbda4..0f50432 100644 --- a/internal/format/testdata/json/json-OnlyRequirements.golden +++ b/internal/format/testdata/json/json-OnlyRequirements.golden @@ -1,6 +1,7 @@ { "header": "", "inputs": [], + "modules": [], "outputs": [], "providers": [], "requirements": [ diff --git a/internal/format/testdata/json/json-OnlyResources.golden b/internal/format/testdata/json/json-OnlyResources.golden index 642486f..d71bc3b 100644 --- a/internal/format/testdata/json/json-OnlyResources.golden +++ b/internal/format/testdata/json/json-OnlyResources.golden @@ -1,6 +1,7 @@ { "header": "", "inputs": [], + "modules": [], "outputs": [], "providers": [], "requirements": [], diff --git a/internal/format/testdata/json/json-OutputValues.golden b/internal/format/testdata/json/json-OutputValues.golden index 4f694a2..205028a 100644 --- a/internal/format/testdata/json/json-OutputValues.golden +++ b/internal/format/testdata/json/json-OutputValues.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/json/json-SortByName.golden b/internal/format/testdata/json/json-SortByName.golden index e4aace3..ed83967 100644 --- a/internal/format/testdata/json/json-SortByName.golden +++ b/internal/format/testdata/json/json-SortByName.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + } + ], "outputs": [ { "name": "output-0.12", diff --git a/internal/format/testdata/json/json-SortByRequired.golden b/internal/format/testdata/json/json-SortByRequired.golden index d5c51bd..6af1eb1 100644 --- a/internal/format/testdata/json/json-SortByRequired.golden +++ b/internal/format/testdata/json/json-SortByRequired.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + } + ], "outputs": [ { "name": "output-0.12", diff --git a/internal/format/testdata/json/json-SortByType.golden b/internal/format/testdata/json/json-SortByType.golden index 8ae1c0a..cb14476 100644 --- a/internal/format/testdata/json/json-SortByType.golden +++ b/internal/format/testdata/json/json-SortByType.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "output-0.12", diff --git a/internal/format/testdata/json/json.golden b/internal/format/testdata/json/json.golden index 53661ad..8016b6d 100644 --- a/internal/format/testdata/json/json.golden +++ b/internal/format/testdata/json/json.golden @@ -244,6 +244,23 @@ "required": false } ], + "modules": [ + { + "name": "foo", + "source": "bar", + "version": "1.2.3" + }, + { + "name": "bar", + "source": "baz", + "version": "4.5.6" + }, + { + "name": "baz", + "source": "baz", + "version": "4.5.6" + } + ], "outputs": [ { "name": "unquoted", diff --git a/internal/format/testdata/markdown/document-EscapeCharacters.golden b/internal/format/testdata/markdown/document-EscapeCharacters.golden index 6251389..ccbcbec 100644 --- a/internal/format/testdata/markdown/document-EscapeCharacters.golden +++ b/internal/format/testdata/markdown/document-EscapeCharacters.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden b/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden index d78cc87..13a0419 100644 --- a/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden +++ b/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-HeaderFromMDFile.golden b/internal/format/testdata/markdown/document-HeaderFromMDFile.golden index e4fd58d..c520931 100644 --- a/internal/format/testdata/markdown/document-HeaderFromMDFile.golden +++ b/internal/format/testdata/markdown/document-HeaderFromMDFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-HeaderFromTFFile.golden b/internal/format/testdata/markdown/document-HeaderFromTFFile.golden index 7f6ed34..a4b6924 100644 --- a/internal/format/testdata/markdown/document-HeaderFromTFFile.golden +++ b/internal/format/testdata/markdown/document-HeaderFromTFFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden b/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden index 309c00b..3da197b 100644 --- a/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden +++ b/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden @@ -29,6 +29,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-IndentationAboveAllowed.golden b/internal/format/testdata/markdown/document-IndentationAboveAllowed.golden index 4a1842f..be3bcb2 100644 --- a/internal/format/testdata/markdown/document-IndentationAboveAllowed.golden +++ b/internal/format/testdata/markdown/document-IndentationAboveAllowed.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-IndentationBelowAllowed.golden b/internal/format/testdata/markdown/document-IndentationBelowAllowed.golden index 4a1842f..be3bcb2 100644 --- a/internal/format/testdata/markdown/document-IndentationBelowAllowed.golden +++ b/internal/format/testdata/markdown/document-IndentationBelowAllowed.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-IndentationOfFour.golden b/internal/format/testdata/markdown/document-IndentationOfFour.golden index db01d3d..40ac0e9 100644 --- a/internal/format/testdata/markdown/document-IndentationOfFour.golden +++ b/internal/format/testdata/markdown/document-IndentationOfFour.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +#### Modules + +The following Modules are called: + +##### foo + +Source: bar + +Version: 1.2.3 + +##### bar + +Source: baz + +Version: 4.5.6 + +##### baz + +Source: baz + +Version: 4.5.6 + #### Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-NoHeader.golden b/internal/format/testdata/markdown/document-NoHeader.golden index 86547c1..a06f100 100644 --- a/internal/format/testdata/markdown/document-NoHeader.golden +++ b/internal/format/testdata/markdown/document-NoHeader.golden @@ -20,6 +20,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-NoInputs.golden b/internal/format/testdata/markdown/document-NoInputs.golden index 1ed7e75..d994e07 100644 --- a/internal/format/testdata/markdown/document-NoInputs.golden +++ b/internal/format/testdata/markdown/document-NoInputs.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-NoModulecalls.golden b/internal/format/testdata/markdown/document-NoModulecalls.golden new file mode 100644 index 0000000..ef99b75 --- /dev/null +++ b/internal/format/testdata/markdown/document-NoModulecalls.golden @@ -0,0 +1,390 @@ +Usage: + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 + +Even inline **formatting** in _here_ is possible. +and some [link](https://domain.com/) + +* list item 3 +* list item 4 + +```hcl +module "foo_bar" { + source = "github.com/foo/bar" + + id = "1234567890" + name = "baz" + + zones = ["us-east-1", "us-west-1"] + + tags = { + Name = "baz" + Created-By = "first.last@email.com" + Date-Created = "20180101" + } +} +``` + +Here is some trailing text after code block, +followed by another line of text. + +| Name | Description | +|------|-----------------| +| Foo | Foo description | +| Bar | Bar description | + +## Requirements + +The following requirements are needed by this module: + +- terraform (>= 0.12) + +- aws (>= 2.15.0) + +- random (>= 2.2.0) + +## Providers + +The following providers are used by this module: + +- tls + +- aws (>= 2.15.0) + +- aws.ident (>= 2.15.0) + +- null + +## Inputs + +The following input variables are supported: + +### unquoted + +Description: n/a + +Type: `any` + +Default: n/a + +### bool-3 + +Description: n/a + +Type: `bool` + +Default: `true` + +### bool-2 + +Description: It's bool number two. + +Type: `bool` + +Default: `false` + +### bool-1 + +Description: It's bool number one. + +Type: `bool` + +Default: `true` + +### string-3 + +Description: n/a + +Type: `string` + +Default: `""` + +### string-2 + +Description: It's string number two. + +Type: `string` + +Default: n/a + +### string-1 + +Description: It's string number one. + +Type: `string` + +Default: `"bar"` + +### string-special-chars + +Description: n/a + +Type: `string` + +Default: `"\\.<>[]{}_-"` + +### number-3 + +Description: n/a + +Type: `number` + +Default: `"19"` + +### number-4 + +Description: n/a + +Type: `number` + +Default: `15.75` + +### number-2 + +Description: It's number number two. + +Type: `number` + +Default: n/a + +### number-1 + +Description: It's number number one. + +Type: `number` + +Default: `42` + +### map-3 + +Description: n/a + +Type: `map` + +Default: `{}` + +### map-2 + +Description: It's map number two. + +Type: `map` + +Default: n/a + +### map-1 + +Description: It's map number one. + +Type: `map` + +Default: + +```json +{ + "a": 1, + "b": 2, + "c": 3 +} +``` + +### list-3 + +Description: n/a + +Type: `list` + +Default: `[]` + +### list-2 + +Description: It's list number two. + +Type: `list` + +Default: n/a + +### list-1 + +Description: It's list number one. + +Type: `list` + +Default: + +```json +[ + "a", + "b", + "c" +] +``` + +### input_with_underscores + +Description: A variable with underscores. + +Type: `any` + +Default: n/a + +### input-with-pipe + +Description: It includes v1 \| v2 \| v3 + +Type: `string` + +Default: `"v1"` + +### input-with-code-block + +Description: This is a complicated one. We need a newline. +And an example in a code block +``` +default = [ + "machine rack01:neptune" +] +``` + +Type: `list` + +Default: + +```json +[ + "name rack:location" +] +``` + +### long_type + +Description: This description is itself markdown. + +It spans over multiple lines. + +Type: + +```hcl +object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) +``` + +Default: + +```json +{ + "bar": { + "bar": "bar", + "foo": "bar" + }, + "buzz": [ + "fizz", + "buzz" + ], + "fizz": [], + "foo": { + "bar": "foo", + "foo": "foo" + }, + "name": "hello" +} +``` + +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + +### with-url + +Description: The description contains url. https://www.domain.com/foo/bar_baz.html + +Type: `string` + +Default: `""` + +### string_default_empty + +Description: n/a + +Type: `string` + +Default: `""` + +### string_default_null + +Description: n/a + +Type: `string` + +Default: `null` + +### string_no_default + +Description: n/a + +Type: `string` + +Default: n/a + +### number_default_zero + +Description: n/a + +Type: `number` + +Default: `0` + +### bool_default_false + +Description: n/a + +Type: `bool` + +Default: `false` + +### list_default_empty + +Description: n/a + +Type: `list(string)` + +Default: `[]` + +### object_default_empty + +Description: n/a + +Type: `object({})` + +Default: `{}` + +## Outputs + +The following outputs are exported: + +### unquoted + +Description: It's unquoted output. + +### output-2 + +Description: It's output number two. + +### output-1 + +Description: It's output number one. + +### output-0.12 + +Description: terraform 0.12 only \ No newline at end of file diff --git a/internal/format/testdata/markdown/document-NoOutputs.golden b/internal/format/testdata/markdown/document-NoOutputs.golden index a389787..970405a 100644 --- a/internal/format/testdata/markdown/document-NoOutputs.golden +++ b/internal/format/testdata/markdown/document-NoOutputs.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-NoProviders.golden b/internal/format/testdata/markdown/document-NoProviders.golden index 486cfec..d54a13a 100644 --- a/internal/format/testdata/markdown/document-NoProviders.golden +++ b/internal/format/testdata/markdown/document-NoProviders.golden @@ -46,6 +46,28 @@ The following requirements are needed by this module: - random (>= 2.2.0) +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-NoRequirements.golden b/internal/format/testdata/markdown/document-NoRequirements.golden index bb248fb..beb4f06 100644 --- a/internal/format/testdata/markdown/document-NoRequirements.golden +++ b/internal/format/testdata/markdown/document-NoRequirements.golden @@ -48,6 +48,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-OnlyModulecalls.golden b/internal/format/testdata/markdown/document-OnlyModulecalls.golden new file mode 100644 index 0000000..6ba6a10 --- /dev/null +++ b/internal/format/testdata/markdown/document-OnlyModulecalls.golden @@ -0,0 +1,21 @@ +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 \ No newline at end of file diff --git a/internal/format/testdata/markdown/document-OutputValues.golden b/internal/format/testdata/markdown/document-OutputValues.golden index bed3a6d..87aa4ef 100644 --- a/internal/format/testdata/markdown/document-OutputValues.golden +++ b/internal/format/testdata/markdown/document-OutputValues.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-OutputValuesNoSensitivity.golden b/internal/format/testdata/markdown/document-OutputValuesNoSensitivity.golden index c50a264..68aacea 100644 --- a/internal/format/testdata/markdown/document-OutputValuesNoSensitivity.golden +++ b/internal/format/testdata/markdown/document-OutputValuesNoSensitivity.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-SortByName.golden b/internal/format/testdata/markdown/document-SortByName.golden index 4d483cf..c98e854 100644 --- a/internal/format/testdata/markdown/document-SortByName.golden +++ b/internal/format/testdata/markdown/document-SortByName.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +## Modules + +The following Modules are called: + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + +### foo + +Source: bar + +Version: 1.2.3 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-SortByRequired.golden b/internal/format/testdata/markdown/document-SortByRequired.golden index 2bc05cf..d918ea7 100644 --- a/internal/format/testdata/markdown/document-SortByRequired.golden +++ b/internal/format/testdata/markdown/document-SortByRequired.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +## Modules + +The following Modules are called: + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + +### foo + +Source: bar + +Version: 1.2.3 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-SortByType.golden b/internal/format/testdata/markdown/document-SortByType.golden index 2ccdd50..54d0659 100644 --- a/internal/format/testdata/markdown/document-SortByType.golden +++ b/internal/format/testdata/markdown/document-SortByType.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - tls +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document-WithRequired.golden b/internal/format/testdata/markdown/document-WithRequired.golden index 4961210..865fab2 100644 --- a/internal/format/testdata/markdown/document-WithRequired.golden +++ b/internal/format/testdata/markdown/document-WithRequired.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/document.golden b/internal/format/testdata/markdown/document.golden index 4a1842f..be3bcb2 100644 --- a/internal/format/testdata/markdown/document.golden +++ b/internal/format/testdata/markdown/document.golden @@ -58,6 +58,28 @@ The following providers are used by this module: - null +## Modules + +The following Modules are called: + +### foo + +Source: bar + +Version: 1.2.3 + +### bar + +Source: baz + +Version: 4.5.6 + +### baz + +Source: baz + +Version: 4.5.6 + ## Resources The following resources are used by this module: diff --git a/internal/format/testdata/markdown/table-EscapeCharacters.golden b/internal/format/testdata/markdown/table-EscapeCharacters.golden index c5ddaf7..bbc1888 100644 --- a/internal/format/testdata/markdown/table-EscapeCharacters.golden +++ b/internal/format/testdata/markdown/table-EscapeCharacters.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden b/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden index 07cbf95..2391fb2 100644 --- a/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden +++ b/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden @@ -24,6 +24,14 @@ esse cillum dolore eu fugiat nulla pariatur. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-HeaderFromMDFile.golden b/internal/format/testdata/markdown/table-HeaderFromMDFile.golden index 39ea626..fc18d5b 100644 --- a/internal/format/testdata/markdown/table-HeaderFromMDFile.golden +++ b/internal/format/testdata/markdown/table-HeaderFromMDFile.golden @@ -24,6 +24,14 @@ esse cillum dolore eu fugiat nulla pariatur. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-HeaderFromTFFile.golden b/internal/format/testdata/markdown/table-HeaderFromTFFile.golden index c541a56..57a06cb 100644 --- a/internal/format/testdata/markdown/table-HeaderFromTFFile.golden +++ b/internal/format/testdata/markdown/table-HeaderFromTFFile.golden @@ -24,6 +24,14 @@ esse cillum dolore eu fugiat nulla pariatur. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden b/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden index de28a01..31e617a 100644 --- a/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden +++ b/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden @@ -24,6 +24,14 @@ esse cillum dolore eu fugiat nulla pariatur. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-IndentationAboveAllowed.golden b/internal/format/testdata/markdown/table-IndentationAboveAllowed.golden index 7f3df00..41e0ef3 100644 --- a/internal/format/testdata/markdown/table-IndentationAboveAllowed.golden +++ b/internal/format/testdata/markdown/table-IndentationAboveAllowed.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-IndentationBelowAllowed.golden b/internal/format/testdata/markdown/table-IndentationBelowAllowed.golden index 7f3df00..41e0ef3 100644 --- a/internal/format/testdata/markdown/table-IndentationBelowAllowed.golden +++ b/internal/format/testdata/markdown/table-IndentationBelowAllowed.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-IndentationOfFour.golden b/internal/format/testdata/markdown/table-IndentationOfFour.golden index 6d0615c..8d21e9d 100644 --- a/internal/format/testdata/markdown/table-IndentationOfFour.golden +++ b/internal/format/testdata/markdown/table-IndentationOfFour.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +#### Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + #### Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoHeader.golden b/internal/format/testdata/markdown/table-NoHeader.golden index 77dd03a..53ef920 100644 --- a/internal/format/testdata/markdown/table-NoHeader.golden +++ b/internal/format/testdata/markdown/table-NoHeader.golden @@ -15,6 +15,14 @@ | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoInputs.golden b/internal/format/testdata/markdown/table-NoInputs.golden index f14f87e..0f50579 100644 --- a/internal/format/testdata/markdown/table-NoInputs.golden +++ b/internal/format/testdata/markdown/table-NoInputs.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoModulecalls.golden b/internal/format/testdata/markdown/table-NoModulecalls.golden new file mode 100644 index 0000000..7f3df00 --- /dev/null +++ b/internal/format/testdata/markdown/table-NoModulecalls.golden @@ -0,0 +1,107 @@ +Usage: + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 + +Even inline **formatting** in _here_ is possible. +and some [link](https://domain.com/) + +* list item 3 +* list item 4 + +```hcl +module "foo_bar" { + source = "github.com/foo/bar" + + id = "1234567890" + name = "baz" + + zones = ["us-east-1", "us-west-1"] + + tags = { + Name = "baz" + Created-By = "first.last@email.com" + Date-Created = "20180101" + } +} +``` + +Here is some trailing text after code block, +followed by another line of text. + +| Name | Description | +|------|-----------------| +| Foo | Foo description | +| Bar | Bar description | + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12 | +| aws | >= 2.15.0 | +| random | >= 2.2.0 | + +## Providers + +| Name | Version | +|------|---------| +| tls | n/a | +| aws | >= 2.15.0 | +| aws.ident | >= 2.15.0 | +| null | n/a | + +## Resources + +| Name | +|------| +| [aws_caller_identity](https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) | +| [null_resource](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | +| [tls_private_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | + +## Inputs + +| Name | Description | Type | Default | +|------|-------------|------|---------| +| unquoted | n/a | `any` | n/a | +| bool-3 | n/a | `bool` | `true` | +| bool-2 | It's bool number two. | `bool` | `false` | +| bool-1 | It's bool number one. | `bool` | `true` | +| string-3 | n/a | `string` | `""` | +| string-2 | It's string number two. | `string` | n/a | +| string-1 | It's string number one. | `string` | `"bar"` | +| string-special-chars | n/a | `string` | `"\\.<>[]{}_-"` | +| number-3 | n/a | `number` | `"19"` | +| number-4 | n/a | `number` | `15.75` | +| number-2 | It's number number two. | `number` | n/a | +| number-1 | It's number number one. | `number` | `42` | +| map-3 | n/a | `map` | `{}` | +| map-2 | It's map number two. | `map` | n/a | +| map-1 | It's map number one. | `map` |
{
"a": 1,
"b": 2,
"c": 3
}
| +| list-3 | n/a | `list` | `[]` | +| list-2 | It's list number two. | `list` | n/a | +| list-1 | It's list number one. | `list` |
[
"a",
"b",
"c"
]
| +| input_with_underscores | A variable with underscores. | `any` | n/a | +| input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | +| input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| +| long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | +| with-url | The description contains url. https://www.domain.com/foo/bar_baz.html | `string` | `""` | +| string_default_empty | n/a | `string` | `""` | +| string_default_null | n/a | `string` | `null` | +| string_no_default | n/a | `string` | n/a | +| number_default_zero | n/a | `number` | `0` | +| bool_default_false | n/a | `bool` | `false` | +| list_default_empty | n/a | `list(string)` | `[]` | +| object_default_empty | n/a | `object({})` | `{}` | + +## Outputs + +| Name | Description | +|------|-------------| +| unquoted | It's unquoted output. | +| output-2 | It's output number two. | +| output-1 | It's output number one. | +| output-0.12 | terraform 0.12 only | \ No newline at end of file diff --git a/internal/format/testdata/markdown/table-NoOutputs.golden b/internal/format/testdata/markdown/table-NoOutputs.golden index 9540580..4a6b536 100644 --- a/internal/format/testdata/markdown/table-NoOutputs.golden +++ b/internal/format/testdata/markdown/table-NoOutputs.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoProviders.golden b/internal/format/testdata/markdown/table-NoProviders.golden index b9f8282..9551120 100644 --- a/internal/format/testdata/markdown/table-NoProviders.golden +++ b/internal/format/testdata/markdown/table-NoProviders.golden @@ -44,6 +44,14 @@ followed by another line of text. | aws | >= 2.15.0 | | random | >= 2.2.0 | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoRequirements.golden b/internal/format/testdata/markdown/table-NoRequirements.golden index 46e8f46..6c86f43 100644 --- a/internal/format/testdata/markdown/table-NoRequirements.golden +++ b/internal/format/testdata/markdown/table-NoRequirements.golden @@ -45,6 +45,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-NoResources.golden b/internal/format/testdata/markdown/table-NoResources.golden index 4c2987e..deded0f 100644 --- a/internal/format/testdata/markdown/table-NoResources.golden +++ b/internal/format/testdata/markdown/table-NoResources.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Inputs | Name | Description | Type | Default | diff --git a/internal/format/testdata/markdown/table-OnlyModulecalls.golden b/internal/format/testdata/markdown/table-OnlyModulecalls.golden new file mode 100644 index 0000000..c982ec4 --- /dev/null +++ b/internal/format/testdata/markdown/table-OnlyModulecalls.golden @@ -0,0 +1,7 @@ +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | \ No newline at end of file diff --git a/internal/format/testdata/markdown/table-OutputValues.golden b/internal/format/testdata/markdown/table-OutputValues.golden index e8adca0..65e1246 100644 --- a/internal/format/testdata/markdown/table-OutputValues.golden +++ b/internal/format/testdata/markdown/table-OutputValues.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-OutputValuesNoSensitivity.golden b/internal/format/testdata/markdown/table-OutputValuesNoSensitivity.golden index 0629c73..f65f3cb 100644 --- a/internal/format/testdata/markdown/table-OutputValuesNoSensitivity.golden +++ b/internal/format/testdata/markdown/table-OutputValuesNoSensitivity.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-SortByName.golden b/internal/format/testdata/markdown/table-SortByName.golden index 5df89cc..7a9d37f 100644 --- a/internal/format/testdata/markdown/table-SortByName.golden +++ b/internal/format/testdata/markdown/table-SortByName.golden @@ -53,6 +53,14 @@ followed by another line of text. | null | n/a | | tls | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | +| foo | bar | 1.2.3 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-SortByRequired.golden b/internal/format/testdata/markdown/table-SortByRequired.golden index 1752412..7864dd9 100644 --- a/internal/format/testdata/markdown/table-SortByRequired.golden +++ b/internal/format/testdata/markdown/table-SortByRequired.golden @@ -53,6 +53,14 @@ followed by another line of text. | null | n/a | | tls | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | +| foo | bar | 1.2.3 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-SortByType.golden b/internal/format/testdata/markdown/table-SortByType.golden index 5bbf957..f932f5e 100644 --- a/internal/format/testdata/markdown/table-SortByType.golden +++ b/internal/format/testdata/markdown/table-SortByType.golden @@ -53,6 +53,14 @@ followed by another line of text. | null | n/a | | tls | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table-WithRequired.golden b/internal/format/testdata/markdown/table-WithRequired.golden index bd60e13..d626c5a 100644 --- a/internal/format/testdata/markdown/table-WithRequired.golden +++ b/internal/format/testdata/markdown/table-WithRequired.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/markdown/table.golden b/internal/format/testdata/markdown/table.golden index 7f3df00..41e0ef3 100644 --- a/internal/format/testdata/markdown/table.golden +++ b/internal/format/testdata/markdown/table.golden @@ -53,6 +53,14 @@ followed by another line of text. | aws.ident | >= 2.15.0 | | null | n/a | +## Modules + +| Name | Source | Version | +|------|--------|---------| +| foo | bar | 1.2.3 | +| bar | baz | 4.5.6 | +| baz | baz | 4.5.6 | + ## Resources | Name | diff --git a/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden index 638f535..01b841a 100644 --- a/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden +++ b/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden @@ -20,6 +20,11 @@ esse cillum dolore eu fugiat nulla pariatur. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden index 95330ce..4cabf62 100644 --- a/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden +++ b/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden @@ -20,6 +20,11 @@ esse cillum dolore eu fugiat nulla pariatur. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden index 3f5962c..60bdb38 100644 --- a/internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden +++ b/internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden @@ -19,6 +19,11 @@ esse cillum dolore eu fugiat nulla pariatur. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden index 93d5649..9e1d395 100644 --- a/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden +++ b/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden @@ -20,6 +20,11 @@ esse cillum dolore eu fugiat nulla pariatur. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoColor.golden b/internal/format/testdata/pretty/pretty-NoColor.golden index 6eaa697..e764d59 100644 --- a/internal/format/testdata/pretty/pretty-NoColor.golden +++ b/internal/format/testdata/pretty/pretty-NoColor.golden @@ -48,6 +48,11 @@ provider.aws.ident (>= 2.15.0) provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoHeader.golden b/internal/format/testdata/pretty/pretty-NoHeader.golden index d4d0069..b2e4d78 100644 --- a/internal/format/testdata/pretty/pretty-NoHeader.golden +++ b/internal/format/testdata/pretty/pretty-NoHeader.golden @@ -9,6 +9,11 @@ provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoInputs.golden b/internal/format/testdata/pretty/pretty-NoInputs.golden index f490838..631985e 100644 --- a/internal/format/testdata/pretty/pretty-NoInputs.golden +++ b/internal/format/testdata/pretty/pretty-NoInputs.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoModulecalls.golden b/internal/format/testdata/pretty/pretty-NoModulecalls.golden new file mode 100644 index 0000000..e61f295 --- /dev/null +++ b/internal/format/testdata/pretty/pretty-NoModulecalls.golden @@ -0,0 +1,193 @@ +Usage: + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 + +Even inline **formatting** in _here_ is possible. +and some [link](https://domain.com/) + +* list item 3 +* list item 4 + +```hcl +module "foo_bar" { + source = "github.com/foo/bar" + + id = "1234567890" + name = "baz" + + zones = ["us-east-1", "us-west-1"] + + tags = { + Name = "baz" + Created-By = "first.last@email.com" + Date-Created = "20180101" + } +} +``` + +Here is some trailing text after code block, +followed by another line of text. + +| Name | Description | +|------|-----------------| +| Foo | Foo description | +| Bar | Bar description | + + +requirement.terraform (>= 0.12) +requirement.aws (>= 2.15.0) +requirement.random (>= 2.2.0) + + +provider.tls +provider.aws (>= 2.15.0) +provider.aws.ident (>= 2.15.0) +provider.null + + +resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) +resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) +resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) + + +input.unquoted (required) +n/a + +input.bool-3 (true) +n/a + +input.bool-2 (false) +It's bool number two. + +input.bool-1 (true) +It's bool number one. + +input.string-3 ("") +n/a + +input.string-2 (required) +It's string number two. + +input.string-1 ("bar") +It's string number one. + +input.string-special-chars ("\\.<>[]{}_-") +n/a + +input.number-3 ("19") +n/a + +input.number-4 (15.75) +n/a + +input.number-2 (required) +It's number number two. + +input.number-1 (42) +It's number number one. + +input.map-3 ({}) +n/a + +input.map-2 (required) +It's map number two. + +input.map-1 ({ + "a": 1, + "b": 2, + "c": 3 +}) +It's map number one. + +input.list-3 ([]) +n/a + +input.list-2 (required) +It's list number two. + +input.list-1 ([ + "a", + "b", + "c" +]) +It's list number one. + +input.input_with_underscores (required) +A variable with underscores. + +input.input-with-pipe ("v1") +It includes v1 | v2 | v3 + +input.input-with-code-block ([ + "name rack:location" +]) +This is a complicated one. We need a newline. +And an example in a code block +``` +default = [ + "machine rack01:neptune" +] +``` + +input.long_type ({ + "bar": { + "bar": "bar", + "foo": "bar" + }, + "buzz": [ + "fizz", + "buzz" + ], + "fizz": [], + "foo": { + "bar": "foo", + "foo": "foo" + }, + "name": "hello" +}) +This description is itself markdown. + +It spans over multiple lines. + +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +input.with-url ("") +The description contains url. https://www.domain.com/foo/bar_baz.html + +input.string_default_empty ("") +n/a + +input.string_default_null (null) +n/a + +input.string_no_default (required) +n/a + +input.number_default_zero (0) +n/a + +input.bool_default_false (false) +n/a + +input.list_default_empty ([]) +n/a + +input.object_default_empty ({}) +n/a + + +output.unquoted +It's unquoted output. + +output.output-2 +It's output number two. + +output.output-1 +It's output number one. + +output.output-0.12 +terraform 0.12 only \ No newline at end of file diff --git a/internal/format/testdata/pretty/pretty-NoOutputs.golden b/internal/format/testdata/pretty/pretty-NoOutputs.golden index 79ee9cf..81f887c 100644 --- a/internal/format/testdata/pretty/pretty-NoOutputs.golden +++ b/internal/format/testdata/pretty/pretty-NoOutputs.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoProviders.golden b/internal/format/testdata/pretty/pretty-NoProviders.golden index 41b0b82..b68ee88 100644 --- a/internal/format/testdata/pretty/pretty-NoProviders.golden +++ b/internal/format/testdata/pretty/pretty-NoProviders.golden @@ -42,6 +42,11 @@ followed by another line of text. requirement.random (>= 2.2.0) +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoRequirements.golden b/internal/format/testdata/pretty/pretty-NoRequirements.golden index 71c9815..54e6138 100644 --- a/internal/format/testdata/pretty/pretty-NoRequirements.golden +++ b/internal/format/testdata/pretty/pretty-NoRequirements.golden @@ -43,6 +43,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-NoResources.golden b/internal/format/testdata/pretty/pretty-NoResources.golden index 2300f01..f7fd39e 100644 --- a/internal/format/testdata/pretty/pretty-NoResources.golden +++ b/internal/format/testdata/pretty/pretty-NoResources.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + input.unquoted (required) n/a diff --git a/internal/format/testdata/pretty/pretty-OnlyModulecalls.golden b/internal/format/testdata/pretty/pretty-OnlyModulecalls.golden new file mode 100644 index 0000000..e59d658 --- /dev/null +++ b/internal/format/testdata/pretty/pretty-OnlyModulecalls.golden @@ -0,0 +1,3 @@ +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) \ No newline at end of file diff --git a/internal/format/testdata/pretty/pretty-OutputValues.golden b/internal/format/testdata/pretty/pretty-OutputValues.golden index 8d68f88..984e706 100644 --- a/internal/format/testdata/pretty/pretty-OutputValues.golden +++ b/internal/format/testdata/pretty/pretty-OutputValues.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-SortByName.golden b/internal/format/testdata/pretty/pretty-SortByName.golden index e3c8cbe..f857ad5 100644 --- a/internal/format/testdata/pretty/pretty-SortByName.golden +++ b/internal/format/testdata/pretty/pretty-SortByName.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.tls +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) +modulecall.foo (bar,1.2.3) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-SortByRequired.golden b/internal/format/testdata/pretty/pretty-SortByRequired.golden index 813a921..d85a7bc 100644 --- a/internal/format/testdata/pretty/pretty-SortByRequired.golden +++ b/internal/format/testdata/pretty/pretty-SortByRequired.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.tls +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) +modulecall.foo (bar,1.2.3) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty-SortByType.golden b/internal/format/testdata/pretty/pretty-SortByType.golden index ab321d7..d2c2339 100644 --- a/internal/format/testdata/pretty/pretty-SortByType.golden +++ b/internal/format/testdata/pretty/pretty-SortByType.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.tls +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/pretty/pretty.golden b/internal/format/testdata/pretty/pretty.golden index e61f295..8017148 100644 --- a/internal/format/testdata/pretty/pretty.golden +++ b/internal/format/testdata/pretty/pretty.golden @@ -48,6 +48,11 @@ followed by another line of text. provider.null +modulecall.foo (bar,1.2.3) +modulecall.bar (baz,4.5.6) +modulecall.baz (baz,4.5.6) + + resource.aws_caller_identity (https://registry.terraform.io/providers/hashicorp/aws/2.15.0/docs/data-sources/caller_identity) resource.null_resource (https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) resource.tls_private_key (https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) diff --git a/internal/format/testdata/toml/toml-Empty.golden b/internal/format/testdata/toml/toml-Empty.golden index 92a21dd..9852941 100644 --- a/internal/format/testdata/toml/toml-Empty.golden +++ b/internal/format/testdata/toml/toml-Empty.golden @@ -1,5 +1,6 @@ header = "" inputs = [] +modules = [] outputs = [] providers = [] requirements = [] diff --git a/internal/format/testdata/toml/toml-HeaderFromFile.golden b/internal/format/testdata/toml/toml-HeaderFromFile.golden index 18710c4..2417075 100644 --- a/internal/format/testdata/toml/toml-HeaderFromFile.golden +++ b/internal/format/testdata/toml/toml-HeaderFromFile.golden @@ -229,6 +229,21 @@ header = "This header comes from a custom file\n\nLorem ipsum dolor sit amet, co required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-NoHeader.golden b/internal/format/testdata/toml/toml-NoHeader.golden index 70f290d..284d712 100644 --- a/internal/format/testdata/toml/toml-NoHeader.golden +++ b/internal/format/testdata/toml/toml-NoHeader.golden @@ -229,6 +229,21 @@ header = "" required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-NoInputs.golden b/internal/format/testdata/toml/toml-NoInputs.golden index 790047a..cda16b6 100644 --- a/internal/format/testdata/toml/toml-NoInputs.golden +++ b/internal/format/testdata/toml/toml-NoInputs.golden @@ -1,6 +1,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |" inputs = [] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-NoModulecalls.golden b/internal/format/testdata/toml/toml-NoModulecalls.golden new file mode 100644 index 0000000..a0d2b6f --- /dev/null +++ b/internal/format/testdata/toml/toml-NoModulecalls.golden @@ -0,0 +1,300 @@ +header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |" +modules = [] + +[[inputs]] + name = "unquoted" + type = "any" + description = "" + required = true + [inputs.default] + +[[inputs]] + name = "bool-3" + type = "bool" + description = "" + default = true + required = false + +[[inputs]] + name = "bool-2" + type = "bool" + description = "It's bool number two." + default = false + required = false + +[[inputs]] + name = "bool-1" + type = "bool" + description = "It's bool number one." + default = true + required = false + +[[inputs]] + name = "string-3" + type = "string" + description = "" + default = "" + required = false + +[[inputs]] + name = "string-2" + type = "string" + description = "It's string number two." + required = true + [inputs.default] + +[[inputs]] + name = "string-1" + type = "string" + description = "It's string number one." + default = "bar" + required = false + +[[inputs]] + name = "string-special-chars" + type = "string" + description = "" + default = "\\.<>[]{}_-" + required = false + +[[inputs]] + name = "number-3" + type = "number" + description = "" + default = "19" + required = false + +[[inputs]] + name = "number-4" + type = "number" + description = "" + default = 15.75 + required = false + +[[inputs]] + name = "number-2" + type = "number" + description = "It's number number two." + required = true + [inputs.default] + +[[inputs]] + name = "number-1" + type = "number" + description = "It's number number one." + default = 42.0 + required = false + +[[inputs]] + name = "map-3" + type = "map" + description = "" + required = false + [inputs.default] + +[[inputs]] + name = "map-2" + type = "map" + description = "It's map number two." + required = true + [inputs.default] + +[[inputs]] + name = "map-1" + type = "map" + description = "It's map number one." + required = false + [inputs.default] + a = 1.0 + b = 2.0 + c = 3.0 + +[[inputs]] + name = "list-3" + type = "list" + description = "" + default = [] + required = false + +[[inputs]] + name = "list-2" + type = "list" + description = "It's list number two." + required = true + [inputs.default] + +[[inputs]] + name = "list-1" + type = "list" + description = "It's list number one." + default = ["a", "b", "c"] + required = false + +[[inputs]] + name = "input_with_underscores" + type = "any" + description = "A variable with underscores." + required = true + [inputs.default] + +[[inputs]] + name = "input-with-pipe" + type = "string" + description = "It includes v1 | v2 | v3" + default = "v1" + required = false + +[[inputs]] + name = "input-with-code-block" + type = "list" + description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n" + default = ["name rack:location"] + required = false + +[[inputs]] + name = "long_type" + type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })" + description = "This description is itself markdown.\n\nIt spans over multiple lines.\n" + required = false + [inputs.default] + buzz = ["fizz", "buzz"] + fizz = [] + name = "hello" + [inputs.default.bar] + bar = "bar" + foo = "bar" + [inputs.default.foo] + bar = "foo" + foo = "foo" + +[[inputs]] + name = "no-escape-default-value" + type = "string" + description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'." + default = "VALUE_WITH_UNDERSCORE" + required = false + +[[inputs]] + name = "with-url" + type = "string" + description = "The description contains url. https://www.domain.com/foo/bar_baz.html" + default = "" + required = false + +[[inputs]] + name = "string_default_empty" + type = "string" + description = "" + default = "" + required = false + +[[inputs]] + name = "string_default_null" + type = "string" + description = "" + required = false + [inputs.default] + +[[inputs]] + name = "string_no_default" + type = "string" + description = "" + required = true + [inputs.default] + +[[inputs]] + name = "number_default_zero" + type = "number" + description = "" + default = 0.0 + required = false + +[[inputs]] + name = "bool_default_false" + type = "bool" + description = "" + default = false + required = false + +[[inputs]] + name = "list_default_empty" + type = "list(string)" + description = "" + default = [] + required = false + +[[inputs]] + name = "object_default_empty" + type = "object({})" + description = "" + required = false + [inputs.default] + +[[outputs]] + name = "unquoted" + description = "It's unquoted output." + +[[outputs]] + name = "output-2" + description = "It's output number two." + +[[outputs]] + name = "output-1" + description = "It's output number one." + +[[outputs]] + name = "output-0.12" + description = "terraform 0.12 only" + +[[providers]] + name = "tls" + alias = "" + version = "" + +[[providers]] + name = "aws" + alias = "" + version = ">= 2.15.0" + +[[providers]] + name = "aws" + alias = "ident" + version = ">= 2.15.0" + +[[providers]] + name = "null" + alias = "" + version = "" + +[[requirements]] + Name = "terraform" + Version = ">= 0.12" + +[[requirements]] + Name = "aws" + Version = ">= 2.15.0" + +[[requirements]] + Name = "random" + Version = ">= 2.2.0" + +[[resources]] + type = "caller_identity" + providerName = "aws" + providerSource = "hashicorp/aws" + mode = "data" + version = "2.15.0" + +[[resources]] + type = "resource" + providerName = "null" + providerSource = "hashicorp/null" + mode = "managed" + version = "latest" + +[[resources]] + type = "private_key" + providerName = "tls" + providerSource = "hashicorp/tls" + mode = "managed" + version = "latest" \ No newline at end of file diff --git a/internal/format/testdata/toml/toml-NoOutputs.golden b/internal/format/testdata/toml/toml-NoOutputs.golden index 9484760..c700c32 100644 --- a/internal/format/testdata/toml/toml-NoOutputs.golden +++ b/internal/format/testdata/toml/toml-NoOutputs.golden @@ -230,6 +230,21 @@ outputs = [] required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[providers]] name = "tls" alias = "" diff --git a/internal/format/testdata/toml/toml-NoProviders.golden b/internal/format/testdata/toml/toml-NoProviders.golden index b78bf2d..656a3f2 100644 --- a/internal/format/testdata/toml/toml-NoProviders.golden +++ b/internal/format/testdata/toml/toml-NoProviders.golden @@ -230,6 +230,21 @@ providers = [] required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-NoRequirements.golden b/internal/format/testdata/toml/toml-NoRequirements.golden index 307843c..6fa9f52 100644 --- a/internal/format/testdata/toml/toml-NoRequirements.golden +++ b/internal/format/testdata/toml/toml-NoRequirements.golden @@ -230,6 +230,21 @@ requirements = [] required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-NoResources.golden b/internal/format/testdata/toml/toml-NoResources.golden index 0f53a4a..6413740 100644 --- a/internal/format/testdata/toml/toml-NoResources.golden +++ b/internal/format/testdata/toml/toml-NoResources.golden @@ -230,6 +230,21 @@ resources = [] required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-OnlyHeader.golden b/internal/format/testdata/toml/toml-OnlyHeader.golden index 834bb43..002880f 100644 --- a/internal/format/testdata/toml/toml-OnlyHeader.golden +++ b/internal/format/testdata/toml/toml-OnlyHeader.golden @@ -1,5 +1,6 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |" inputs = [] +modules = [] outputs = [] providers = [] requirements = [] diff --git a/internal/format/testdata/toml/toml-OnlyInputs.golden b/internal/format/testdata/toml/toml-OnlyInputs.golden index a0f1f4b..fbf8143 100644 --- a/internal/format/testdata/toml/toml-OnlyInputs.golden +++ b/internal/format/testdata/toml/toml-OnlyInputs.golden @@ -1,4 +1,5 @@ header = "" +modules = [] outputs = [] providers = [] requirements = [] diff --git a/internal/format/testdata/toml/toml-OnlyModulecalls.golden b/internal/format/testdata/toml/toml-OnlyModulecalls.golden new file mode 100644 index 0000000..c181506 --- /dev/null +++ b/internal/format/testdata/toml/toml-OnlyModulecalls.golden @@ -0,0 +1,21 @@ +header = "" +inputs = [] +outputs = [] +providers = [] +requirements = [] +resources = [] + +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" \ No newline at end of file diff --git a/internal/format/testdata/toml/toml-OnlyOutputs.golden b/internal/format/testdata/toml/toml-OnlyOutputs.golden index b99f767..5a1defe 100644 --- a/internal/format/testdata/toml/toml-OnlyOutputs.golden +++ b/internal/format/testdata/toml/toml-OnlyOutputs.golden @@ -1,5 +1,6 @@ header = "" inputs = [] +modules = [] providers = [] requirements = [] resources = [] diff --git a/internal/format/testdata/toml/toml-OnlyProviders.golden b/internal/format/testdata/toml/toml-OnlyProviders.golden index 2fd9af2..5286455 100644 --- a/internal/format/testdata/toml/toml-OnlyProviders.golden +++ b/internal/format/testdata/toml/toml-OnlyProviders.golden @@ -1,5 +1,6 @@ header = "" inputs = [] +modules = [] outputs = [] requirements = [] resources = [] diff --git a/internal/format/testdata/toml/toml-OnlyRequirements.golden b/internal/format/testdata/toml/toml-OnlyRequirements.golden index 29d7a85..3fb1e1e 100644 --- a/internal/format/testdata/toml/toml-OnlyRequirements.golden +++ b/internal/format/testdata/toml/toml-OnlyRequirements.golden @@ -1,5 +1,6 @@ header = "" inputs = [] +modules = [] outputs = [] providers = [] resources = [] diff --git a/internal/format/testdata/toml/toml-OnlyResources.golden b/internal/format/testdata/toml/toml-OnlyResources.golden index 9c49b2a..b2f4f12 100644 --- a/internal/format/testdata/toml/toml-OnlyResources.golden +++ b/internal/format/testdata/toml/toml-OnlyResources.golden @@ -1,5 +1,6 @@ header = "" inputs = [] +modules = [] outputs = [] providers = [] requirements = [] diff --git a/internal/format/testdata/toml/toml-OutputValues.golden b/internal/format/testdata/toml/toml-OutputValues.golden index a228a3c..9c0f95b 100644 --- a/internal/format/testdata/toml/toml-OutputValues.golden +++ b/internal/format/testdata/toml/toml-OutputValues.golden @@ -229,6 +229,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/toml/toml-SortByName.golden b/internal/format/testdata/toml/toml-SortByName.golden index e2d1789..54ea705 100644 --- a/internal/format/testdata/toml/toml-SortByName.golden +++ b/internal/format/testdata/toml/toml-SortByName.golden @@ -229,6 +229,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item default = "" required = false +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + [[outputs]] name = "output-0.12" description = "terraform 0.12 only" diff --git a/internal/format/testdata/toml/toml-SortByRequired.golden b/internal/format/testdata/toml/toml-SortByRequired.golden index 2329ba5..5cd45f8 100644 --- a/internal/format/testdata/toml/toml-SortByRequired.golden +++ b/internal/format/testdata/toml/toml-SortByRequired.golden @@ -229,6 +229,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item default = "" required = false +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + [[outputs]] name = "output-0.12" description = "terraform 0.12 only" diff --git a/internal/format/testdata/toml/toml-SortByType.golden b/internal/format/testdata/toml/toml-SortByType.golden index 86ce0a1..f28149f 100644 --- a/internal/format/testdata/toml/toml-SortByType.golden +++ b/internal/format/testdata/toml/toml-SortByType.golden @@ -229,6 +229,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item default = "" required = false +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "output-0.12" description = "terraform 0.12 only" diff --git a/internal/format/testdata/toml/toml.golden b/internal/format/testdata/toml/toml.golden index b28c0c2..79a8dce 100644 --- a/internal/format/testdata/toml/toml.golden +++ b/internal/format/testdata/toml/toml.golden @@ -229,6 +229,21 @@ header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item required = false [inputs.default] +[[modules]] + Name = "foo" + Source = "bar" + Version = "1.2.3" + +[[modules]] + Name = "bar" + Source = "baz" + Version = "4.5.6" + +[[modules]] + Name = "baz" + Source = "baz" + Version = "4.5.6" + [[outputs]] name = "unquoted" description = "It's unquoted output." diff --git a/internal/format/testdata/xml/xml-Empty.golden b/internal/format/testdata/xml/xml-Empty.golden index 80adbb6..1a9f4d7 100644 --- a/internal/format/testdata/xml/xml-Empty.golden +++ b/internal/format/testdata/xml/xml-Empty.golden @@ -1,6 +1,7 @@
+ diff --git a/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden b/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden index bf912a1..e2544cd 100644 --- a/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden +++ b/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-HeaderFromMDFile.golden b/internal/format/testdata/xml/xml-HeaderFromMDFile.golden index 98fb8ef..0bfe94e 100644 --- a/internal/format/testdata/xml/xml-HeaderFromMDFile.golden +++ b/internal/format/testdata/xml/xml-HeaderFromMDFile.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-HeaderFromTFFile.golden b/internal/format/testdata/xml/xml-HeaderFromTFFile.golden index c70b997..c051c18 100644 --- a/internal/format/testdata/xml/xml-HeaderFromTFFile.golden +++ b/internal/format/testdata/xml/xml-HeaderFromTFFile.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden b/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden index f5dbda6..8176ed3 100644 --- a/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden +++ b/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-NoHeader.golden b/internal/format/testdata/xml/xml-NoHeader.golden index b4245d1..8601ccd 100644 --- a/internal/format/testdata/xml/xml-NoHeader.golden +++ b/internal/format/testdata/xml/xml-NoHeader.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-NoInputs.golden b/internal/format/testdata/xml/xml-NoInputs.golden index 1556010..19f0621 100644 --- a/internal/format/testdata/xml/xml-NoInputs.golden +++ b/internal/format/testdata/xml/xml-NoInputs.golden @@ -1,6 +1,23 @@
Usage: Example of 'foo_bar' module in `foo_bar.tf`. - list item 1 - list item 2 Even inline **formatting** in _here_ is possible. and some [link](https://domain.com/) * list item 3 * list item 4 ```hcl module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" name = "baz" zones = ["us-east-1", "us-west-1"] tags = { Name = "baz" Created-By = "first.last@email.com" Date-Created = "20180101" } } ``` Here is some trailing text after code block, followed by another line of text. | Name | Description | |------|-----------------| | Foo | Foo description | | Bar | Bar description |
+ + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-NoModulecalls.golden b/internal/format/testdata/xml/xml-NoModulecalls.golden new file mode 100644 index 0000000..e6d5ff8 --- /dev/null +++ b/internal/format/testdata/xml/xml-NoModulecalls.golden @@ -0,0 +1,325 @@ + +
Usage: Example of 'foo_bar' module in `foo_bar.tf`. - list item 1 - list item 2 Even inline **formatting** in _here_ is possible. and some [link](https://domain.com/) * list item 3 * list item 4 ```hcl module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" name = "baz" zones = ["us-east-1", "us-west-1"] tags = { Name = "baz" Created-By = "first.last@email.com" Date-Created = "20180101" } } ``` Here is some trailing text after code block, followed by another line of text. | Name | Description | |------|-----------------| | Foo | Foo description | | Bar | Bar description |
+ + + unquoted + any + + + true + + + bool-3 + bool + + true + false + + + bool-2 + bool + It's bool number two. + false + false + + + bool-1 + bool + It's bool number one. + true + false + + + string-3 + string + + + false + + + string-2 + string + It's string number two. + + true + + + string-1 + string + It's string number one. + bar + false + + + string-special-chars + string + + \.<>[]{}_- + false + + + number-3 + number + + 19 + false + + + number-4 + number + + 15.75 + false + + + number-2 + number + It's number number two. + + true + + + number-1 + number + It's number number one. + 42 + false + + + map-3 + map + + + false + + + map-2 + map + It's map number two. + + true + + + map-1 + map + It's map number one. + + 1 + 2 + 3 + + false + + + list-3 + list + + + false + + + list-2 + list + It's list number two. + + true + + + list-1 + list + It's list number one. + + a + b + c + + false + + + input_with_underscores + any + A variable with underscores. + + true + + + input-with-pipe + string + It includes v1 | v2 | v3 + v1 + false + + + input-with-code-block + list + This is a complicated one. We need a newline. And an example in a code block ``` default = [ "machine rack01:neptune" ] ``` + + name rack:location + + false + + + long_type + object({ name = string, foo = object({ foo = string, bar = string }), bar = object({ foo = string, bar = string }), fizz = list(string), buzz = list(string) }) + This description is itself markdown. It spans over multiple lines. + + + bar + bar + + + fizz + buzz + + + + foo + foo + + hello + + false + + + no-escape-default-value + string + The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + VALUE_WITH_UNDERSCORE + false + + + with-url + string + The description contains url. https://www.domain.com/foo/bar_baz.html + + false + + + string_default_empty + string + + + false + + + string_default_null + string + + + false + + + string_no_default + string + + + true + + + number_default_zero + number + + 0 + false + + + bool_default_false + bool + + false + false + + + list_default_empty + list(string) + + + false + + + object_default_empty + object({}) + + + false + + + + + + unquoted + It's unquoted output. + + + output-2 + It's output number two. + + + output-1 + It's output number one. + + + output-0.12 + terraform 0.12 only + + + + + tls + + + + + aws + + >= 2.15.0 + + + aws + ident + >= 2.15.0 + + + null + + + + + + + terraform + >= 0.12 + + + aws + >= 2.15.0 + + + random + >= 2.2.0 + + + + + caller_identity + aws + hashicorp/aws + data + 2.15.0 + + + resource + null + hashicorp/null + managed + latest + + + private_key + tls + hashicorp/tls + managed + latest + + +
\ No newline at end of file diff --git a/internal/format/testdata/xml/xml-NoOutputs.golden b/internal/format/testdata/xml/xml-NoOutputs.golden index 3bc2990..a3ba835 100644 --- a/internal/format/testdata/xml/xml-NoOutputs.golden +++ b/internal/format/testdata/xml/xml-NoOutputs.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + diff --git a/internal/format/testdata/xml/xml-NoProviders.golden b/internal/format/testdata/xml/xml-NoProviders.golden index 9d7628a..ed003e8 100644 --- a/internal/format/testdata/xml/xml-NoProviders.golden +++ b/internal/format/testdata/xml/xml-NoProviders.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-NoRequirements.golden b/internal/format/testdata/xml/xml-NoRequirements.golden index 6d92c4c..bd5cd01 100644 --- a/internal/format/testdata/xml/xml-NoRequirements.golden +++ b/internal/format/testdata/xml/xml-NoRequirements.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-NoResources.golden b/internal/format/testdata/xml/xml-NoResources.golden index a7e9e84..0e4e4da 100644 --- a/internal/format/testdata/xml/xml-NoResources.golden +++ b/internal/format/testdata/xml/xml-NoResources.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-OnlyHeader.golden b/internal/format/testdata/xml/xml-OnlyHeader.golden index e09868f..ca60ccb 100644 --- a/internal/format/testdata/xml/xml-OnlyHeader.golden +++ b/internal/format/testdata/xml/xml-OnlyHeader.golden @@ -1,6 +1,7 @@
Usage: Example of 'foo_bar' module in `foo_bar.tf`. - list item 1 - list item 2 Even inline **formatting** in _here_ is possible. and some [link](https://domain.com/) * list item 3 * list item 4 ```hcl module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" name = "baz" zones = ["us-east-1", "us-west-1"] tags = { Name = "baz" Created-By = "first.last@email.com" Date-Created = "20180101" } } ``` Here is some trailing text after code block, followed by another line of text. | Name | Description | |------|-----------------| | Foo | Foo description | | Bar | Bar description |
+ diff --git a/internal/format/testdata/xml/xml-OnlyInputs.golden b/internal/format/testdata/xml/xml-OnlyInputs.golden index d8b73cf..54b6088 100644 --- a/internal/format/testdata/xml/xml-OnlyInputs.golden +++ b/internal/format/testdata/xml/xml-OnlyInputs.golden @@ -244,6 +244,7 @@ false + diff --git a/internal/format/testdata/xml/xml-OnlyModulecalls.golden b/internal/format/testdata/xml/xml-OnlyModulecalls.golden new file mode 100644 index 0000000..7a8fc28 --- /dev/null +++ b/internal/format/testdata/xml/xml-OnlyModulecalls.golden @@ -0,0 +1,25 @@ + +
+ + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + + + + + +
\ No newline at end of file diff --git a/internal/format/testdata/xml/xml-OnlyOutputs.golden b/internal/format/testdata/xml/xml-OnlyOutputs.golden index d429a6f..626c559 100644 --- a/internal/format/testdata/xml/xml-OnlyOutputs.golden +++ b/internal/format/testdata/xml/xml-OnlyOutputs.golden @@ -1,6 +1,7 @@
+ unquoted diff --git a/internal/format/testdata/xml/xml-OnlyProviders.golden b/internal/format/testdata/xml/xml-OnlyProviders.golden index ab72d5e..6891d5b 100644 --- a/internal/format/testdata/xml/xml-OnlyProviders.golden +++ b/internal/format/testdata/xml/xml-OnlyProviders.golden @@ -1,6 +1,7 @@
+ diff --git a/internal/format/testdata/xml/xml-OnlyRequirements.golden b/internal/format/testdata/xml/xml-OnlyRequirements.golden index 8f02b8b..1f79a16 100644 --- a/internal/format/testdata/xml/xml-OnlyRequirements.golden +++ b/internal/format/testdata/xml/xml-OnlyRequirements.golden @@ -1,6 +1,7 @@
+ diff --git a/internal/format/testdata/xml/xml-OnlyResources.golden b/internal/format/testdata/xml/xml-OnlyResources.golden index abfd76a..9c8bf29 100644 --- a/internal/format/testdata/xml/xml-OnlyResources.golden +++ b/internal/format/testdata/xml/xml-OnlyResources.golden @@ -1,6 +1,7 @@
+ diff --git a/internal/format/testdata/xml/xml-OutputValues.golden b/internal/format/testdata/xml/xml-OutputValues.golden index 3a55638..40f2d5e 100644 --- a/internal/format/testdata/xml/xml-OutputValues.golden +++ b/internal/format/testdata/xml/xml-OutputValues.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/xml/xml-SortByName.golden b/internal/format/testdata/xml/xml-SortByName.golden index e41e8dd..656605b 100644 --- a/internal/format/testdata/xml/xml-SortByName.golden +++ b/internal/format/testdata/xml/xml-SortByName.golden @@ -244,6 +244,23 @@ false + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + + foo + bar + 1.2.3 + + output-0.12 diff --git a/internal/format/testdata/xml/xml-SortByRequired.golden b/internal/format/testdata/xml/xml-SortByRequired.golden index 9c8be0f..d958186 100644 --- a/internal/format/testdata/xml/xml-SortByRequired.golden +++ b/internal/format/testdata/xml/xml-SortByRequired.golden @@ -244,6 +244,23 @@ false + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + + foo + bar + 1.2.3 + + output-0.12 diff --git a/internal/format/testdata/xml/xml-SortByType.golden b/internal/format/testdata/xml/xml-SortByType.golden index 19d6d21..7baa9b3 100644 --- a/internal/format/testdata/xml/xml-SortByType.golden +++ b/internal/format/testdata/xml/xml-SortByType.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + output-0.12 diff --git a/internal/format/testdata/xml/xml.golden b/internal/format/testdata/xml/xml.golden index 4f399c8..593b1fe 100644 --- a/internal/format/testdata/xml/xml.golden +++ b/internal/format/testdata/xml/xml.golden @@ -244,6 +244,23 @@ false + + + foo + bar + 1.2.3 + + + bar + baz + 4.5.6 + + + baz + baz + 4.5.6 + + unquoted diff --git a/internal/format/testdata/yaml/yaml-Empty.golden b/internal/format/testdata/yaml/yaml-Empty.golden index 2b7409c..4a62352 100644 --- a/internal/format/testdata/yaml/yaml-Empty.golden +++ b/internal/format/testdata/yaml/yaml-Empty.golden @@ -1,5 +1,6 @@ header: "" inputs: [] +modules: [] outputs: [] providers: [] requirements: [] diff --git a/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden index 55c5b7a..eb980a1 100644 --- a/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden +++ b/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden @@ -191,6 +191,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden index f07d534..2d36425 100644 --- a/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden +++ b/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden @@ -191,6 +191,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden index 42b3a64..91d4614 100644 --- a/internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden +++ b/internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden @@ -191,6 +191,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden index 966f58f..2c8c8c1 100644 --- a/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden +++ b/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden @@ -191,6 +191,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-NoHeader.golden b/internal/format/testdata/yaml/yaml-NoHeader.golden index 981210e..b3a9c2f 100644 --- a/internal/format/testdata/yaml/yaml-NoHeader.golden +++ b/internal/format/testdata/yaml/yaml-NoHeader.golden @@ -183,6 +183,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-NoInputs.golden b/internal/format/testdata/yaml/yaml-NoInputs.golden index 787b85c..9eba9f6 100644 --- a/internal/format/testdata/yaml/yaml-NoInputs.golden +++ b/internal/format/testdata/yaml/yaml-NoInputs.golden @@ -37,6 +37,16 @@ header: |- | Foo | Foo description | | Bar | Bar description | inputs: [] +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-NoModulecalls.golden b/internal/format/testdata/yaml/yaml-NoModulecalls.golden new file mode 100644 index 0000000..e5931fc --- /dev/null +++ b/internal/format/testdata/yaml/yaml-NoModulecalls.golden @@ -0,0 +1,268 @@ +header: |- + Usage: + + Example of 'foo_bar' module in `foo_bar.tf`. + + - list item 1 + - list item 2 + + Even inline **formatting** in _here_ is possible. + and some [link](https://domain.com/) + + * list item 3 + * list item 4 + + ```hcl + module "foo_bar" { + source = "github.com/foo/bar" + + id = "1234567890" + name = "baz" + + zones = ["us-east-1", "us-west-1"] + + tags = { + Name = "baz" + Created-By = "first.last@email.com" + Date-Created = "20180101" + } + } + ``` + + Here is some trailing text after code block, + followed by another line of text. + + | Name | Description | + |------|-----------------| + | Foo | Foo description | + | Bar | Bar description | +inputs: + - name: unquoted + type: any + description: null + default: null + required: true + - name: bool-3 + type: bool + description: null + default: true + required: false + - name: bool-2 + type: bool + description: It's bool number two. + default: false + required: false + - name: bool-1 + type: bool + description: It's bool number one. + default: true + required: false + - name: string-3 + type: string + description: null + default: "" + required: false + - name: string-2 + type: string + description: It's string number two. + default: null + required: true + - name: string-1 + type: string + description: It's string number one. + default: bar + required: false + - name: string-special-chars + type: string + description: null + default: \.<>[]{}_- + required: false + - name: number-3 + type: number + description: null + default: "19" + required: false + - name: number-4 + type: number + description: null + default: 15.75 + required: false + - name: number-2 + type: number + description: It's number number two. + default: null + required: true + - name: number-1 + type: number + description: It's number number one. + default: 42 + required: false + - name: map-3 + type: map + description: null + default: {} + required: false + - name: map-2 + type: map + description: It's map number two. + default: null + required: true + - name: map-1 + type: map + description: It's map number one. + default: + a: 1 + b: 2 + c: 3 + required: false + - name: list-3 + type: list + description: null + default: [] + required: false + - name: list-2 + type: list + description: It's list number two. + default: null + required: true + - name: list-1 + type: list + description: It's list number one. + default: + - a + - b + - c + required: false + - name: input_with_underscores + type: any + description: A variable with underscores. + default: null + required: true + - name: input-with-pipe + type: string + description: It includes v1 | v2 | v3 + default: v1 + required: false + - name: input-with-code-block + type: list + description: "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n" + default: + - name rack:location + required: false + - name: long_type + type: |- + object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) + description: | + This description is itself markdown. + + It spans over multiple lines. + default: + bar: + bar: bar + foo: bar + buzz: + - fizz + - buzz + fizz: [] + foo: + bar: foo + foo: foo + name: hello + required: false + - name: no-escape-default-value + type: string + description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + default: VALUE_WITH_UNDERSCORE + required: false + - name: with-url + type: string + description: The description contains url. https://www.domain.com/foo/bar_baz.html + default: "" + required: false + - name: string_default_empty + type: string + description: null + default: "" + required: false + - name: string_default_null + type: string + description: null + default: null + required: false + - name: string_no_default + type: string + description: null + default: null + required: true + - name: number_default_zero + type: number + description: null + default: 0 + required: false + - name: bool_default_false + type: bool + description: null + default: false + required: false + - name: list_default_empty + type: list(string) + description: null + default: [] + required: false + - name: object_default_empty + type: object({}) + description: null + default: {} + required: false +modules: [] +outputs: + - name: unquoted + description: It's unquoted output. + - name: output-2 + description: It's output number two. + - name: output-1 + description: It's output number one. + - name: output-0.12 + description: terraform 0.12 only +providers: + - name: tls + alias: null + version: null + - name: aws + alias: null + version: '>= 2.15.0' + - name: aws + alias: ident + version: '>= 2.15.0' + - name: "null" + alias: null + version: null +requirements: + - name: terraform + version: '>= 0.12' + - name: aws + version: '>= 2.15.0' + - name: random + version: '>= 2.2.0' +resources: + - type: caller_identity + providerName: aws + providerSource: hashicorp/aws + mode: data + version: 2.15.0 + - type: resource + providerName: "null" + providerSource: hashicorp/null + mode: managed + version: latest + - type: private_key + providerName: tls + providerSource: hashicorp/tls + mode: managed + version: latest \ No newline at end of file diff --git a/internal/format/testdata/yaml/yaml-NoOutputs.golden b/internal/format/testdata/yaml/yaml-NoOutputs.golden index fd07439..9eb804c 100644 --- a/internal/format/testdata/yaml/yaml-NoOutputs.golden +++ b/internal/format/testdata/yaml/yaml-NoOutputs.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: [] providers: - name: tls diff --git a/internal/format/testdata/yaml/yaml-NoProviders.golden b/internal/format/testdata/yaml/yaml-NoProviders.golden index 4d2e395..3d308c0 100644 --- a/internal/format/testdata/yaml/yaml-NoProviders.golden +++ b/internal/format/testdata/yaml/yaml-NoProviders.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-NoRequirements.golden b/internal/format/testdata/yaml/yaml-NoRequirements.golden index e73b767..4014432 100644 --- a/internal/format/testdata/yaml/yaml-NoRequirements.golden +++ b/internal/format/testdata/yaml/yaml-NoRequirements.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-NoResources.golden b/internal/format/testdata/yaml/yaml-NoResources.golden index 25c015e..8e3951a 100644 --- a/internal/format/testdata/yaml/yaml-NoResources.golden +++ b/internal/format/testdata/yaml/yaml-NoResources.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-OnlyHeader.golden b/internal/format/testdata/yaml/yaml-OnlyHeader.golden index cd2cea1..b388973 100644 --- a/internal/format/testdata/yaml/yaml-OnlyHeader.golden +++ b/internal/format/testdata/yaml/yaml-OnlyHeader.golden @@ -37,6 +37,7 @@ header: |- | Foo | Foo description | | Bar | Bar description | inputs: [] +modules: [] outputs: [] providers: [] requirements: [] diff --git a/internal/format/testdata/yaml/yaml-OnlyInputs.golden b/internal/format/testdata/yaml/yaml-OnlyInputs.golden index a7dd39c..da19324 100644 --- a/internal/format/testdata/yaml/yaml-OnlyInputs.golden +++ b/internal/format/testdata/yaml/yaml-OnlyInputs.golden @@ -183,6 +183,7 @@ inputs: description: null default: {} required: false +modules: [] outputs: [] providers: [] requirements: [] diff --git a/internal/format/testdata/yaml/yaml-OnlyModulecalls.golden b/internal/format/testdata/yaml/yaml-OnlyModulecalls.golden new file mode 100644 index 0000000..d571e9d --- /dev/null +++ b/internal/format/testdata/yaml/yaml-OnlyModulecalls.golden @@ -0,0 +1,16 @@ +header: "" +inputs: [] +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 +outputs: [] +providers: [] +requirements: [] +resources: [] \ No newline at end of file diff --git a/internal/format/testdata/yaml/yaml-OnlyOutputs.golden b/internal/format/testdata/yaml/yaml-OnlyOutputs.golden index cb4e0e6..4eaf60f 100644 --- a/internal/format/testdata/yaml/yaml-OnlyOutputs.golden +++ b/internal/format/testdata/yaml/yaml-OnlyOutputs.golden @@ -1,5 +1,6 @@ header: "" inputs: [] +modules: [] outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-OnlyProviders.golden b/internal/format/testdata/yaml/yaml-OnlyProviders.golden index 11aade1..4746e4e 100644 --- a/internal/format/testdata/yaml/yaml-OnlyProviders.golden +++ b/internal/format/testdata/yaml/yaml-OnlyProviders.golden @@ -1,5 +1,6 @@ header: "" inputs: [] +modules: [] outputs: [] providers: - name: tls diff --git a/internal/format/testdata/yaml/yaml-OnlyRequirements.golden b/internal/format/testdata/yaml/yaml-OnlyRequirements.golden index 2003937..2707ce0 100644 --- a/internal/format/testdata/yaml/yaml-OnlyRequirements.golden +++ b/internal/format/testdata/yaml/yaml-OnlyRequirements.golden @@ -1,5 +1,6 @@ header: "" inputs: [] +modules: [] outputs: [] providers: [] requirements: diff --git a/internal/format/testdata/yaml/yaml-OnlyResources.golden b/internal/format/testdata/yaml/yaml-OnlyResources.golden index d0ea2f9..c1c5e61 100644 --- a/internal/format/testdata/yaml/yaml-OnlyResources.golden +++ b/internal/format/testdata/yaml/yaml-OnlyResources.golden @@ -1,5 +1,6 @@ header: "" inputs: [] +modules: [] outputs: [] providers: [] requirements: [] diff --git a/internal/format/testdata/yaml/yaml-OutputValues.golden b/internal/format/testdata/yaml/yaml-OutputValues.golden index 589d67f..87743dd 100644 --- a/internal/format/testdata/yaml/yaml-OutputValues.golden +++ b/internal/format/testdata/yaml/yaml-OutputValues.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/testdata/yaml/yaml-SortByName.golden b/internal/format/testdata/yaml/yaml-SortByName.golden index ef4f88d..d20a77d 100644 --- a/internal/format/testdata/yaml/yaml-SortByName.golden +++ b/internal/format/testdata/yaml/yaml-SortByName.golden @@ -220,6 +220,16 @@ inputs: description: The description contains url. https://www.domain.com/foo/bar_baz.html default: "" required: false +modules: + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 + - name: foo + source: bar + version: 1.2.3 outputs: - name: output-0.12 description: terraform 0.12 only diff --git a/internal/format/testdata/yaml/yaml-SortByRequired.golden b/internal/format/testdata/yaml/yaml-SortByRequired.golden index bc31f44..c6f4f02 100644 --- a/internal/format/testdata/yaml/yaml-SortByRequired.golden +++ b/internal/format/testdata/yaml/yaml-SortByRequired.golden @@ -220,6 +220,16 @@ inputs: description: The description contains url. https://www.domain.com/foo/bar_baz.html default: "" required: false +modules: + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 + - name: foo + source: bar + version: 1.2.3 outputs: - name: output-0.12 description: terraform 0.12 only diff --git a/internal/format/testdata/yaml/yaml-SortByType.golden b/internal/format/testdata/yaml/yaml-SortByType.golden index a5e32ec..4310f93 100644 --- a/internal/format/testdata/yaml/yaml-SortByType.golden +++ b/internal/format/testdata/yaml/yaml-SortByType.golden @@ -220,6 +220,16 @@ inputs: description: The description contains url. https://www.domain.com/foo/bar_baz.html default: "" required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: output-0.12 description: terraform 0.12 only diff --git a/internal/format/testdata/yaml/yaml.golden b/internal/format/testdata/yaml/yaml.golden index fee289e..334d8a1 100644 --- a/internal/format/testdata/yaml/yaml.golden +++ b/internal/format/testdata/yaml/yaml.golden @@ -220,6 +220,16 @@ inputs: description: null default: {} required: false +modules: + - name: foo + source: bar + version: 1.2.3 + - name: bar + source: baz + version: 4.5.6 + - name: baz + source: baz + version: 4.5.6 outputs: - name: unquoted description: It's unquoted output. diff --git a/internal/format/toml.go b/internal/format/toml.go index fbdab41..8420a58 100644 --- a/internal/format/toml.go +++ b/internal/format/toml.go @@ -34,6 +34,7 @@ func (t *TOML) Print(module *terraform.Module, settings *print.Settings) (string Header: "", Providers: make([]*terraform.Provider, 0), Inputs: make([]*terraform.Input, 0), + ModuleCalls: make([]*terraform.ModuleCall, 0), Outputs: make([]*terraform.Output, 0), Requirements: make([]*terraform.Requirement, 0), Resources: make([]*terraform.Resource, 0), @@ -45,6 +46,9 @@ func (t *TOML) Print(module *terraform.Module, settings *print.Settings) (string if settings.ShowInputs { copy.Inputs = module.Inputs } + if settings.ShowModuleCalls { + copy.ModuleCalls = module.ModuleCalls + } if settings.ShowOutputs { copy.Outputs = module.Outputs } diff --git a/internal/format/toml_test.go b/internal/format/toml_test.go index 53ffe1e..9ac35dc 100644 --- a/internal/format/toml_test.go +++ b/internal/format/toml_test.go @@ -123,6 +123,7 @@ func TestTomlNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -148,6 +149,7 @@ func TestTomlNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,11 +170,38 @@ func TestTomlNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestTomlNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("toml", "toml-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewTOML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestTomlNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -198,6 +227,7 @@ func TestTomlNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -223,6 +253,7 @@ func TestTomlNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -248,6 +279,7 @@ func TestTomlNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -273,6 +305,7 @@ func TestTomlOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -298,6 +331,7 @@ func TestTomlOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,11 +352,38 @@ func TestTomlOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestTomlOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("toml", "toml-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewTOML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestTomlOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -348,6 +409,7 @@ func TestTomlOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -373,6 +435,7 @@ func TestTomlOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -398,6 +461,7 @@ func TestTomlOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -470,6 +534,7 @@ func TestTomlEmpty(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, diff --git a/internal/format/xml.go b/internal/format/xml.go index ba465fb..277fff8 100644 --- a/internal/format/xml.go +++ b/internal/format/xml.go @@ -31,6 +31,7 @@ func (x *XML) Print(module *terraform.Module, settings *print.Settings) (string, copy := &terraform.Module{ Header: "", Inputs: make([]*terraform.Input, 0), + ModuleCalls: make([]*terraform.ModuleCall, 0), Outputs: make([]*terraform.Output, 0), Providers: make([]*terraform.Provider, 0), Requirements: make([]*terraform.Requirement, 0), @@ -43,6 +44,9 @@ func (x *XML) Print(module *terraform.Module, settings *print.Settings) (string, if settings.ShowInputs { copy.Inputs = module.Inputs } + if settings.ShowModuleCalls { + copy.ModuleCalls = module.ModuleCalls + } if settings.ShowOutputs { copy.Outputs = module.Outputs } diff --git a/internal/format/xml_test.go b/internal/format/xml_test.go index a1c96a3..bce4ed2 100644 --- a/internal/format/xml_test.go +++ b/internal/format/xml_test.go @@ -123,6 +123,7 @@ func TestXmlNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -148,6 +149,7 @@ func TestXmlNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,11 +170,38 @@ func TestXmlNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestXmlNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("xml", "xml-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewXML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestXmlNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -198,6 +227,7 @@ func TestXmlNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -223,6 +253,7 @@ func TestXmlNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -248,6 +279,7 @@ func TestXmlNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -273,6 +305,7 @@ func TestXmlOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -298,6 +331,7 @@ func TestXmlOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,11 +352,38 @@ func TestXmlOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestXmlOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("xml", "xml-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewXML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestXmlOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -348,6 +409,7 @@ func TestXmlOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -373,6 +435,7 @@ func TestXmlOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -398,6 +461,7 @@ func TestXmlOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, diff --git a/internal/format/yaml.go b/internal/format/yaml.go index dc5bc20..0e42e0b 100644 --- a/internal/format/yaml.go +++ b/internal/format/yaml.go @@ -33,6 +33,7 @@ func (y *YAML) Print(module *terraform.Module, settings *print.Settings) (string copy := &terraform.Module{ Header: "", Inputs: make([]*terraform.Input, 0), + ModuleCalls: make([]*terraform.ModuleCall, 0), Outputs: make([]*terraform.Output, 0), Providers: make([]*terraform.Provider, 0), Requirements: make([]*terraform.Requirement, 0), @@ -45,6 +46,9 @@ func (y *YAML) Print(module *terraform.Module, settings *print.Settings) (string if settings.ShowInputs { copy.Inputs = module.Inputs } + if settings.ShowModuleCalls { + copy.ModuleCalls = module.ModuleCalls + } if settings.ShowOutputs { copy.Outputs = module.Outputs } diff --git a/internal/format/yaml_test.go b/internal/format/yaml_test.go index 48ca4c0..dd09e78 100644 --- a/internal/format/yaml_test.go +++ b/internal/format/yaml_test.go @@ -123,6 +123,7 @@ func TestYamlNoHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -148,6 +149,7 @@ func TestYamlNoInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -168,11 +170,38 @@ func TestYamlNoInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestYamlNoModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: true, + ShowInputs: true, + ShowModuleCalls: false, + ShowOutputs: true, + ShowProviders: true, + ShowRequirements: true, + ShowResources: true, + }).Build() + + expected, err := testutil.GetExpected("yaml", "yaml-NoModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewYAML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestYamlNoOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: false, ShowProviders: true, ShowRequirements: true, @@ -198,6 +227,7 @@ func TestYamlNoProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: false, ShowRequirements: true, @@ -223,6 +253,7 @@ func TestYamlNoRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: false, @@ -248,6 +279,7 @@ func TestYamlNoResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true, @@ -273,6 +305,7 @@ func TestYamlOnlyHeader(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: true, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -298,6 +331,7 @@ func TestYamlOnlyInputs(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: true, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -318,11 +352,38 @@ func TestYamlOnlyInputs(t *testing.T) { assert.Equal(expected, actual) } +func TestYamlOnlyModulecalls(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().With(&print.Settings{ + ShowHeader: false, + ShowInputs: false, + ShowModuleCalls: true, + ShowOutputs: false, + ShowProviders: false, + ShowRequirements: false, + ShowResources: false, + }).Build() + + expected, err := testutil.GetExpected("yaml", "yaml-OnlyModulecalls") + assert.Nil(err) + + options := terraform.NewOptions() + module, err := testutil.GetModule(options) + assert.Nil(err) + + printer := NewYAML(settings) + actual, err := printer.Print(module, settings) + + assert.Nil(err) + assert.Equal(expected, actual) +} + func TestYamlOnlyOutputs(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: true, ShowProviders: false, ShowRequirements: false, @@ -348,6 +409,7 @@ func TestYamlOnlyProviders(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: true, ShowRequirements: false, @@ -373,6 +435,7 @@ func TestYamlOnlyRequirements(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: true, @@ -398,6 +461,7 @@ func TestYamlOnlyResources(t *testing.T) { settings := testutil.Settings().With(&print.Settings{ ShowHeader: false, ShowInputs: false, + ShowModuleCalls: false, ShowOutputs: false, ShowProviders: false, ShowRequirements: false, @@ -498,10 +562,12 @@ func TestYamlHeaderFromFile(t *testing.T) { func TestYamlEmpty(t *testing.T) { assert := assert.New(t) settings := testutil.Settings().With(&print.Settings{ - ShowHeader: false, - ShowProviders: false, - ShowInputs: false, - ShowOutputs: false, + ShowHeader: false, + ShowProviders: false, + ShowInputs: false, + ShowModuleCalls: false, + ShowOutputs: false, + ShowRequirements: false, }).Build() expected, err := testutil.GetExpected("yaml", "yaml-Empty") diff --git a/internal/print/settings.go b/internal/print/settings.go index d588947..1511951 100644 --- a/internal/print/settings.go +++ b/internal/print/settings.go @@ -58,6 +58,12 @@ type Settings struct { // scope: Global ShowInputs bool + // ShowModuleCalls show "ModuleCalls" information (default: true) + // + // default: true + // scope: Global + ShowModuleCalls bool + // ShowOutputs show "Outputs" information // // default: true @@ -123,6 +129,7 @@ func DefaultSettings() *Settings { ShowColor: true, ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequired: true, @@ -146,6 +153,7 @@ func (s *Settings) Convert() *printsdk.Settings { ShowHeader: s.ShowHeader, ShowInputs: s.ShowInputs, ShowOutputs: s.ShowOutputs, + ShowModuleCalls: s.ShowModuleCalls, ShowProviders: s.ShowProviders, ShowRequired: s.ShowRequired, ShowSensitivity: s.ShowSensitivity, diff --git a/internal/terraform/module.go b/internal/terraform/module.go index 3b61db9..73a0232 100644 --- a/internal/terraform/module.go +++ b/internal/terraform/module.go @@ -31,6 +31,7 @@ import ( // // - Header ('header' json key): Module header found in shape of multi line comments at the beginning of 'main.tf' // - Inputs ('inputs' json key): List of input 'variables' extracted from the Terraform module .tf files +// - ModuleCalls ('modules' json key): List of 'modules' extracted from the Terraform module .tf files // - Outputs ('outputs' json key): List of 'outputs' extracted from Terraform module .tf files // - Providers ('providers' json key): List of 'providers' extracted from resources used in Terraform module // - Requirements ('requirements' json key): List of 'requirements' extracted from the Terraform module .tf files @@ -40,6 +41,7 @@ type Module struct { Header string `json:"header" toml:"header" xml:"header" yaml:"header"` Inputs []*Input `json:"inputs" toml:"inputs" xml:"inputs>input" yaml:"inputs"` + ModuleCalls []*ModuleCall `json:"modules" toml:"modules" xml:"modules>module" yaml:"modules"` Outputs []*Output `json:"outputs" toml:"outputs" xml:"outputs>output" yaml:"outputs"` Providers []*Provider `json:"providers" toml:"providers" xml:"providers>provider" yaml:"providers"` Requirements []*Requirement `json:"requirements" toml:"requirements" xml:"requirements>requirement" yaml:"requirements"` @@ -59,6 +61,11 @@ func (m *Module) HasInputs() bool { return len(m.Inputs) > 0 } +// HasModuleCalls indicates if the module has modulecalls. +func (m *Module) HasModuleCalls() bool { + return len(m.ModuleCalls) > 0 +} + // HasOutputs indicates if the module has outputs. func (m *Module) HasOutputs() bool { return len(m.Outputs) > 0 @@ -84,6 +91,7 @@ func (m *Module) Convert() terraformsdk.Module { return terraformsdk.NewModule( terraformsdk.WithHeader(m.Header), terraformsdk.WithInputs(inputs(m.Inputs).convert()), + terraformsdk.WithModuleCalls(modulecalls(m.ModuleCalls).convert()), terraformsdk.WithOutputs(outputs(m.Outputs).convert()), terraformsdk.WithProviders(providers(m.Providers).convert()), terraformsdk.WithRequirements(requirements(m.Requirements).convert()), @@ -123,6 +131,7 @@ func loadModuleItems(tfmodule *tfconfig.Module, options *Options) (*Module, erro } inputs, required, optional := loadInputs(tfmodule) + modulecalls := loadModulecalls(tfmodule) outputs, err := loadOutputs(tfmodule, options) if err != nil { return nil, err @@ -134,6 +143,7 @@ func loadModuleItems(tfmodule *tfconfig.Module, options *Options) (*Module, erro return &Module{ Header: header, Inputs: inputs, + ModuleCalls: modulecalls, Outputs: outputs, Providers: providers, Requirements: requirements, @@ -246,6 +256,18 @@ func loadInputs(tfmodule *tfconfig.Module) ([]*Input, []*Input, []*Input) { return inputs, required, optional } +func loadModulecalls(tfmodule *tfconfig.Module) []*ModuleCall { + var modulecalls = make([]*ModuleCall, 0) + for _, modulecall := range tfmodule.ModuleCalls { + modulecalls = append(modulecalls, &ModuleCall{ + Name: modulecall.Name, + Source: modulecall.Source, + Version: modulecall.Version, + }) + } + return modulecalls +} + func loadOutputs(tfmodule *tfconfig.Module, options *Options) ([]*Output, error) { outputs := make([]*Output, 0, len(tfmodule.Outputs)) values := make(map[string]*output) @@ -447,4 +469,15 @@ func sortItems(tfmodule *Module, sortby *SortBy) { // Always sort resources sort.Sort(resourcesSortedByType(tfmodule.Resources)) + if sortby.Name { + sort.Sort(modulecallsSortedByName(tfmodule.ModuleCalls)) + } else { + sort.Sort(modulecallsSortedBySource(tfmodule.ModuleCalls)) + } + + if sortby.Name { + sort.Sort(modulecallsSortedByName(tfmodule.ModuleCalls)) + } else { + sort.Sort(modulecallsSortedBySource(tfmodule.ModuleCalls)) + } } diff --git a/internal/terraform/module_test.go b/internal/terraform/module_test.go index b4d8b90..c528e8e 100644 --- a/internal/terraform/module_test.go +++ b/internal/terraform/module_test.go @@ -29,6 +29,7 @@ func TestLoadModuleWithOptions(t *testing.T) { assert.Equal(true, module.HasHeader()) assert.Equal(true, module.HasInputs()) assert.Equal(true, module.HasOutputs()) + assert.Equal(true, module.HasModuleCalls()) assert.Equal(true, module.HasProviders()) assert.Equal(true, module.HasRequirements()) } @@ -350,6 +351,34 @@ func TestLoadInputs(t *testing.T) { } } +func TestLoadModulecalls(t *testing.T) { + tests := []struct { + name string + path string + expected int + }{ + { + name: "load modulecalls from path", + path: "full-example", + expected: 1, + }, + { + name: "load modulecalls from path", + path: "no-modulecalls", + expected: 0, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + module, _ := loadModule(filepath.Join("testdata", tt.path)) + modulecalls := loadModulecalls(module) + + assert.Equal(tt.expected, len(modulecalls)) + }) + } +} + func TestLoadInputsLineEnding(t *testing.T) { tests := []struct { name string diff --git a/internal/terraform/modulecall.go b/internal/terraform/modulecall.go new file mode 100644 index 0000000..7834c76 --- /dev/null +++ b/internal/terraform/modulecall.go @@ -0,0 +1,65 @@ +/* +Copyright 2021 The terraform-docs Authors. + +Licensed under the MIT license (the "License"); you may not +use this file except in compliance with the License. + +You may obtain a copy of the License at the LICENSE file in +the root directory of this source tree. +*/ + +package terraform + +import ( + "fmt" + + terraformsdk "github.com/terraform-docs/plugin-sdk/terraform" +) + +// ModuleCall represents a submodule called by Terraform module. +type ModuleCall struct { + Name string `json:"name"` + Source string `json:"source"` + Version string `json:"version,omitempty"` +} + +// FullName returns full name of the modulecall, with version if available +func (mc *ModuleCall) FullName() string { + if mc.Version != "" { + return fmt.Sprintf("%s,%s", mc.Source, mc.Version) + } + return mc.Source +} + +type modulecallsSortedByName []*ModuleCall + +func (a modulecallsSortedByName) Len() int { return len(a) } +func (a modulecallsSortedByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a modulecallsSortedByName) Less(i, j int) bool { + return a[i].Name < a[j].Name +} + +type modulecallsSortedBySource []*ModuleCall + +func (a modulecallsSortedBySource) Len() int { return len(a) } +func (a modulecallsSortedBySource) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a modulecallsSortedBySource) Less(i, j int) bool { + if a[i].Source == a[j].Source { + return a[i].Name < a[j].Name + } + return a[i].Source < a[j].Source +} + +type modulecalls []*ModuleCall + +func (mm modulecalls) convert() []*terraformsdk.ModuleCall { + list := []*terraformsdk.ModuleCall{} + for _, m := range mm { + list = append(list, &terraformsdk.ModuleCall{ + Name: m.Name, + Source: m.Source, + Version: m.Version, + }) + } + return list +} diff --git a/internal/terraform/modulecall_test.go b/internal/terraform/modulecall_test.go new file mode 100644 index 0000000..82f86e9 --- /dev/null +++ b/internal/terraform/modulecall_test.go @@ -0,0 +1,36 @@ +/* +Copyright 2021 The terraform-docs Authors. + +Licensed under the MIT license (the "License"); you may not +use this file except in compliance with the License. + +You may obtain a copy of the License at the LICENSE file in +the root directory of this source tree. +*/ + +package terraform + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestModulecallNameWithoutVersion(t *testing.T) { + assert := assert.New(t) + modulecall := ModuleCall{ + Name: "provider", + Source: "bar", + } + assert.Equal("bar", modulecall.FullName()) +} + +func TestModulecallNameWithVersion(t *testing.T) { + assert := assert.New(t) + modulecall := ModuleCall{ + Name: "provider", + Source: "bar", + Version: "1.2.3", + } + assert.Equal("bar,1.2.3", modulecall.FullName()) +} diff --git a/internal/terraform/testdata/full-example/main.tf b/internal/terraform/testdata/full-example/main.tf index e8e3bd6..68c29cf 100644 --- a/internal/terraform/testdata/full-example/main.tf +++ b/internal/terraform/testdata/full-example/main.tf @@ -22,3 +22,8 @@ data "aws_caller_identity" "current" { } resource "null_resource" "foo" {} + +module "foo" { + source = "bar" + version = "1.2.3" +} \ No newline at end of file diff --git a/internal/terraform/testdata/no-modulecalls/main.tf b/internal/terraform/testdata/no-modulecalls/main.tf new file mode 100644 index 0000000..351b7d6 --- /dev/null +++ b/internal/terraform/testdata/no-modulecalls/main.tf @@ -0,0 +1 @@ +resource "tls_private_key" "baz" {} \ No newline at end of file diff --git a/internal/testutil/settings.go b/internal/testutil/settings.go index edd1037..73e61be 100644 --- a/internal/testutil/settings.go +++ b/internal/testutil/settings.go @@ -50,11 +50,12 @@ func (s *TestSettings) WithColor() *TestSettings { return s } -// WithSections appends predefined show all sections ShowHeader, ShowProviders, ShowInputs, ShowOutputs to TestSettings +// WithSections appends predefined show all sections ShowHeader, ShowProviders, ShowInputs, ShowModulecalls, ShowOutputs to TestSettings func (s *TestSettings) WithSections() *TestSettings { sections := &print.Settings{ ShowHeader: true, ShowInputs: true, + ShowModuleCalls: true, ShowOutputs: true, ShowProviders: true, ShowRequirements: true,