parser

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParseFailure = errors.New("parse failure error")

ErrParseFailure is returned by parser.Parse when the input string is unable to be parsed.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Key           *string `parser:"@(Ident { \".\" | \"#\" | \"%\" | \"~\" | \"/\" | \"-\" | Ident | Float }) \":\""`
	Before        *string `parser:"((@String \"=\" \">\""`
	After         *string `parser:"  (@String"`
	AfterComputed *string `parser:" 	| @(\"<\" Ident \">\")))"`
	Value         *string `parser:" | @String"`
	Computed      *string `parser:" | @(\"<\" Ident \">\"))"`
	NewResource   bool    `parser:"{ @(\"(\" \"forces\" \"new\" \"resource\" \")\") }"`
	// contains filtered or unexported fields
}

The Attribute struct is responsible for parsing the attributes of each resource displayed by Terraform plan output.

Examples:

`id:              <computed>`
`policy_arn:      "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"``
`allow_overwrite: "" => "true"`
type Header struct {
	Change      *string `parser:"@(\"-\" \"/\" \"+\" | \"<\" \"=\" | \"+\" | \"-\" | \"~\")"`
	Name        *string `parser:"@(Ident { (\".\" | \"-\") (Ident | Int)+ | \"[\" Int \"]\" })"`
	Taint       bool    `parser:"{ @(\"(\" \"tainted\" \")\") }"`
	NewResource bool    `parser:"{ @(\"(\" \"new\" \"resource\" \"required\" \")\") }"`
	// contains filtered or unexported fields
}

The Header struct is responsible for parsing the header of each resource displayed by Terraform plan output.

Examples:

`+ aws_route53_record.record`
`-/+ module.module_name (new resource required)`

type Metadata

type Metadata struct {
	Add     int `parser:"@Int \"to\" \"add\" \",\""`
	Change  int `parser:"@Int \"to\" \"change\" \",\" "`
	Destroy int `parser:"@Int \"to\" \"destroy\" \".\" "`
	// contains filtered or unexported fields
}

The Metadata struct is responsible for parsing the plan metadata that displays the summary statistics from the Terraform plan output.

Example:

`Plan: 2 to add, 0 to change, 0 to destroy.`

type Plan

type Plan struct {
	Warnings *[]string

	Resources []*Resource `parser:"{@@}"`

	Metadata *Metadata `parser:"{@@}"`

	NoChanges bool
	// contains filtered or unexported fields
}

The Plan struct is the root of the AST grammar used to parse the Terraform plan output.

func Parse

func Parse(inputPlan string) (*Plan, error)

Parse takes in an Terraform plan output string and returns a parsed representation in the form of a Plan struct.

The ParseFailureErr error is returned the string is not able to be parsed properly by the grammar.

type Resource

type Resource struct {
	Header     *Header      `parser:"@@"`
	Attributes []*Attribute `parser:"{ @@ }"`
	// contains filtered or unexported fields
}

The Resource struct is responsible for parsing each resource group that is displayed by the Terraform plan output. A resource comprises of a single Header and as many optional Attributes.

type SceneryDefinition

type SceneryDefinition struct{}

SceneryDefinition is a copy of participles default Definition lexer with the modification that new lines are not ignored.

func (*SceneryDefinition) Lex

func (d *SceneryDefinition) Lex(r io.Reader) (lexer.Lexer, error)

Lex an io.Reader with text/scanner.Scanner.

This provides very fast lexing of source code compatible with Go tokens.

Note that this differs from text/scanner.Scanner in that string tokens will be unquoted and new lines are not ignored.

func (*SceneryDefinition) Symbols

func (d *SceneryDefinition) Symbols() map[string]rune

Symbols returns a map of the tokens type symbols

Jump to

Keyboard shortcuts

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