gcloudtf

package module
v0.0.0-...-d4fae17 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package gcloudtf handles parsing Terraform files to extract structured information out of it, to support a few tools to speed up the DeployStack authoring process

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Name string            `json:"name" yaml:"name"`
	Text string            `json:"text" yaml:"text"`
	Kind string            `json:"kind" yaml:"kind"`
	Type string            `json:"type" yaml:"type"`
	Attr map[string]string `json:"attr" yaml:"attr"`
	// contains filtered or unexported fields
}

Block represents one of several kinds of Terraform constructs: resources, variables, module

func NewModuleBlock

func NewModuleBlock(t *tfconfig.ModuleCall) (Block, error)

NewModuleBlock converts a parsed Terraform Module to a Block

func NewResourceBlock

func NewResourceBlock(t *tfconfig.Resource) (Block, error)

NewResourceBlock converts a parsed Terraform Resource to a Block

func NewVariableBlock

func NewVariableBlock(t *tfconfig.Variable) (Block, error)

NewVariableBlock converts a parsed Terraform Variable to a Block

func (Block) IsModule

func (b Block) IsModule() bool

IsModule returns true if block is a Terraform module

func (Block) IsResource

func (b Block) IsResource() bool

IsResource returns true if block is a Terraform resource

func (Block) IsVariable

func (b Block) IsVariable() bool

IsVariable returns true if block is a Terraform variable

func (Block) NoDefault

func (b Block) NoDefault() bool

NoDefault returns true if block does not contain a default value

type Blocks

type Blocks []Block

Blocks is a slice of type Block

func Extract

func Extract(path string) (*Blocks, error)

Extract points to a path that includes Terraform files and extracts all of the information out of it for use with DeployStack Tools

func NewBlocks

func NewBlocks(mod *tfconfig.Module) (*Blocks, error)

NewBlocks converts the results from a Terraform parse operation to Blocks.

type GCPResource

type GCPResource struct {
	Label      string     `json:"label" yaml:"label"`
	Product    string     `json:"product" yaml:"product"`
	APICalls   []string   `json:"api_calls" yaml:"api_calls"`
	TestConfig TestConfig `json:"test_config" yaml:"test_config"`
	AliasOf    []string   `json:"aliasof" yaml:"aliasof"`
}

GCPResource is a Terraform resource that matches up with a GCP product. This is used to automate the generation of tests and documentation

type GCPResources

type GCPResources map[string]GCPResource

GCPResources is a collection of GCPResource

func NewGCPResources

func NewGCPResources(path string) (GCPResources, error)

NewGCPResources reads in a yaml file as a config

func (GCPResources) GetProduct

func (g GCPResources) GetProduct(key string) string

GetProduct returns the prouct name assoicated with the terraform resource

type List

type List []string

List is a slice of strings that we add extra functionality to

func (List) Matches

func (l List) Matches(s string) bool

Matches determines if a given string is an entry in the list.

type Repos

type Repos []string

Repos is a slice of strings containing github urls

func NewRepos

func NewRepos(path string) (Repos, error)

NewRepos retrieves the list of repos from a ymal file.

type TestConfig

type TestConfig struct {
	TestType    string `json:"test_type" yaml:"test_type"`
	TestCommand string `json:"test_command" yaml:"test_command"`
	Suffix      string `json:"suffix" yaml:"suffix"`
	Region      bool   `json:"region" yaml:"region"`
	Zone        bool   `json:"zone" yaml:"zone"`
	LabelField  string `json:"label_field" yaml:"label_field"`
	Expected    string `json:"expected" yaml:"expected"`
	Todo        string `json:"todo" yaml:"todo"`
}

TestConfig is the information needed to automate test creation.

func (TestConfig) HasTest

func (t TestConfig) HasTest() bool

HasTest returns true if test config actually has a test in it.

func (TestConfig) HasTodo

func (t TestConfig) HasTodo() bool

HasTodo returns true if test config actually has a todo in it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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