From fbbf01e451ff4dff97ab704b6d89ea20c7b3f1f9 Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Wed, 29 Apr 2020 15:30:48 -0400 Subject: [PATCH] Read header from .adoc, .md and .txt file as well (#252) * Allow reading header from a markdown file * wording * add supports for .adoc and .txt as well * wording * revert docs Signed-off-by: Khosrow Moossavi --- .gitignore | 1 + Makefile | 2 +- examples/doc.adoc | 8 + examples/doc.md | 8 + examples/doc.txt | 8 + internal/format/asciidoc_document_test.go | 58 ++- internal/format/asciidoc_table_test.go | 58 ++- internal/format/json_test.go | 58 ++- internal/format/markdown_document_test.go | 58 ++- internal/format/markdown_table_test.go | 58 ++- internal/format/pretty_test.go | 58 ++- .../document-HeaderFromADOCFile.golden | 353 ++++++++++++++++++ .../asciidoc/document-HeaderFromMDFile.golden | 353 ++++++++++++++++++ ...olden => document-HeaderFromTFFile.golden} | 0 .../document-HeaderFromTXTFile.golden | 353 ++++++++++++++++++ .../asciidoc/table-HeaderFromADOCFile.golden | 265 +++++++++++++ .../asciidoc/table-HeaderFromMDFile.golden | 265 +++++++++++++ ...e.golden => table-HeaderFromTFFile.golden} | 0 .../asciidoc/table-HeaderFromTXTFile.golden | 265 +++++++++++++ .../json/json-HeaderFromADOCFile.golden | 294 +++++++++++++++ .../json/json-HeaderFromMDFile.golden | 294 +++++++++++++++ ...le.golden => json-HeaderFromTFFile.golden} | 0 .../json/json-HeaderFromTXTFile.golden | 294 +++++++++++++++ .../document-HeaderFromADOCFile.golden | 353 ++++++++++++++++++ .../markdown/document-HeaderFromMDFile.golden | 353 ++++++++++++++++++ ...olden => document-HeaderFromTFFile.golden} | 0 .../document-HeaderFromTXTFile.golden | 353 ++++++++++++++++++ .../markdown/table-HeaderFromADOCFile.golden | 69 ++++ .../markdown/table-HeaderFromMDFile.golden | 69 ++++ ...e.golden => table-HeaderFromTFFile.golden} | 0 .../markdown/table-HeaderFromTXTFile.golden | 69 ++++ .../pretty/pretty-HeaderFromADOCFile.golden | 169 +++++++++ .../pretty/pretty-HeaderFromMDFile.golden | 169 +++++++++ ....golden => pretty-HeaderFromTFFile.golden} | 0 .../pretty/pretty-HeaderFromTXTFile.golden | 169 +++++++++ .../xml/xml-HeaderFromADOCFile.golden | 294 +++++++++++++++ .../testdata/xml/xml-HeaderFromMDFile.golden | 294 +++++++++++++++ ...ile.golden => xml-HeaderFromTFFile.golden} | 0 .../testdata/xml/xml-HeaderFromTXTFile.golden | 294 +++++++++++++++ .../yaml/yaml-HeaderFromADOCFile.golden | 218 +++++++++++ .../yaml/yaml-HeaderFromMDFile.golden | 218 +++++++++++ ...le.golden => yaml-HeaderFromTFFile.golden} | 0 .../yaml/yaml-HeaderFromTXTFile.golden | 218 +++++++++++ internal/format/xml_test.go | 58 ++- internal/format/yaml_test.go | 58 ++- internal/module/module.go | 36 +- internal/module/module_test.go | 153 ++++++++ .../module/testdata/full-example/doc.adoc | 6 + internal/module/testdata/full-example/doc.md | 6 + internal/module/testdata/full-example/doc.txt | 6 + 50 files changed, 6627 insertions(+), 116 deletions(-) create mode 100644 examples/doc.adoc create mode 100644 examples/doc.md create mode 100644 examples/doc.txt create mode 100644 internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden rename internal/format/testdata/asciidoc/{document-HeaderFromFile.golden => document-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden rename internal/format/testdata/asciidoc/{table-HeaderFromFile.golden => table-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/json/json-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/json/json-HeaderFromMDFile.golden rename internal/format/testdata/json/{json-HeaderFromFile.golden => json-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/json/json-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/markdown/document-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/markdown/document-HeaderFromMDFile.golden rename internal/format/testdata/markdown/{document-HeaderFromFile.golden => document-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/markdown/document-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/markdown/table-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/markdown/table-HeaderFromMDFile.golden rename internal/format/testdata/markdown/{table-HeaderFromFile.golden => table-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/markdown/table-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden rename internal/format/testdata/pretty/{pretty-HeaderFromFile.golden => pretty-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/xml/xml-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/xml/xml-HeaderFromMDFile.golden rename internal/format/testdata/xml/{xml-HeaderFromFile.golden => xml-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/xml/xml-HeaderFromTXTFile.golden create mode 100644 internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden create mode 100644 internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden rename internal/format/testdata/yaml/{yaml-HeaderFromFile.golden => yaml-HeaderFromTFFile.golden} (100%) create mode 100644 internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden create mode 100644 internal/module/testdata/full-example/doc.adoc create mode 100644 internal/module/testdata/full-example/doc.md create mode 100644 internal/module/testdata/full-example/doc.txt diff --git a/.gitignore b/.gitignore index 666ac34..d15f938 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin +coverage.out coverage.txt diff --git a/Makefile b/Makefile index cacaa8a..b814549 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ BUILD_DIR := bin COMMIT_HASH ?= $(shell git rev-parse --short HEAD 2>/dev/null) BUILD_DATE ?= $(shell date +%FT%T%z) VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git describe --tags 2>/dev/null || echo "v0.0.0-$(COMMIT_HASH)") -COVERAGE_OUT := coverage.txt +COVERAGE_OUT := coverage.out # Go variables GOCMD := GO111MODULE=on go diff --git a/examples/doc.adoc b/examples/doc.adoc new file mode 100644 index 0000000..ffe215c --- /dev/null +++ b/examples/doc.adoc @@ -0,0 +1,8 @@ += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. diff --git a/examples/doc.md b/examples/doc.md new file mode 100644 index 0000000..79b0ef9 --- /dev/null +++ b/examples/doc.md @@ -0,0 +1,8 @@ +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. diff --git a/examples/doc.txt b/examples/doc.txt new file mode 100644 index 0000000..6ccbbd6 --- /dev/null +++ b/examples/doc.txt @@ -0,0 +1,8 @@ +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. diff --git a/internal/format/asciidoc_document_test.go b/internal/format/asciidoc_document_test.go index a2428f2..9628ca2 100644 --- a/internal/format/asciidoc_document_test.go +++ b/internal/format/asciidoc_document_test.go @@ -454,25 +454,55 @@ func TestAsciidocDocumentOutputValues(t *testing.T) { } func TestAsciidocDocumentHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "document-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "document-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "document-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "document-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("asciidoc", "document-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("asciidoc", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewAsciidocDocument(settings) - actual, err := printer.Print(module, settings) + printer := NewAsciidocDocument(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestAsciidocDocumentOutputValuesNoSensitivity(t *testing.T) { diff --git a/internal/format/asciidoc_table_test.go b/internal/format/asciidoc_table_test.go index ebb8e0d..8a900ca 100644 --- a/internal/format/asciidoc_table_test.go +++ b/internal/format/asciidoc_table_test.go @@ -454,25 +454,55 @@ func TestAsciidocTableOutputValues(t *testing.T) { } func TestAsciidocTableHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "table-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "table-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "table-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "table-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("asciidoc", "table-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("asciidoc", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewAsciidocTable(settings) - actual, err := printer.Print(module, settings) + printer := NewAsciidocTable(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestAsciidocTableOutputValuesNoSensitivity(t *testing.T) { diff --git a/internal/format/json_test.go b/internal/format/json_test.go index 0a1bf36..791b4ba 100644 --- a/internal/format/json_test.go +++ b/internal/format/json_test.go @@ -393,25 +393,55 @@ func TestJsonOutputValues(t *testing.T) { } func TestJsonHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "json-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "json-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "json-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "json-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("json", "json-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("json", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewJSON(settings) - actual, err := printer.Print(module, settings) + printer := NewJSON(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestJsonEmpty(t *testing.T) { diff --git a/internal/format/markdown_document_test.go b/internal/format/markdown_document_test.go index 9dd024a..aefad26 100644 --- a/internal/format/markdown_document_test.go +++ b/internal/format/markdown_document_test.go @@ -474,25 +474,55 @@ func TestDocumentOutputValues(t *testing.T) { } func TestDocumentHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "document-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "document-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "document-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "document-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("markdown", "document-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("markdown", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewDocument(settings) - actual, err := printer.Print(module, settings) + printer := NewDocument(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestDocumentOutputValuesNoSensitivity(t *testing.T) { diff --git a/internal/format/markdown_table_test.go b/internal/format/markdown_table_test.go index 61b2120..40ce184 100644 --- a/internal/format/markdown_table_test.go +++ b/internal/format/markdown_table_test.go @@ -474,25 +474,55 @@ func TestTableOutputValues(t *testing.T) { } func TestTableHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "table-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "table-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "table-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "table-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("markdown", "table-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("markdown", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewTable(settings) - actual, err := printer.Print(module, settings) + printer := NewTable(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestTableOutputValuesNoSensitivity(t *testing.T) { diff --git a/internal/format/pretty_test.go b/internal/format/pretty_test.go index 65a2e89..1655e59 100644 --- a/internal/format/pretty_test.go +++ b/internal/format/pretty_test.go @@ -393,25 +393,55 @@ func TestPrettyOutputValues(t *testing.T) { } func TestPrettyHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().WithColor().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "pretty-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "pretty-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "pretty-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "pretty-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().WithColor().Build() - expected, err := testutil.GetExpected("pretty", "pretty-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("pretty", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewPretty(settings) - actual, err := printer.Print(module, settings) + printer := NewPretty(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestPrettyEmpty(t *testing.T) { diff --git a/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden new file mode 100644 index 0000000..7205eeb --- /dev/null +++ b/internal/format/testdata/asciidoc/document-HeaderFromADOCFile.golden @@ -0,0 +1,353 @@ += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== 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"` + +=== 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 diff --git a/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden new file mode 100644 index 0000000..9ed7143 --- /dev/null +++ b/internal/format/testdata/asciidoc/document-HeaderFromMDFile.golden @@ -0,0 +1,353 @@ +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== 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"` + +=== 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 diff --git a/internal/format/testdata/asciidoc/document-HeaderFromFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/asciidoc/document-HeaderFromFile.golden rename to internal/format/testdata/asciidoc/document-HeaderFromTFFile.golden diff --git a/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden b/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden new file mode 100644 index 0000000..377bd6f --- /dev/null +++ b/internal/format/testdata/asciidoc/document-HeaderFromTXTFile.golden @@ -0,0 +1,353 @@ +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== 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"` + +=== 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 diff --git a/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden new file mode 100644 index 0000000..ffd4ad0 --- /dev/null +++ b/internal/format/testdata/asciidoc/table-HeaderFromADOCFile.golden @@ -0,0 +1,265 @@ += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== Requirements + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|terraform |>= 0.12 +|aws |>= 2.15.0 +|random |>= 2.2.0 +|=== + +== Providers + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|tls |n/a +|aws |>= 2.15.0 +|aws.ident |>= 2.15.0 +|null |n/a +|=== + +== Inputs + +[cols="a,a,a,a",options="header,autowidth"] +|=== +|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"` + +|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` +| + +[source] +---- +{ + "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` +| + +[source] +---- +[ + "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 +[source] +---- +default = [ + "machine rack01:neptune" +] +---- + +|`list` +| + +[source] +---- +[ + "name rack:location" +] +---- + +|long_type +|This description is itself markdown. + +It spans over multiple lines. + +| + +[source] +---- +object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) +---- + +| + +[source] +---- +{ + "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 + +[cols="a,a",options="header,autowidth"] +|=== +|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 +|=== diff --git a/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden new file mode 100644 index 0000000..4b0bc0f --- /dev/null +++ b/internal/format/testdata/asciidoc/table-HeaderFromMDFile.golden @@ -0,0 +1,265 @@ +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== Requirements + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|terraform |>= 0.12 +|aws |>= 2.15.0 +|random |>= 2.2.0 +|=== + +== Providers + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|tls |n/a +|aws |>= 2.15.0 +|aws.ident |>= 2.15.0 +|null |n/a +|=== + +== Inputs + +[cols="a,a,a,a",options="header,autowidth"] +|=== +|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"` + +|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` +| + +[source] +---- +{ + "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` +| + +[source] +---- +[ + "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 +[source] +---- +default = [ + "machine rack01:neptune" +] +---- + +|`list` +| + +[source] +---- +[ + "name rack:location" +] +---- + +|long_type +|This description is itself markdown. + +It spans over multiple lines. + +| + +[source] +---- +object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) +---- + +| + +[source] +---- +{ + "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 + +[cols="a,a",options="header,autowidth"] +|=== +|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 +|=== diff --git a/internal/format/testdata/asciidoc/table-HeaderFromFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/asciidoc/table-HeaderFromFile.golden rename to internal/format/testdata/asciidoc/table-HeaderFromTFFile.golden diff --git a/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden b/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden new file mode 100644 index 0000000..f77e84a --- /dev/null +++ b/internal/format/testdata/asciidoc/table-HeaderFromTXTFile.golden @@ -0,0 +1,265 @@ +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +== Requirements + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|terraform |>= 0.12 +|aws |>= 2.15.0 +|random |>= 2.2.0 +|=== + +== Providers + +[cols="a,a",options="header,autowidth"] +|=== +|Name |Version +|tls |n/a +|aws |>= 2.15.0 +|aws.ident |>= 2.15.0 +|null |n/a +|=== + +== Inputs + +[cols="a,a,a,a",options="header,autowidth"] +|=== +|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"` + +|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` +| + +[source] +---- +{ + "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` +| + +[source] +---- +[ + "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 +[source] +---- +default = [ + "machine rack01:neptune" +] +---- + +|`list` +| + +[source] +---- +[ + "name rack:location" +] +---- + +|long_type +|This description is itself markdown. + +It spans over multiple lines. + +| + +[source] +---- +object({ + name = string, + foo = object({ foo = string, bar = string }), + bar = object({ foo = string, bar = string }), + fizz = list(string), + buzz = list(string) + }) +---- + +| + +[source] +---- +{ + "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 + +[cols="a,a",options="header,autowidth"] +|=== +|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 +|=== diff --git a/internal/format/testdata/json/json-HeaderFromADOCFile.golden b/internal/format/testdata/json/json-HeaderFromADOCFile.golden new file mode 100644 index 0000000..3922a45 --- /dev/null +++ b/internal/format/testdata/json/json-HeaderFromADOCFile.golden @@ -0,0 +1,294 @@ +{ + "header": "= This header comes from a custom AsciiDoc file\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna\naliqua. Ut enim ad minim veniam, quis nostrud exercitation\nullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit\nesse cillum dolore eu fugiat nulla pariatur.\n", + "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": "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 + } + ], + "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" + } + ] +} \ No newline at end of file diff --git a/internal/format/testdata/json/json-HeaderFromMDFile.golden b/internal/format/testdata/json/json-HeaderFromMDFile.golden new file mode 100644 index 0000000..98379f7 --- /dev/null +++ b/internal/format/testdata/json/json-HeaderFromMDFile.golden @@ -0,0 +1,294 @@ +{ + "header": "# This header comes from a custom Markdown file\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna\naliqua. Ut enim ad minim veniam, quis nostrud exercitation\nullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit\nesse cillum dolore eu fugiat nulla pariatur.\n", + "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": "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 + } + ], + "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" + } + ] +} \ No newline at end of file diff --git a/internal/format/testdata/json/json-HeaderFromFile.golden b/internal/format/testdata/json/json-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/json/json-HeaderFromFile.golden rename to internal/format/testdata/json/json-HeaderFromTFFile.golden diff --git a/internal/format/testdata/json/json-HeaderFromTXTFile.golden b/internal/format/testdata/json/json-HeaderFromTXTFile.golden new file mode 100644 index 0000000..f988eea --- /dev/null +++ b/internal/format/testdata/json/json-HeaderFromTXTFile.golden @@ -0,0 +1,294 @@ +{ + "header": "# This header comes from a custom Text file\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna\naliqua. Ut enim ad minim veniam, quis nostrud exercitation\nullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit\nesse cillum dolore eu fugiat nulla pariatur.\n", + "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": "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 + } + ], + "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" + } + ] +} \ No newline at end of file diff --git a/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden b/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden new file mode 100644 index 0000000..bd04807 --- /dev/null +++ b/internal/format/testdata/markdown/document-HeaderFromADOCFile.golden @@ -0,0 +1,353 @@ += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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"` + +### 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 diff --git a/internal/format/testdata/markdown/document-HeaderFromMDFile.golden b/internal/format/testdata/markdown/document-HeaderFromMDFile.golden new file mode 100644 index 0000000..22935be --- /dev/null +++ b/internal/format/testdata/markdown/document-HeaderFromMDFile.golden @@ -0,0 +1,353 @@ +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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"` + +### 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 diff --git a/internal/format/testdata/markdown/document-HeaderFromFile.golden b/internal/format/testdata/markdown/document-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/markdown/document-HeaderFromFile.golden rename to internal/format/testdata/markdown/document-HeaderFromTFFile.golden diff --git a/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden b/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden new file mode 100644 index 0000000..414a2f2 --- /dev/null +++ b/internal/format/testdata/markdown/document-HeaderFromTXTFile.golden @@ -0,0 +1,353 @@ +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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"` + +### 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 diff --git a/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden b/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden new file mode 100644 index 0000000..db4f14d --- /dev/null +++ b/internal/format/testdata/markdown/table-HeaderFromADOCFile.golden @@ -0,0 +1,69 @@ += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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 | + +## 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"` | +| 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 | diff --git a/internal/format/testdata/markdown/table-HeaderFromMDFile.golden b/internal/format/testdata/markdown/table-HeaderFromMDFile.golden new file mode 100644 index 0000000..ee9fee9 --- /dev/null +++ b/internal/format/testdata/markdown/table-HeaderFromMDFile.golden @@ -0,0 +1,69 @@ +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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 | + +## 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"` | +| 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 | diff --git a/internal/format/testdata/markdown/table-HeaderFromFile.golden b/internal/format/testdata/markdown/table-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/markdown/table-HeaderFromFile.golden rename to internal/format/testdata/markdown/table-HeaderFromTFFile.golden diff --git a/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden b/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden new file mode 100644 index 0000000..9ac8cae --- /dev/null +++ b/internal/format/testdata/markdown/table-HeaderFromTXTFile.golden @@ -0,0 +1,69 @@ +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + +## 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 | + +## 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"` | +| 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 | diff --git a/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden new file mode 100644 index 0000000..3ce0c1b --- /dev/null +++ b/internal/format/testdata/pretty/pretty-HeaderFromADOCFile.golden @@ -0,0 +1,169 @@ + + += This header comes from a custom AsciiDoc file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + + + + +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 + + + +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.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 + diff --git a/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden new file mode 100644 index 0000000..37c27d3 --- /dev/null +++ b/internal/format/testdata/pretty/pretty-HeaderFromMDFile.golden @@ -0,0 +1,169 @@ + + +# This header comes from a custom Markdown file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + + + + +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 + + + +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.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 + diff --git a/internal/format/testdata/pretty/pretty-HeaderFromFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/pretty/pretty-HeaderFromFile.golden rename to internal/format/testdata/pretty/pretty-HeaderFromTFFile.golden diff --git a/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden b/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden new file mode 100644 index 0000000..2ba53ee --- /dev/null +++ b/internal/format/testdata/pretty/pretty-HeaderFromTXTFile.golden @@ -0,0 +1,169 @@ + + +# This header comes from a custom Text file + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation +ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit +esse cillum dolore eu fugiat nulla pariatur. + + + + +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 + + + +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.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 + diff --git a/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden b/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden new file mode 100644 index 0000000..6d48fbe --- /dev/null +++ b/internal/format/testdata/xml/xml-HeaderFromADOCFile.golden @@ -0,0 +1,294 @@ + +
= This header comes from a custom AsciiDoc file Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+ + + 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 + + + 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 + + +
\ No newline at end of file diff --git a/internal/format/testdata/xml/xml-HeaderFromMDFile.golden b/internal/format/testdata/xml/xml-HeaderFromMDFile.golden new file mode 100644 index 0000000..b7b3b44 --- /dev/null +++ b/internal/format/testdata/xml/xml-HeaderFromMDFile.golden @@ -0,0 +1,294 @@ + +
# This header comes from a custom Markdown file Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+ + + 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 + + + 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 + + +
\ No newline at end of file diff --git a/internal/format/testdata/xml/xml-HeaderFromFile.golden b/internal/format/testdata/xml/xml-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/xml/xml-HeaderFromFile.golden rename to internal/format/testdata/xml/xml-HeaderFromTFFile.golden diff --git a/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden b/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden new file mode 100644 index 0000000..d45f894 --- /dev/null +++ b/internal/format/testdata/xml/xml-HeaderFromTXTFile.golden @@ -0,0 +1,294 @@ + +
# This header comes from a custom Text file Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+ + + 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 + + + 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 + + +
\ No newline at end of file diff --git a/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden new file mode 100644 index 0000000..2ae93d3 --- /dev/null +++ b/internal/format/testdata/yaml/yaml-HeaderFromADOCFile.golden @@ -0,0 +1,218 @@ +header: | + = This header comes from a custom AsciiDoc file + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, + sed do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation + ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit + esse cillum dolore eu fugiat nulla pariatur. +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: 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 +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' \ No newline at end of file diff --git a/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden new file mode 100644 index 0000000..ff361d1 --- /dev/null +++ b/internal/format/testdata/yaml/yaml-HeaderFromMDFile.golden @@ -0,0 +1,218 @@ +header: | + # This header comes from a custom Markdown file + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, + sed do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation + ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit + esse cillum dolore eu fugiat nulla pariatur. +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: 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 +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' \ No newline at end of file diff --git a/internal/format/testdata/yaml/yaml-HeaderFromFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden similarity index 100% rename from internal/format/testdata/yaml/yaml-HeaderFromFile.golden rename to internal/format/testdata/yaml/yaml-HeaderFromTFFile.golden diff --git a/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden b/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden new file mode 100644 index 0000000..2e1d993 --- /dev/null +++ b/internal/format/testdata/yaml/yaml-HeaderFromTXTFile.golden @@ -0,0 +1,218 @@ +header: | + # This header comes from a custom Text file + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, + sed do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation + ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit + esse cillum dolore eu fugiat nulla pariatur. +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: 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 +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' \ No newline at end of file diff --git a/internal/format/xml_test.go b/internal/format/xml_test.go index 6e143d4..2e849b8 100644 --- a/internal/format/xml_test.go +++ b/internal/format/xml_test.go @@ -373,25 +373,55 @@ func TestXmlOutputValues(t *testing.T) { } func TestXmlHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "xml-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "xml-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "xml-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "xml-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("xml", "xml-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("xml", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewXML(settings) - actual, err := printer.Print(module, settings) + printer := NewXML(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestXmlEmpty(t *testing.T) { diff --git a/internal/format/yaml_test.go b/internal/format/yaml_test.go index 05d3ec8..bfa3903 100644 --- a/internal/format/yaml_test.go +++ b/internal/format/yaml_test.go @@ -373,25 +373,55 @@ func TestYamlOutputValues(t *testing.T) { } func TestYamlHeaderFromFile(t *testing.T) { - assert := assert.New(t) - settings := testutil.Settings().WithSections().Build() + tests := []struct { + name string + golden string + file string + }{ + { + name: "load module header from .adoc", + golden: "yaml-HeaderFromADOCFile", + file: "doc.adoc", + }, + { + name: "load module header from .md", + golden: "yaml-HeaderFromMDFile", + file: "doc.md", + }, + { + name: "load module header from .tf", + golden: "yaml-HeaderFromTFFile", + file: "doc.tf", + }, + { + name: "load module header from .txt", + golden: "yaml-HeaderFromTXTFile", + file: "doc.txt", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + settings := testutil.Settings().WithSections().Build() - expected, err := testutil.GetExpected("yaml", "yaml-HeaderFromFile") - assert.Nil(err) + expected, err := testutil.GetExpected("yaml", tt.golden) + assert.Nil(err) - options, err := module.NewOptions().WithOverwrite(&module.Options{ - HeaderFromFile: "doc.tf", - }) - assert.Nil(err) + options, err := module.NewOptions().WithOverwrite(&module.Options{ + HeaderFromFile: tt.file, + }) + assert.Nil(err) - module, err := testutil.GetModule(options) - assert.Nil(err) + module, err := testutil.GetModule(options) + assert.Nil(err) - printer := NewYAML(settings) - actual, err := printer.Print(module, settings) + printer := NewYAML(settings) + actual, err := printer.Print(module, settings) - assert.Nil(err) - assert.Equal(expected, actual) + assert.Nil(err) + assert.Equal(expected, actual) + }) + } } func TestYamlEmpty(t *testing.T) { diff --git a/internal/module/module.go b/internal/module/module.go index 2cd4dc5..d9e211f 100644 --- a/internal/module/module.go +++ b/internal/module/module.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "os" "os/exec" "path/filepath" "sort" @@ -64,19 +65,48 @@ func loadModuleItems(tfmodule *tfconfig.Module, options *Options) (*tfconf.Modul }, nil } +func getFileFormat(filename string) string { + if filename == "" { + return "" + } + last := strings.LastIndex(filename, ".") + if last == -1 { + return "" + } + return filename[last:] +} +func isFileFormatSupported(filename string) (bool, error) { + if filename == "" { + return false, fmt.Errorf("--header-from value is missing") + } + switch getFileFormat(filename) { + case ".adoc", ".md", ".tf", ".txt": + return true, nil + } + return false, fmt.Errorf("only .adoc, .md, .tf and .txt formats are supported to read header from") +} + func loadHeader(options *Options) (string, error) { if !options.ShowHeader { return "", nil } - + if ok, err := isFileFormatSupported(options.HeaderFromFile); !ok { + return "", err + } filename := filepath.Join(options.Path, options.HeaderFromFile) - _, err := ioutil.ReadFile(filename) - if err != nil { + if info, err := os.Stat(filename); os.IsNotExist(err) || info.IsDir() { if options.HeaderFromFile != "main.tf" { return "", err // user explicitly asked for a file which doesn't exist } return "", nil // absorb the error to not break workflow of users who don't have 'main.tf at all } + if getFileFormat(options.HeaderFromFile) != ".tf" { + content, err := ioutil.ReadFile(filename) + if err != nil { + return "", err + } + return string(content), nil + } lines := reader.Lines{ FileName: filename, LineNum: -1, diff --git a/internal/module/module_test.go b/internal/module/module_test.go index fffa058..5d1e534 100644 --- a/internal/module/module_test.go +++ b/internal/module/module_test.go @@ -53,6 +53,118 @@ func TestLoadModule(t *testing.T) { } } +func TestGetFileFormat(t *testing.T) { + tests := []struct { + name string + filename string + expected string + }{ + { + name: "get file format", + filename: "main.tf", + expected: ".tf", + }, + { + name: "get file format", + filename: "main.file.tf", + expected: ".tf", + }, + { + name: "get file format", + filename: "main_file.tf", + expected: ".tf", + }, + { + name: "get file format", + filename: "main.file_tf", + expected: ".file_tf", + }, + { + name: "get file format", + filename: "main_file_tf", + expected: "", + }, + { + name: "get file format", + filename: "", + expected: "", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + actual := getFileFormat(tt.filename) + assert.Equal(tt.expected, actual) + }) + } +} + +func TestIsFileFormatSupported(t *testing.T) { + tests := []struct { + name string + filename string + expected bool + wantErr bool + errText string + }{ + { + name: "is file format supported", + filename: "main.adoc", + expected: true, + wantErr: false, + errText: "", + }, + { + name: "is file format supported", + filename: "main.md", + expected: true, + wantErr: false, + errText: "", + }, + { + name: "is file format supported", + filename: "main.tf", + expected: true, + wantErr: false, + errText: "", + }, + { + name: "is file format supported", + filename: "main.txt", + expected: true, + wantErr: false, + errText: "", + }, + { + name: "is file format supported", + filename: "main.doc", + expected: false, + wantErr: true, + errText: "only .adoc, .md, .tf and .txt formats are supported to read header from", + }, + { + name: "is file format supported", + filename: "", + expected: false, + wantErr: true, + errText: "--header-from value is missing", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert := assert.New(t) + actual, err := isFileFormatSupported(tt.filename) + if tt.wantErr { + assert.NotNil(err) + assert.Equal(tt.errText, err.Error()) + } else { + assert.Nil(err) + assert.Equal(tt.expected, actual) + } + }) + } +} + func TestLoadHeader(t *testing.T) { tests := []struct { name string @@ -60,6 +172,7 @@ func TestLoadHeader(t *testing.T) { header string expected string wantErr bool + errText string }{ { name: "load module header from path", @@ -67,6 +180,7 @@ func TestLoadHeader(t *testing.T) { header: "main.tf", expected: "Example 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/)", wantErr: false, + errText: "", }, { name: "load module header from path", @@ -74,6 +188,31 @@ func TestLoadHeader(t *testing.T) { header: "doc.tf", expected: "Custom Header:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2", wantErr: false, + errText: "", + }, + { + name: "load module header from path", + path: "full-example", + header: "doc.md", + expected: "# Custom Header\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n", + wantErr: false, + errText: "", + }, + { + name: "load module header from path", + path: "full-example", + header: "doc.adoc", + expected: "= Custom Header\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n", + wantErr: false, + errText: "", + }, + { + name: "load module header from path", + path: "full-example", + header: "doc.txt", + expected: "# Custom Header\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n", + wantErr: false, + errText: "", }, { name: "load module header from path", @@ -81,6 +220,7 @@ func TestLoadHeader(t *testing.T) { header: "main.tf", expected: "", wantErr: false, + errText: "", }, { name: "load module header from path", @@ -88,6 +228,15 @@ func TestLoadHeader(t *testing.T) { header: "non-existent.tf", expected: "", wantErr: true, + errText: "stat testdata/full-example/non-existent.tf: no such file or directory", + }, + { + name: "load module header from path", + path: "full-example", + header: "wrong-formate.docx", + expected: "", + wantErr: true, + errText: "only .adoc, .md, .tf and .txt formats are supported to read header from", }, { name: "load module header from path", @@ -95,6 +244,7 @@ func TestLoadHeader(t *testing.T) { header: "", expected: "", wantErr: true, + errText: "--header-from value is missing", }, { name: "load module header from path", @@ -102,6 +252,7 @@ func TestLoadHeader(t *testing.T) { header: "", expected: "", wantErr: true, + errText: "--header-from value is missing", }, { name: "load module header from path", @@ -109,6 +260,7 @@ func TestLoadHeader(t *testing.T) { header: "", expected: "", wantErr: true, + errText: "--header-from value is missing", }, } for _, tt := range tests { @@ -118,6 +270,7 @@ func TestLoadHeader(t *testing.T) { actual, err := loadHeader(options) if tt.wantErr { assert.NotNil(err) + assert.Equal(tt.errText, err.Error()) } else { assert.Nil(err) assert.Equal(tt.expected, actual) diff --git a/internal/module/testdata/full-example/doc.adoc b/internal/module/testdata/full-example/doc.adoc new file mode 100644 index 0000000..94e77c5 --- /dev/null +++ b/internal/module/testdata/full-example/doc.adoc @@ -0,0 +1,6 @@ += Custom Header + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 diff --git a/internal/module/testdata/full-example/doc.md b/internal/module/testdata/full-example/doc.md new file mode 100644 index 0000000..f75f137 --- /dev/null +++ b/internal/module/testdata/full-example/doc.md @@ -0,0 +1,6 @@ +# Custom Header + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2 diff --git a/internal/module/testdata/full-example/doc.txt b/internal/module/testdata/full-example/doc.txt new file mode 100644 index 0000000..f75f137 --- /dev/null +++ b/internal/module/testdata/full-example/doc.txt @@ -0,0 +1,6 @@ +# Custom Header + +Example of 'foo_bar' module in `foo_bar.tf`. + +- list item 1 +- list item 2