Prepend any type of resource, including `resource`, `data`, `module`,
`variable`, and `output` with a comment including "terraform-docs-ignore"
to exclude it from the generated output.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Numerous Google Cloud Go packages have been upgraded to their latest versions in the go.sum dependencies file. This enhances the codebase with the latest features, improvements, and bug fixes offered by these packages. It's part of an effort to keep the project's dependencies up to date and ensure the application runs optimally with the latest available resources.
Signed-off-by: Aurelian Shuttleworth <aurelian@shuttleworth.tech>
Moving terraform-docs/plugin-sdk standalone module to in-tree, because
maintaining both of them, specifically if anything needs to be added to
Config, or terraform will required dual effort on both repository. As
such now everything is consolidated under one repository. Example usage
for plugin developer after this move is as follow:
```go
package main
import (
_ "embed" //nolint
"github.com/terraform-docs/terraform-docs/plugin"
"github.com/terraform-docs/terraform-docs/print"
"github.com/terraform-docs/terraform-docs/template"
"github.com/terraform-docs/terraform-docs/terraform"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
Name: "template",
Version: "0.1.0",
Printer: printer,
})
}
//go:embed sections.tmpl
var tplCustom []byte
// Print the custom format template. You have all the flexibility to generate
// the output however you choose to.
func printer(config *print.Config, module *terraform.Module) (string, error) {
tpl := template.New(config,
&template.Item{Name: "custom", Text: string(tplCustom)},
)
rendered, err := tpl.Render("custom", module)
if err != nil {
return "", err
}
return rendered, nil
}
```
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Packer config, since 1.7.0, prefers HCL2 which effectively makes us to
reuse the same binary for generating documentation for it with terraform-docs
as well. The missing part was that terraform-config-inspect did not
recognize `pkr.hcl` and `pkr.json` as valid formats, which this fixes that.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
If .terraform.lock.hcl exists in module path, try to extract the exact
provider version being used as opposed to provided constraints.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Generated content can be customized further away with `content` in configuration.
If the `content` is empty the default orders of section is used. `content` is a
Go template with following additional variables:
- `{{ .Header }}`
- `{{ .Footer }}`
- `{{ .Inputs }}`
- `{{ .Modules }}`
- `{{ .Outputs }}`
- `{{ .Providers }}`
- `{{ .Requirements }}`
- `{{ .Resources }}`
```yaml
content: |-
Any arbitrary text can be placed anywhere in the content
{{ .Header }}
and even in between sections
{{ .Providers }}
and they don't even need to be in the default order
{{ .Outputs }}
{{ .Inputs }}
```
These variables are the generated output of individual sections in the selected
formatter. For example `{{ .Inputs }}` is Markdown Table representation of inputs
when formatter is set to `markdown table` and AsciiDoc Document representation
when formatter is set to `asciidoc document` and so on.
Compatible formats for customized content are:
- `asciidoc document`
- `asciidoc table`
- `markdown document`
- `markdown table`
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Configuration can be loaded with `-c, --config string` which accepts
both relative and absolute paths.
$ pwd
/path/to/parent/folder
$ tree
.
├── module-a
│ └── main.tf
├── module-b
│ └── main.tf
├── ...
└── .terraform-docs.yml
# executing from parent
$ terraform-docs -c .terraform-docs.yml module-a/
# executing from child
$ cd module-a/
$ terraform-docs -c ../.terraform-docs.yml .
# or an absolute path
$ terraform-docs -c /path/to/parent/folder/.terraform-docs.yml .
The order for looking for config file is:
1. root of module directory
2. current directory
3. `$HOME/.tfdocs.d/`
if `.terraform-docs.yml` is found in any of the folders above, that will
take precedence and will override the other ones. Note that values passed
directly as CLI flags will override all of the above.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
terraform-docs version constraints is almost identical to the syntax
used by Terraform. A version constraint is a string literal containing
one or more condition, which are separated by commas.
```yaml
version: ">= 0.13.0, < 1.0.0"
```
Each condition consists of an operator and a version number. A version
number is a series of numbers separated by dots (e.g. `0.13.0`). Note
that version number should not have leading `v` in it.
Valid operators are as follow:
- `=` (or no operator): allows for exact version number.
- `!=`: exclude an exact version number.
- `>`, `>=`, `<`, and `<=`: comparisons against a specific version.
- `~>`: only the rightmost version component to increment.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Enables a footer to be appended to the end of a generated document
sourced from tf files or documents in the same way as the header
Adds the `footer-from` field to the config yml
Adds the `--footer-from` flag to the cli
Signed-off-by: Simon Clifford <siclifford@gmail.com>
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Two new flags are added: '--default bool' and '--type bool' to
control the visibility of Default and Type columns and section
respectively in Markdown and AsciiDoc.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Originally pkg/tfconf was set to be public to be used by plugin
developers, but these structs have to be defined by plugin-sdk and as
such it's moved to internal/terraform to be only used by terraform-docs
core project.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Originally we in-tree forked hashicorp/terraform-config-inspect project
due to it being stalled and we depended on a fix upstream. But now that
seems to be resolved and they've added the feature we were looking for
in upstream.
Although, to prevent future dependency lock, we went ahead and forked
the project under terraform-docs organization and will be using that,
which at this point is identical to upstream and we don have any reason
to believe that changes anytime soon too.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>