terraform

package
v0.0.0-...-6ba9fcd Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(t *Terraform, outputDir string) (*Client, error)

func (*Client) Format

func (c *Client) Format() error

type General

type General struct {
	Organisation     string `yaml:"organisation,omitempty" json:"organisation,omitempty"`
	Workspace        string `yaml:"workspace,omitempty" json:"workspace,omitempty"`
	TerraformVersion string `yaml:"terraformVersion" json:"terraformVersion" validate:"required"`
	Region           string `yaml:"region" json:"region" validate:"required"`
	ProjectID        string `yaml:"projectId" json:"projectId" validate:"required"`
}

General contains general information about the terraform project. This information is used to generate the main.tf file. Organisation and Workspace are optional. If they are not provided, it will not connect to a remote state. TerraformVersion, Region and ProjectID are required.

type Module

type Module struct {
	Name            string `yaml:"name" json:"name" validate:"required"`
	GitOrganisation string `yaml:"organisation" json:"organisation" validate:"required"`
	Description     string `yaml:"description,omitempty" json:"description,omitempty"`
	Version         string `yaml:"version" json:"version" validate:"required"`
}

Module contains information about the module. This information is used to generate the information across the module files. Name and Version are required. Description is optional.

type Service

type Service struct {
	Name        string   `yaml:"name" json:"name" validate:"required"`
	Description string   `yaml:"description,omitempty" json:"description,omitempty"`
	Modules     []Module `yaml:"modules,omitempty" json:"modules,omitempty"`
}

Service contains information about the service. This information is used to generate the information across the files. Name is required. Description and Modules is optional.

type Terraform

type Terraform struct {
	General General `yaml:"general" json:"general"`
	Service Service `yaml:"service" json:"service"`
}

Terraform is the struct that will be used to parse the terraform file. Should contain all the information needed to generate terraform code.

func Parse

func Parse(fileType string, data []byte) (*Terraform, error)

Parse will parse data into a Terraform struct. It will return an error if the file type is not supported. Currently only json and yaml is supported. It will also return an error if the data is not valid. The data is not valid if it does not match the Terraform struct validation rules.

func (*Terraform) Generate

func (t *Terraform) Generate(outputDir string) error

Generate will generate terraform files from the Terraform struct. It will return an error if the template cannot be read, parsed or executed. It will also return an error if the file cannot be created. The file will be created in the outputDir. Defaults to the current directory. The file name will be main.tf for the main file and <module_name>.tf for each module.

Jump to

Keyboard shortcuts

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