mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 04:48:33 +07:00
feat: Add support for TOML renderer (#197)
* Add support for TOML renderer * Add kind:formatter to toml command * update docs * adjust tests after merge * fix after merge * adjust tests after merge * update docs * remove vendor leftovers * update doc * update tests
This commit is contained in:
@@ -19,6 +19,7 @@ terraform-docs markdown document ./my-terraform-module # generate markdown docum
|
||||
terraform-docs pretty ./my-terraform-module # generate colorized pretty
|
||||
terraform-docs tfvars hcl ./my-terraform-module # generate hcl format of terraform.tfvars
|
||||
terraform-docs tfvars json ./my-terraform-module # generate json format of terraform.tfvars
|
||||
terraform-docs toml ./my-terraform-module # generate toml
|
||||
terraform-docs xml ./my-terraform-module # generate xml
|
||||
terraform-docs yaml ./my-terraform-module # generate yaml
|
||||
```
|
||||
|
||||
17
cmd/toml.go
Normal file
17
cmd/toml.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var tomlCmd = &cobra.Command{
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "toml [PATH]",
|
||||
Short: "Generate TOML of inputs and outputs",
|
||||
Annotations: formatAnnotations("toml"),
|
||||
RunE: formatRunE,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(tomlCmd)
|
||||
}
|
||||
@@ -36,6 +36,7 @@ A utility to generate documentation from Terraform modules in various output for
|
||||
* [terraform-docs tfvars](/docs/formats/tfvars.md) - Generate terraform.tfvars of inputs
|
||||
* [terraform-docs tfvars hcl](/docs/formats/tfvars-hcl.md) - Generate HCL format of terraform.tfvars of inputs
|
||||
* [terraform-docs tfvars json](/docs/formats/tfvars-json.md) - Generate JSON format of terraform.tfvars of inputs
|
||||
* [terraform-docs toml](/docs/formats/toml.md) - Generate TOML of inputs and outputs
|
||||
* [terraform-docs xml](/docs/formats/xml.md) - Generate XML of inputs and outputs
|
||||
* [terraform-docs yaml](/docs/formats/yaml.md) - Generate YAML of inputs and outputs
|
||||
|
||||
|
||||
319
docs/formats/toml.md
Normal file
319
docs/formats/toml.md
Normal file
@@ -0,0 +1,319 @@
|
||||
## terraform-docs toml
|
||||
|
||||
Generate TOML of inputs and outputs
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate TOML of inputs and outputs
|
||||
|
||||
```
|
||||
terraform-docs toml [PATH] [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for toml
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--header-from string relative path of a file to read header from (default "main.tf")
|
||||
--no-header do not show module header
|
||||
--no-inputs do not show inputs
|
||||
--no-outputs do not show outputs
|
||||
--no-providers do not show providers
|
||||
--no-requirements do not show module requirements
|
||||
--no-sort do no sort items
|
||||
--output-values inject output values into outputs
|
||||
--output-values-from string inject output values from file into outputs
|
||||
--sort-by-required sort items by name and print required ones first
|
||||
--sort-by-type sort items by type of them
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
Given the [`examples`](/examples/) module:
|
||||
|
||||
```shell
|
||||
terraform-docs toml ./examples/
|
||||
```
|
||||
|
||||
generates the following output:
|
||||
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
|
||||
|
||||
|
||||
###### Auto generated by spf13/cobra on 14-May-2020
|
||||
1
go.mod
1
go.mod
@@ -3,6 +3,7 @@ module github.com/segmentio/terraform-docs
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/go-test/deep v1.0.6
|
||||
github.com/hashicorp/hcl v1.0.0
|
||||
github.com/hashicorp/hcl/v2 v2.5.1
|
||||
|
||||
2
go.sum
2
go.sum
@@ -55,8 +55,6 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/hcl/v2 v2.5.0 h1:tnNRfUho4o/6qLTqd54gj9Gs5AWmdc0tG8YdElu6MEw=
|
||||
github.com/hashicorp/hcl/v2 v2.5.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
|
||||
github.com/hashicorp/hcl/v2 v2.5.1 h1:5ytFZykUu2/4U59ogd2f+XZdi9+6oC/Tv5WzsH6fIDA=
|
||||
github.com/hashicorp/hcl/v2 v2.5.1/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
|
||||
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk=
|
||||
|
||||
@@ -32,6 +32,8 @@ func Factory(name string, settings *print.Settings) (print.Format, error) {
|
||||
return NewTfvarsHCL(settings), nil
|
||||
case "tfvars json":
|
||||
return NewTfvarsJSON(settings), nil
|
||||
case "toml":
|
||||
return NewTOML(settings), nil
|
||||
case "xml":
|
||||
return NewXML(settings), nil
|
||||
case "yaml":
|
||||
|
||||
@@ -75,6 +75,12 @@ func TestFormatFactory(t *testing.T) {
|
||||
expected: "*format.TfvarsJSON",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "format factory from name",
|
||||
format: "toml",
|
||||
expected: "*format.TOML",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "format factory from name",
|
||||
format: "xml",
|
||||
|
||||
5
internal/format/testdata/toml/toml-Empty.golden
vendored
Normal file
5
internal/format/testdata/toml/toml-Empty.golden
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
header = ""
|
||||
inputs = []
|
||||
outputs = []
|
||||
providers = []
|
||||
requirements = []
|
||||
271
internal/format/testdata/toml/toml-HeaderFromFile.golden
vendored
Normal file
271
internal/format/testdata/toml/toml-HeaderFromFile.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = "This header comes from a custom 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."
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
271
internal/format/testdata/toml/toml-NoHeader.golden
vendored
Normal file
271
internal/format/testdata/toml/toml-NoHeader.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = ""
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
50
internal/format/testdata/toml/toml-NoInputs.golden
vendored
Normal file
50
internal/format/testdata/toml/toml-NoInputs.golden
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
inputs = []
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
256
internal/format/testdata/toml/toml-NoOutputs.golden
vendored
Normal file
256
internal/format/testdata/toml/toml-NoOutputs.golden
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
outputs = []
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
252
internal/format/testdata/toml/toml-NoProviders.golden
vendored
Normal file
252
internal/format/testdata/toml/toml-NoProviders.golden
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
providers = []
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
260
internal/format/testdata/toml/toml-NoRequirements.golden
vendored
Normal file
260
internal/format/testdata/toml/toml-NoRequirements.golden
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
requirements = []
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
5
internal/format/testdata/toml/toml-OnlyHeader.golden
vendored
Normal file
5
internal/format/testdata/toml/toml-OnlyHeader.golden
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
inputs = []
|
||||
outputs = []
|
||||
providers = []
|
||||
requirements = []
|
||||
226
internal/format/testdata/toml/toml-OnlyInputs.golden
vendored
Normal file
226
internal/format/testdata/toml/toml-OnlyInputs.golden
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
header = ""
|
||||
outputs = []
|
||||
providers = []
|
||||
requirements = []
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
20
internal/format/testdata/toml/toml-OnlyOutputs.golden
vendored
Normal file
20
internal/format/testdata/toml/toml-OnlyOutputs.golden
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
header = ""
|
||||
inputs = []
|
||||
providers = []
|
||||
requirements = []
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
24
internal/format/testdata/toml/toml-OnlyProviders.golden
vendored
Normal file
24
internal/format/testdata/toml/toml-OnlyProviders.golden
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
header = ""
|
||||
inputs = []
|
||||
outputs = []
|
||||
requirements = []
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
16
internal/format/testdata/toml/toml-OnlyRequirements.golden
vendored
Normal file
16
internal/format/testdata/toml/toml-OnlyRequirements.golden
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
header = ""
|
||||
inputs = []
|
||||
outputs = []
|
||||
providers = []
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
277
internal/format/testdata/toml/toml-OutputValues.golden
vendored
Normal file
277
internal/format/testdata/toml/toml-OutputValues.golden
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
[outputs.value]
|
||||
leon = "cat"
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
value = ["jack", "lola"]
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
value = 1.0
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
value = "<sensitive>"
|
||||
sensitive = true
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
271
internal/format/testdata/toml/toml-SortByName.golden
vendored
Normal file
271
internal/format/testdata/toml/toml-SortByName.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
271
internal/format/testdata/toml/toml-SortByRequired.golden
vendored
Normal file
271
internal/format/testdata/toml/toml-SortByRequired.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
271
internal/format/testdata/toml/toml-SortByType.golden
vendored
Normal file
271
internal/format/testdata/toml/toml-SortByType.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
271
internal/format/testdata/toml/toml.golden
vendored
Normal file
271
internal/format/testdata/toml/toml.golden
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
header = "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n- list item 1\n- list item 2\n\nEven inline **formatting** in _here_ is possible.\nand some [link](https://domain.com/)\n\n* list item 3\n* list item 4\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```\n\nHere is some trailing text after code block,\nfollowed by another line of text.\n\n| Name | Description |\n|------|-----------------|\n| Foo | Foo description |\n| Bar | Bar description |"
|
||||
|
||||
[[inputs]]
|
||||
name = "unquoted"
|
||||
type = "any"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-3"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-2"
|
||||
type = "bool"
|
||||
description = "It's bool number two."
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool-1"
|
||||
type = "bool"
|
||||
description = "It's bool number one."
|
||||
default = true
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-3"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string-2"
|
||||
type = "string"
|
||||
description = "It's string number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string-1"
|
||||
type = "string"
|
||||
description = "It's string number one."
|
||||
default = "bar"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-3"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = "19"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-4"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 15.75
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "number-2"
|
||||
type = "number"
|
||||
description = "It's number number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number-1"
|
||||
type = "number"
|
||||
description = "It's number number one."
|
||||
default = 42.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "map-3"
|
||||
type = "map"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-2"
|
||||
type = "map"
|
||||
description = "It's map number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "map-1"
|
||||
type = "map"
|
||||
description = "It's map number one."
|
||||
required = false
|
||||
[inputs.default]
|
||||
a = 1.0
|
||||
b = 2.0
|
||||
c = 3.0
|
||||
|
||||
[[inputs]]
|
||||
name = "list-3"
|
||||
type = "list"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list-2"
|
||||
type = "list"
|
||||
description = "It's list number two."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "list-1"
|
||||
type = "list"
|
||||
description = "It's list number one."
|
||||
default = ["a", "b", "c"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input_with_underscores"
|
||||
type = "any"
|
||||
description = "A variable with underscores."
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-pipe"
|
||||
type = "string"
|
||||
description = "It includes v1 | v2 | v3"
|
||||
default = "v1"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "input-with-code-block"
|
||||
type = "list"
|
||||
description = "This is a complicated one. We need a newline. \nAnd an example in a code block\n```\ndefault = [\n \"machine rack01:neptune\"\n]\n```\n"
|
||||
default = ["name rack:location"]
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "long_type"
|
||||
type = "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })"
|
||||
description = "This description is itself markdown.\n\nIt spans over multiple lines.\n"
|
||||
required = false
|
||||
[inputs.default]
|
||||
buzz = ["fizz", "buzz"]
|
||||
fizz = []
|
||||
name = "hello"
|
||||
[inputs.default.bar]
|
||||
bar = "bar"
|
||||
foo = "bar"
|
||||
[inputs.default.foo]
|
||||
bar = "foo"
|
||||
foo = "foo"
|
||||
|
||||
[[inputs]]
|
||||
name = "no-escape-default-value"
|
||||
type = "string"
|
||||
description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'."
|
||||
default = "VALUE_WITH_UNDERSCORE"
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "with-url"
|
||||
type = "string"
|
||||
description = "The description contains url. https://www.domain.com/foo/bar_baz.html"
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_empty"
|
||||
type = "string"
|
||||
description = ""
|
||||
default = ""
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "string_default_null"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "string_no_default"
|
||||
type = "string"
|
||||
description = ""
|
||||
required = true
|
||||
[inputs.default]
|
||||
|
||||
[[inputs]]
|
||||
name = "number_default_zero"
|
||||
type = "number"
|
||||
description = ""
|
||||
default = 0.0
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "bool_default_false"
|
||||
type = "bool"
|
||||
description = ""
|
||||
default = false
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "list_default_empty"
|
||||
type = "list(string)"
|
||||
description = ""
|
||||
default = []
|
||||
required = false
|
||||
|
||||
[[inputs]]
|
||||
name = "object_default_empty"
|
||||
type = "object({})"
|
||||
description = ""
|
||||
required = false
|
||||
[inputs.default]
|
||||
|
||||
[[outputs]]
|
||||
name = "unquoted"
|
||||
description = "It's unquoted output."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-2"
|
||||
description = "It's output number two."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-1"
|
||||
description = "It's output number one."
|
||||
|
||||
[[outputs]]
|
||||
name = "output-0.12"
|
||||
description = "terraform 0.12 only"
|
||||
|
||||
[[providers]]
|
||||
name = "tls"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = ""
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "aws"
|
||||
alias = "ident"
|
||||
version = ">= 2.15.0"
|
||||
|
||||
[[providers]]
|
||||
name = "null"
|
||||
alias = ""
|
||||
version = ""
|
||||
|
||||
[[requirements]]
|
||||
Name = "terraform"
|
||||
Version = ">= 0.12"
|
||||
|
||||
[[requirements]]
|
||||
Name = "aws"
|
||||
Version = ">= 2.15.0"
|
||||
|
||||
[[requirements]]
|
||||
Name = "random"
|
||||
Version = ">= 2.2.0"
|
||||
53
internal/format/toml.go
Normal file
53
internal/format/toml.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package format
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/segmentio/terraform-docs/pkg/print"
|
||||
"github.com/segmentio/terraform-docs/pkg/tfconf"
|
||||
)
|
||||
|
||||
// TOML represents TOML format.
|
||||
type TOML struct{}
|
||||
|
||||
// NewTOML returns new instance of TOML.
|
||||
func NewTOML(settings *print.Settings) *TOML {
|
||||
return &TOML{}
|
||||
}
|
||||
|
||||
// Print prints a Terraform module as toml.
|
||||
func (t *TOML) Print(module *tfconf.Module, settings *print.Settings) (string, error) {
|
||||
copy := tfconf.Module{
|
||||
Header: "",
|
||||
Providers: make([]*tfconf.Provider, 0),
|
||||
Inputs: make([]*tfconf.Input, 0),
|
||||
Outputs: make([]*tfconf.Output, 0),
|
||||
Requirements: make([]*tfconf.Requirement, 0),
|
||||
}
|
||||
|
||||
if settings.ShowHeader {
|
||||
copy.Header = module.Header
|
||||
}
|
||||
if settings.ShowInputs {
|
||||
copy.Inputs = module.Inputs
|
||||
}
|
||||
if settings.ShowOutputs {
|
||||
copy.Outputs = module.Outputs
|
||||
}
|
||||
if settings.ShowProviders {
|
||||
copy.Providers = module.Providers
|
||||
}
|
||||
if settings.ShowRequirements {
|
||||
copy.Requirements = module.Requirements
|
||||
}
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
encoder := toml.NewEncoder(buffer)
|
||||
err := encoder.Encode(copy)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return buffer.String(), nil
|
||||
}
|
||||
424
internal/format/toml_test.go
Normal file
424
internal/format/toml_test.go
Normal file
@@ -0,0 +1,424 @@
|
||||
package format
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/segmentio/terraform-docs/internal/module"
|
||||
"github.com/segmentio/terraform-docs/internal/testutil"
|
||||
"github.com/segmentio/terraform-docs/pkg/print"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestToml(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlSortByName(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().With(&print.Settings{
|
||||
SortByName: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-SortByName")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().With(&module.Options{
|
||||
SortBy: &module.SortBy{
|
||||
Name: true,
|
||||
},
|
||||
})
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlSortByRequired(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().With(&print.Settings{
|
||||
SortByName: true,
|
||||
SortByRequired: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-SortByRequired")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().With(&module.Options{
|
||||
SortBy: &module.SortBy{
|
||||
Name: true,
|
||||
Required: true,
|
||||
},
|
||||
})
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlSortByType(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().With(&print.Settings{
|
||||
SortByType: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-SortByType")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().With(&module.Options{
|
||||
SortBy: &module.SortBy{
|
||||
Type: true,
|
||||
},
|
||||
})
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlNoHeader(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: true,
|
||||
ShowOutputs: true,
|
||||
ShowProviders: true,
|
||||
ShowRequirements: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-NoHeader")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlNoInputs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: true,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: true,
|
||||
ShowProviders: true,
|
||||
ShowRequirements: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-NoInputs")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlNoOutputs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: true,
|
||||
ShowInputs: true,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: true,
|
||||
ShowRequirements: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-NoOutputs")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlNoProviders(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: true,
|
||||
ShowInputs: true,
|
||||
ShowOutputs: true,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-NoProviders")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlNoRequirements(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: true,
|
||||
ShowInputs: true,
|
||||
ShowOutputs: true,
|
||||
ShowProviders: true,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-NoRequirements")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOnlyHeader(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: true,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OnlyHeader")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOnlyInputs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: true,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OnlyInputs")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOnlyOutputs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: true,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OnlyOutputs")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOnlyProviders(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: true,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OnlyProviders")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOnlyRequirements(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OnlyRequirements")
|
||||
assert.Nil(err)
|
||||
|
||||
options := module.NewOptions()
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlOutputValues(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().With(&print.Settings{
|
||||
OutputValues: true,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-OutputValues")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().With(&module.Options{
|
||||
OutputValues: true,
|
||||
OutputValuesPath: "output_values.json",
|
||||
})
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlHeaderFromFile(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().WithSections().Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-HeaderFromFile")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().WithOverwrite(&module.Options{
|
||||
HeaderFromFile: "doc.tf",
|
||||
})
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
func TestTomlEmpty(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
settings := testutil.Settings().With(&print.Settings{
|
||||
ShowHeader: false,
|
||||
ShowInputs: false,
|
||||
ShowOutputs: false,
|
||||
ShowProviders: false,
|
||||
ShowRequirements: false,
|
||||
}).Build()
|
||||
|
||||
expected, err := testutil.GetExpected("toml", "toml-Empty")
|
||||
assert.Nil(err)
|
||||
|
||||
options, err := module.NewOptions().WithOverwrite(&module.Options{
|
||||
HeaderFromFile: "bad.tf",
|
||||
})
|
||||
options.ShowHeader = false // Since we don't show the header, the file won't be loaded at all
|
||||
assert.Nil(err)
|
||||
|
||||
module, err := testutil.GetModule(options)
|
||||
assert.Nil(err)
|
||||
|
||||
printer := NewTOML(settings)
|
||||
actual, err := printer.Print(module, settings)
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
|
||||
// Input represents a Terraform input.
|
||||
type Input struct {
|
||||
Name string `json:"name" xml:"name" yaml:"name"`
|
||||
Type types.String `json:"type" xml:"type" yaml:"type"`
|
||||
Description types.String `json:"description" xml:"description" yaml:"description"`
|
||||
Default types.Value `json:"default" xml:"default" yaml:"default"`
|
||||
Required bool `json:"required" xml:"required" yaml:"required"`
|
||||
Position Position `json:"-" xml:"-" yaml:"-"`
|
||||
Name string `json:"name" toml:"name" xml:"name" yaml:"name"`
|
||||
Type types.String `json:"type" toml:"type" xml:"type" yaml:"type"`
|
||||
Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"`
|
||||
Default types.Value `json:"default" toml:"default" xml:"default" yaml:"default"`
|
||||
Required bool `json:"required" toml:"required" xml:"required" yaml:"required"`
|
||||
Position Position `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// GetValue returns JSON representation of the 'Default' value, which is an 'interface'.
|
||||
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
// - Providers ('providers' json key): List of 'providers' extracted from resources used in Terraform module
|
||||
// - Requirements ('header' json key): List of 'requirements' extracted from the Terraform module .tf files
|
||||
type Module struct {
|
||||
XMLName xml.Name `json:"-" xml:"module" yaml:"-"`
|
||||
XMLName xml.Name `json:"-" toml:"-" xml:"module" yaml:"-"`
|
||||
|
||||
Header string `json:"header" xml:"header" yaml:"header"`
|
||||
Inputs []*Input `json:"inputs" xml:"inputs>input" yaml:"inputs"`
|
||||
Outputs []*Output `json:"outputs" xml:"outputs>output" yaml:"outputs"`
|
||||
Providers []*Provider `json:"providers" xml:"providers>provider" yaml:"providers"`
|
||||
Requirements []*Requirement `json:"requirements" xml:"requirements>requirement" yaml:"requirements"`
|
||||
Header string `json:"header" toml:"header" xml:"header" yaml:"header"`
|
||||
Inputs []*Input `json:"inputs" toml:"inputs" xml:"inputs>input" yaml:"inputs"`
|
||||
Outputs []*Output `json:"outputs" toml:"outputs" xml:"outputs>output" yaml:"outputs"`
|
||||
Providers []*Provider `json:"providers" toml:"providers" xml:"providers>provider" yaml:"providers"`
|
||||
Requirements []*Requirement `json:"requirements" toml:"requirements" xml:"requirements>requirement" yaml:"requirements"`
|
||||
|
||||
RequiredInputs []*Input `json:"-" xml:"-" yaml:"-"`
|
||||
OptionalInputs []*Input `json:"-" xml:"-" yaml:"-"`
|
||||
RequiredInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
OptionalInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// HasHeader indicates if the module has header.
|
||||
|
||||
@@ -10,21 +10,21 @@ import (
|
||||
|
||||
// Output represents a Terraform output.
|
||||
type Output struct {
|
||||
Name string `json:"name" xml:"name" yaml:"name"`
|
||||
Description types.String `json:"description" xml:"description" yaml:"description"`
|
||||
Value types.Value `json:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"`
|
||||
Sensitive bool `json:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"`
|
||||
Position Position `json:"-" xml:"-" yaml:"-"`
|
||||
ShowValue bool `json:"-" xml:"-" yaml:"-"`
|
||||
Name string `json:"name" toml:"name" xml:"name" yaml:"name"`
|
||||
Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"`
|
||||
Value types.Value `json:"value,omitempty" toml:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"`
|
||||
Sensitive bool `json:"sensitive,omitempty" toml:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"`
|
||||
Position Position `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
ShowValue bool `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
type withvalue struct {
|
||||
Name string `json:"name" xml:"name" yaml:"name"`
|
||||
Description types.String `json:"description" xml:"description" yaml:"description"`
|
||||
Value types.Value `json:"value" xml:"value" yaml:"value"`
|
||||
Sensitive bool `json:"sensitive" xml:"sensitive" yaml:"sensitive"`
|
||||
Position Position `json:"-" xml:"-" yaml:"-"`
|
||||
ShowValue bool `json:"-" xml:"-" yaml:"-"`
|
||||
Name string `json:"name" toml:"name" xml:"name" yaml:"name"`
|
||||
Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"`
|
||||
Value types.Value `json:"value" toml:"value" xml:"value" yaml:"value"`
|
||||
Sensitive bool `json:"sensitive" toml:"sensitive" xml:"sensitive" yaml:"sensitive"`
|
||||
Position Position `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
ShowValue bool `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// GetValue returns JSON representation of the 'Value', which is an 'interface'.
|
||||
|
||||
@@ -2,6 +2,6 @@ package tfconf
|
||||
|
||||
// Position represents position of Terraform input or output in a file.
|
||||
type Position struct {
|
||||
Filename string `json:"-" xml:"-" yaml:"-"`
|
||||
Line int `json:"-" xml:"-" yaml:"-"`
|
||||
Filename string `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
Line int `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
|
||||
// Provider represents a Terraform output.
|
||||
type Provider struct {
|
||||
Name string `json:"name" xml:"name" yaml:"name"`
|
||||
Alias types.String `json:"alias" xml:"alias" yaml:"alias"`
|
||||
Version types.String `json:"version" xml:"version" yaml:"version"`
|
||||
Position Position `json:"-" xml:"-" yaml:"-"`
|
||||
Name string `json:"name" toml:"name" xml:"name" yaml:"name"`
|
||||
Alias types.String `json:"alias" toml:"alias" xml:"alias" yaml:"alias"`
|
||||
Version types.String `json:"version" toml:"version" xml:"version" yaml:"version"`
|
||||
Position Position `json:"-" toml:"-" xml:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// FullName returns full name of the provider, with alias if available
|
||||
|
||||
Reference in New Issue
Block a user