terraform

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPlanTemplate is a default template for terraform plan
	DefaultPlanTemplate = `` /* 295-byte string literal not displayed */

	// DefaultApplyTemplate is a default template for terraform apply
	DefaultApplyTemplate = `` /* 281-byte string literal not displayed */

	// DefaultPlanParseErrorTemplate is a default template for terraform plan parse error
	DefaultPlanParseErrorTemplate = `` /* 190-byte string literal not displayed */

	// DefaultApplyParseErrorTemplate  is a default template for terraform apply parse error
	DefaultApplyParseErrorTemplate = `` /* 233-byte string literal not displayed */

)
View Source
const (
	// ExitPass is status code zero
	ExitPass int = iota

	// ExitFail is status code non-zero
	ExitFail
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyParser

type ApplyParser struct {
	Pass *regexp.Regexp
	Fail *regexp.Regexp
}

ApplyParser is a parser for terraform apply

func NewApplyParser

func NewApplyParser() *ApplyParser

NewApplyParser is ApplyParser initialized with its Regexp

func (*ApplyParser) Parse

func (p *ApplyParser) Parse(body string) ParseResult

Parse returns ParseResult related with terraform apply

type CommonTemplate

type CommonTemplate struct {
	Result                 string
	ChangedResult          string
	ChangeOutsideTerraform string
	Warning                string
	Link                   string
	UseRawOutput           bool
	HasDestroy             bool
	Vars                   map[string]string
	Templates              map[string]string
	Stdout                 string
	Stderr                 string
	CombinedOutput         string
	ExitCode               int
	ErrorMessages          []string
	CreatedResources       []string
	UpdatedResources       []string
	DeletedResources       []string
	ReplacedResources      []string
}

CommonTemplate represents template entities

type DefaultParser

type DefaultParser struct{}

DefaultParser is a parser for terraform commands

func NewDefaultParser

func NewDefaultParser() *DefaultParser

NewDefaultParser is DefaultParser initializer

func (*DefaultParser) Parse

func (p *DefaultParser) Parse(body string) ParseResult

Parse returns ParseResult related with terraform commands

type ParseResult

type ParseResult struct {
	Result             string
	OutsideTerraform   string
	ChangedResult      string
	Warning            string
	HasAddOrUpdateOnly bool
	HasDestroy         bool
	HasNoChanges       bool
	HasPlanError       bool
	HasParseError      bool
	ExitCode           int
	Error              error
	CreatedResources   []string
	UpdatedResources   []string
	DeletedResources   []string
	ReplacedResources  []string
}

ParseResult represents the result of parsed terraform execution

type Parser

type Parser interface {
	Parse(body string) ParseResult
}

Parser is an interface for parsing terraform execution result

type PlanParser

type PlanParser struct {
	Pass         *regexp.Regexp
	Fail         *regexp.Regexp
	HasDestroy   *regexp.Regexp
	HasNoChanges *regexp.Regexp
	Create       *regexp.Regexp
	Update       *regexp.Regexp
	Delete       *regexp.Regexp
	Replace      *regexp.Regexp
}

PlanParser is a parser for terraform plan

func NewPlanParser

func NewPlanParser() *PlanParser

NewPlanParser is PlanParser initialized with its Regexp

func (*PlanParser) Parse

func (p *PlanParser) Parse(body string) ParseResult

Parse returns ParseResult related with terraform plan

type Template

type Template struct {
	Template string
	CommonTemplate
}

Template is a default template for terraform commands

func NewApplyParseErrorTemplate

func NewApplyParseErrorTemplate(template string) *Template

func NewApplyTemplate

func NewApplyTemplate(template string) *Template

NewApplyTemplate is ApplyTemplate initializer

func NewPlanParseErrorTemplate

func NewPlanParseErrorTemplate(template string) *Template

func NewPlanTemplate

func NewPlanTemplate(template string) *Template

NewPlanTemplate is PlanTemplate initializer

func (*Template) Execute

func (t *Template) Execute() (string, error)

Execute binds the execution result of terraform command into template

func (*Template) IsSamePlan added in v0.1.3

func (t *Template) IsSamePlan(executedStr string) bool

func (*Template) SetValue

func (t *Template) SetValue(ct CommonTemplate)

SetValue sets template entities to CommonTemplate

Jump to

Keyboard shortcuts

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