terraform

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package terraform is the representation of a Terraform Module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Name        string
	Type        string
	Description string
	Default     interface{}
	Required    bool
	Position    Position
}

Input represents a Terraform input.

type Module

type Module interface {
	// HasHeader indicates if the module has header.
	HasHeader() bool

	// HasInputs indicates if the module has inputs.
	HasInputs() bool

	// HasModuleCalls indicates if the module has inputs.
	HasModuleCalls() bool

	// HasOutputs indicates if the module has outputs.
	HasOutputs() bool

	// HasProviders indicates if the module has providers.
	HasProviders() bool

	// HasRequirements indicates if the module has requirements.
	HasRequirements() bool

	// HasResources indicates if the module has resources.
	HasResources() bool
}

Module represents a Terraform module. It consists of

- Header ('header' json key): Module header found in shape of multi line comments at the beginning of 'main.tf' - Inputs ('inputs' json key): List of input 'variables' extracted from the Terraform module .tf files - ModuleCalls ('modules' json key): List of 'modules' extracted from the Terraform module .tf files - Outputs ('outputs' json key): List of 'outputs' extracted from Terraform module .tf files - Providers ('providers' json key): List of 'providers' extracted from resources used in Terraform module - Requirements ('requirements' json key): List of 'requirements' extracted from the Terraform module .tf files - Resources ('resources' json key): List of 'resources' extracted from the Terraform module .tf files

func NewModule

func NewModule(fns ...SectionFn) Module

NewModule creates a new module and adds underlying section data into it.

type ModuleCall

type ModuleCall struct {
	Name    string
	Source  string
	Version string
}

ModuleCall represents a submodule called by Terraform module.

type Output

type Output struct {
	Name        string
	Description string
	Value       interface{}
	Sensitive   bool
	Position    Position
	ShowValue   bool
}

Output represents a Terraform output.

type Position

type Position struct {
	Filename string
	Line     int
}

Position represents position of Terraform input or output in a file.

type Provider

type Provider struct {
	Name     string
	Alias    string
	Version  string
	Position Position
}

Provider represents a Terraform output.

type Requirement

type Requirement struct {
	Name    string
	Version string
}

Requirement represents a requirement for Terraform module.

type Resource

type Resource struct {
	Type           string
	ProviderName   string
	ProviderSource string
	Mode           string
	Version        string
}

Resource represents a managed or data type that is created by the module

type SectionFn

type SectionFn func(*module)

SectionFn is a callback function to add section data into module.

func WithHeader

func WithHeader(h string) SectionFn

WithHeader adds header to Module.

func WithInputs

func WithInputs(i []*Input) SectionFn

WithInputs adds inputs to Module.

func WithModuleCalls

func WithModuleCalls(mc []*ModuleCall) SectionFn

WithModuleCalls adds Modulecalls to Module.

func WithOptionalInputs

func WithOptionalInputs(oi []*Input) SectionFn

WithOptionalInputs adds optional inputs to Module.

func WithOutputs

func WithOutputs(o []*Output) SectionFn

WithOutputs adds outputs to Module.

func WithProviders

func WithProviders(p []*Provider) SectionFn

WithProviders adds providers to Module.

func WithRequiredInputs

func WithRequiredInputs(ri []*Input) SectionFn

WithRequiredInputs adds required inputs to Module.

func WithRequirements

func WithRequirements(r []*Requirement) SectionFn

WithRequirements adds requirements to Module.

func WithResources

func WithResources(r []*Resource) SectionFn

WithResources adds resources to Module.

Jump to

Keyboard shortcuts

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