Documentation
¶
Overview ¶
Package format provides different, out of the box supported, output format types.
Usage ¶
A specific format can be instantiated either with `format.New()` function or directly calling its function (e.g. `NewMarkdownTable`, etc)
config := print.DefaultConfig() config.Formatter = "markdown table" formatter, err := format.New(config) if err != nil { return err } err := formatter.Generate(tfmodule) if err != nil { return err } output, err := formatter.Render"") if err != nil { return err }
Note: if you don't intend to provide additional template for the generated content, or the target format doesn't provide templating (e.g. json, yaml, xml, or toml) you can use `Content()` function instead of `Render)`. Note that `Content()` returns all the sections combined with predefined order.
output := formatter.Content()
Supported formats are:
• `NewAsciidocDocument` • `NewAsciidocTable` • `NewJSON` • `NewMarkdownDocument` • `NewMarkdownTable` • `NewPretty` • `NewTfvarsHCL` • `NewTfvarsJSON` • `NewTOML` • `NewXML` • `NewYAML`
Index ¶
- func PrintFencedAsciidocCodeBlock(code string, language string) (string, bool)
- func PrintFencedCodeBlock(code string, language string) (string, bool)
- type Type
- func New(config *print.Config) (Type, error)
- func NewAsciidocDocument(config *print.Config) Type
- func NewAsciidocTable(config *print.Config) Type
- func NewJSON(config *print.Config) Type
- func NewMarkdownDocument(config *print.Config) Type
- func NewMarkdownTable(config *print.Config) Type
- func NewPretty(config *print.Config) Type
- func NewTOML(config *print.Config) Type
- func NewTfvarsHCL(config *print.Config) Type
- func NewTfvarsJSON(config *print.Config) Type
- func NewXML(config *print.Config) Type
- func NewYAML(config *print.Config) Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintFencedAsciidocCodeBlock ¶
PrintFencedAsciidocCodeBlock prints codes in fences, it automatically detects if the input 'code' contains '\n' it will use multi line fence, otherwise it wraps the 'code' inside single-tick block. If the fenced is multi-line it also appens an extra '\n` at the end and returns true accordingly, otherwise returns false for non-carriage return.
func PrintFencedCodeBlock ¶
PrintFencedCodeBlock prints codes in fences, it automatically detects if the input 'code' contains '\n' it will use multi line fence, otherwise it wraps the 'code' inside single-tick block. If the fenced is multi-line it also appens an extra '\n` at the end and returns true accordingly, otherwise returns false for non-carriage return.
Types ¶
type Type ¶
type Type interface { Generate(*terraform.Module) error // generate the Terraform module Content() string // all the sections combined based on the underlying format Header() string // header section based on the underlying format Inputs() string // inputs section based on the underlying format Modules() string // modules section based on the underlying format Outputs() string // outputs section based on the underlying format Providers() string // providers section based on the underlying format Requirements() string // requirements section based on the underlying format Resources() string // resources section based on the underlying format Render(tmpl string) (string, error) }
Type represents an output format type (e.g. json, markdown table, yaml, etc).
func New ¶
New initializes and returns the concrete implementation of format.Engine based on the provided 'name', for example for name of 'json' it will return '*format.JSON' through 'format.NewJSON' function.
func NewAsciidocDocument ¶
NewAsciidocDocument returns new instance of Asciidoc Document.
func NewAsciidocTable ¶
NewAsciidocTable returns new instance of Asciidoc Table.
func NewMarkdownDocument ¶
NewMarkdownDocument returns new instance of Markdown Document.
func NewMarkdownTable ¶
NewMarkdownTable returns new instance of Markdown Table.
func NewTfvarsHCL ¶
NewTfvarsHCL returns new instance of TfvarsHCL.
func NewTfvarsJSON ¶
NewTfvarsJSON returns new instance of TfvarsJSON.