format
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
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 ordirectly 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 generatedcontent, or the target format doesn't provide templating (e.g. json, yaml,xml, or toml) you can use `Content()` function instead of `Render)`. Notethat `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¶
funcPrintFencedAsciidocCodeBlock¶
PrintFencedAsciidocCodeBlock prints codes in fences, it automatically detects ifthe input 'code' contains '\n' it will use multi line fence, otherwise itwraps the 'code' inside single-tick block.If the fenced is multi-line it also appens an extra '\n` at the end andreturns true accordingly, otherwise returns false for non-carriage return.
funcPrintFencedCodeBlock¶
PrintFencedCodeBlock prints codes in fences, it automatically detects ifthe input 'code' contains '\n' it will use multi line fence, otherwise itwraps the 'code' inside single-tick block.If the fenced is multi-line it also appens an extra '\n` at the end andreturns true accordingly, otherwise returns false for non-carriage return.
Types¶
typeType¶
type Type interface {Generate(*terraform.Module)error// generate the Terraform moduleContent()string// all the sections combined based on the underlying formatHeader()string// header section based on the underlying formatFooter()string// footer section based on the underlying formatInputs()string// inputs section based on the underlying formatModules()string// modules section based on the underlying formatOutputs()string// outputs section based on the underlying formatProviders()string// providers section based on the underlying formatRequirements()string// requirements section based on the underlying formatResources()string// resources section based on the underlying formatRender(tmplstring) (string,error)}
Type represents an output format type (e.g. json, markdown table, yaml, etc).
funcNew¶
New initializes and returns the concrete implementation offormat.Engine based on the provided 'name', for example for nameof 'json' it will return '*format.JSON' through 'format.NewJSON'function.
funcNewAsciidocDocument¶
NewAsciidocDocument returns new instance of Asciidoc Document.
funcNewAsciidocTable¶
NewAsciidocTable returns new instance of Asciidoc Table.
funcNewMarkdownDocument¶
NewMarkdownDocument returns new instance of Markdown Document.
funcNewMarkdownTable¶
NewMarkdownTable returns new instance of Markdown Table.
funcNewTfvarsHCL¶
NewTfvarsHCL returns new instance of TfvarsHCL.
funcNewTfvarsJSON¶
NewTfvarsJSON returns new instance of TfvarsJSON.