terraform

package
v0.0.0-...-8006d43 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(binDir, dir string) error

func Destroy

func Destroy(binDir, dir string) error

func ExtractModule

func ExtractModule(module string, destdir string) error

ExtractModule extract the terraform module embedded into the binary to a directory

func Init

func Init(binDir, dir string) error

Init runs terraform init in the target directory, the main.tf configuration file must exist in the directory

func InstallLibvirtProvider

func InstallLibvirtProvider(destdir string, version string) error

func InstallTerraform

func InstallTerraform(destdir string, version string) error

Install downloads, checks and install terraform into the target directory

func LinkLibvirtProvider

func LinkLibvirtProvider(srcDir string, version string) error

func ParseVariableDefault

func ParseVariableDefault(v Variable, val interface{}) error

func ShowModuleVariable

func ShowModuleVariable(val interface{})

func WriteModuleConfig

func WriteModuleConfig(dst io.Writer, conf Config) error

Types

type Config

type Config struct {
	Provider Provider `hcl:"provider,block"`
	Module   Module   `hcl:"module,block"`
	Meta     Meta     `hcl:"terraform,block"`
}

func NewConfiguration

func NewConfiguration(modulePath string, domain string, netCIDR string) (Config, error)

func ParseModuleConfig

func ParseModuleConfig(path string) (Config, error)

type Machine

type Machine struct {
	IPAddress    string `cty:"ip"`      // "10.10.0.3"
	Distrib      string `cty:"distrib"` // "debian10"
	Vcpus        int    `cty:"vcpu"`
	Memory       int    `cty:"memory"`
	DataDiskSize int    `cty:"data_size"`
	Iface        string `cty:"iface"`
}

Since Machine is an object inside terraform, we need to use tags of the lower level "github.com/zclconf/go-cty/cty" module used by hcl to load it.

type Meta

type Meta struct {
	TfVersion    string      `hcl:"required_version"`
	ReqProviders ReqProvider `hcl:"required_providers,block"`
}

type Module

type Module struct {
	Name        string             `hcl:"name,label"`
	Source      string             `hcl:"source"`
	StoragePool string             `hcl:"storage_pool,optional"`
	Username    string             `hcl:"user_name,optional"`
	SshPubKey   string             `hcl:"user_pubkey,optional"`
	Domain      string             `hcl:"dns_domain"`
	NetworkName string             `hcl:"net_name,optional"`
	NetworkCIDR string             `hcl:"net_cidr"`
	Machines    map[string]Machine `hcl:"vms"` // hostname -> Machine
}

type Provider

type Provider struct {
	Name string `hcl:"name,label"`
	Uri  string `hcl:"uri"`
}

type ProviderInfo

type ProviderInfo struct {
	Source  string `cty:"source"`
	Version string `cty:"version"`
}

type ReqProvider

type ReqProvider struct {
	Libvirt ProviderInfo `hcl:"libvirt,optional"`
}

type VarMachines

type VarMachines struct {
	Value map[string]Machine `hcl:"default"`
}

type VarString

type VarString struct {
	Value string `hcl:"default"`
}

type Variable

type Variable struct {
	Name        string   `hcl:"name,label"`
	Description string   `hcl:"description"`
	Data        hcl.Body `hcl:",remain"`
}

type Variables

type Variables struct {
	Variables []Variable `hcl:"variable,block"`
}

func ParseModuleVariables

func ParseModuleVariables(path string) (Variables, error)

Jump to

Keyboard shortcuts

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