Documentation ¶
Overview ¶
Package print provides configuration, and a Generator.
Configuration ¶
`print.Config` is the data structure representation for `.terraform-docs.yml` which will be read and extracted upon execution of terraform-docs cli. On the other hand it can be used directly if you are using terraform-docs as a library.
This will return an instance of `Config` with default values set:
config := print.DefaultConfig()
Alternatively this will return an empty instance of `Config`:
config := print.NewConfig()
Generator ¶
`Generator` is an abstract implementation of `format.Type`. It doesn't implement `Generate(*terraform.Module) error` function. It is used directly by different format types, i.e. each format extends `Generator` and provides its implementation of `Generate` function.
Generator holds a reference to all the sections (e.g. header, footer, inputs, etc) and also it renders all of them, in a predefined order, in `Content()`.
It also provides `Render(string)` function to process and render the template to generate the final output content. Following variables and functions are available:
• `{{ .Header }}` • `{{ .Footer }}` • `{{ .Inputs }}` • `{{ .Modules }}` • `{{ .Outputs }}` • `{{ .Providers }}` • `{{ .Requirements }}` • `{{ .Resources }}` • `{{ include "path/fo/file" }}`
Index ¶
Constants ¶
const ( OutputModeInject = "inject" OutputModeReplace = "replace" )
Output modes.
const ( OutputBeginComment = "<!-- BEGIN_TF_DOCS -->" OutputContent = "{{ .Content }}" OutputEndComment = "<!-- END_TF_DOCS -->" )
Output template.
const ( SortName = "name" SortRequired = "required" SortType = "type" )
Sort types.
Variables ¶
var ( OutputTemplate = fmt.Sprintf("%s\n%s\n%s", OutputBeginComment, OutputContent, OutputEndComment) OutputModes = strings.Join([]string{OutputModeInject, OutputModeReplace}, ", ") )
Output to file template and modes.
var AllSections = strings.Join(allSections, ", ")
AllSections list.
var SortTypes = strings.Join(allSorts, ", ")
SortTypes list.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.16.0
type Config struct { File string `mapstructure:"-"` Formatter string `mapstructure:"formatter"` Version string `mapstructure:"version"` HeaderFrom string `mapstructure:"header-from"` Recursive recursive `mapstructure:"recursive"` Content string `mapstructure:"content"` Sections sections `mapstructure:"sections"` Output output `mapstructure:"output"` OutputValues outputvalues `mapstructure:"output-values"` Sort sort `mapstructure:"sort"` Settings settings `mapstructure:"settings"` ModuleRoot string }
Config represents all the available config options that can be accessed and passed through CLI.
func DefaultConfig ¶ added in v0.16.0
func DefaultConfig() *Config
DefaultConfig returns new instance of Config with default values set.
func NewConfig ¶ added in v0.16.0
func NewConfig() *Config
NewConfig returns neew instancee of Config with empty values.
func ReadConfig ¶ added in v0.16.0
ReadConfig reads config file in `rootDir` with given `filename` and returns instance of Config. It returns error if config file not found or there is a problem with unmarshalling.