print

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package print provides a specific definition of a printer Format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopySections added in v0.13.0

func CopySections(settings *Settings, src *terraform.Module, dest *terraform.Module)

CopySections sets the sections that'll be printed

func ForEach added in v0.14.0

func ForEach(callback func(string, GeneratorCallback) error) error

ForEach section executes GeneratorCallback to render the content for that section and create corresponding GeneratorFunc. If there is any error in the executing the template for the section ForEach function immediately returns it and exit.

Types

type Engine

type Engine interface {
	Generate(*terraform.Module) (*Generator, error)
}

Engine represents a format engine (e.g. json, table, yaml, ...)

type GenerateFunc added in v0.14.0

type GenerateFunc func(*Generator)

GenerateFunc configures Generator.

func WithContent added in v0.14.0

func WithContent(content string) GenerateFunc

WithContent specifies how the Generator should add content.

func WithFooter added in v0.14.0

func WithFooter(footer string) GenerateFunc

WithFooter specifies how the Generator should add Footer.

func WithHeader added in v0.14.0

func WithHeader(header string) GenerateFunc

WithHeader specifies how the Generator should add Header.

func WithInputs added in v0.14.0

func WithInputs(inputs string) GenerateFunc

WithInputs specifies how the Generator should add Inputs.

func WithModules added in v0.14.0

func WithModules(modules string) GenerateFunc

WithModules specifies how the Generator should add Modules.

func WithOutputs added in v0.14.0

func WithOutputs(outputs string) GenerateFunc

WithOutputs specifies how the Generator should add Outputs.

func WithProviders added in v0.14.0

func WithProviders(providers string) GenerateFunc

WithProviders specifies how the Generator should add Providers.

func WithRequirements added in v0.14.0

func WithRequirements(requirements string) GenerateFunc

WithRequirements specifies how the Generator should add Requirements.

func WithResources added in v0.14.0

func WithResources(resources string) GenerateFunc

WithResources specifies how the Generator should add Resources.

type Generator added in v0.14.0

type Generator struct {
	Header       string
	Footer       string
	Inputs       string
	Modules      string
	Outputs      string
	Providers    string
	Requirements string
	Resources    string
	// contains filtered or unexported fields
}

Generator represents all the sections that can be generated for a Terraform modules (e.g. header, footer, inputs, etc). All these sections are being generated individually and if no content template was passed they will be combined together with a predefined order.

On the other hand these sections can individually be used in content template to form a custom format (and order).

Note that the notion of custom content template will be ignored for incompatible formatters and custom plugins. Compatible formatters are:

- asciidoc document - asciidoc table - markdown document - markdown table

func NewGenerator added in v0.14.0

func NewGenerator(name string, fns ...GenerateFunc) *Generator

NewGenerator returns a Generator for specific formatter name and with provided sets of GeneratorFunc functions to build and add individual sections.

func (*Generator) ExecuteTemplate added in v0.14.0

func (g *Generator) ExecuteTemplate(contentTmpl string) (string, error)

ExecuteTemplate applies the template with Generator known items. If template is empty Generator.content is returned as is. If template is not empty this still returns Generator.content for incompatible formatters.

func (*Generator) Path added in v0.14.0

func (g *Generator) Path(root string)

Path of module's directory.

type GeneratorCallback added in v0.14.0

type GeneratorCallback func(string) GenerateFunc

GeneratorCallback renders a Terraform module and creates a GenerateFunc.

type Settings

type Settings struct {
	// EscapeCharacters escapes special characters (such as _ * in Markdown and > < in JSON)
	//
	// default: true
	// scope: Markdown
	EscapeCharacters bool

	// IndentLevel control the indentation of headers [available: 1, 2, 3, 4, 5]
	//
	// default: 2
	// scope: Asciidoc, Markdown
	IndentLevel int

	// OutputValues extract and show Output values from Terraform module output
	//
	// default: false
	// scope: Global
	OutputValues bool

	// ShowAnchor show html anchor
	//
	// default: true
	// scope: Asciidoc, Markdown
	ShowAnchor bool

	// ShowColor print "colorized" version of result in the terminal
	//
	// default: true
	// scope: Pretty
	ShowColor bool

	// ShowDatasources show the data sources on the "Resources" section
	//
	// default: true
	// scope: Global
	ShowDataSources bool

	// ShowDefault show "Default" column
	//
	// default: true
	// scope: Asciidoc, Markdown
	ShowDefault bool

	// ShowDescription show "Descriptions" as comment on variables
	//
	// default: false
	// scope: tfvars hcl
	ShowDescription bool

	// ShowFooter show "Footer" module information
	//
	// default: false
	// scope: Global
	ShowFooter bool

	// ShowHeader show "Header" module information
	//
	// default: true
	// scope: Global
	ShowHeader bool

	// ShowHTML use HTML tags (a, pre, br, ...)
	//
	// default: true
	// scope: Markdown
	ShowHTML bool

	// ShowInputs show "Inputs" information
	//
	// default: true
	// scope: Global
	ShowInputs bool

	// ShowModuleCalls show "ModuleCalls" information
	//
	// default: true
	// scope: Global
	ShowModuleCalls bool

	// ShowOutputs show "Outputs" information
	//
	// default: true
	// scope: Global
	ShowOutputs bool

	// ShowProviders show "Providers" information
	//
	// default: true
	// scope: Global
	ShowProviders bool

	// ShowRequired show "Required" column
	//
	// default: true
	// scope: Asciidoc, Markdown
	ShowRequired bool

	// ShowSensitivity show "Sensitive" column
	//
	// default: true
	// scope: Asciidoc, Markdown
	ShowSensitivity bool

	// ShowRequirements show "Requirements" section
	//
	// default: true
	// scope: Global
	ShowRequirements bool

	// ShowResources show "Resources" section
	//
	// default: true
	// scope: Global
	ShowResources bool

	// ShowType show "Type" column
	//
	// default: true
	// scope: Asciidoc, Markdown
	ShowType bool
}

Settings represents all settings.

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns new instance of Settings

func (*Settings) Convert

func (s *Settings) Convert() *printsdk.Settings

Convert internal Settings to its equivalent in plugin-sdk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL