tfschema

package
v0.0.0-...-e443136 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

package tfschema provides helpers for working with Terraform's helper/schema.Schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	GetMetadata() interface{}
}
type NetworkInterfaceLink struct {
	SystemID       string
	InterfaceID    int
	SubnetID       int
	Mode           string
	IPAddress      net.IP
	Force          bool
	DefaultGateway net.IP
}

NetworkInterfaceLink represents a maas_interface_link

func NewNetworkInterfaceLink(d *schema.ResourceData) *NetworkInterfaceLink

NewNetworkInterfaceLink creates an NetworkInterfaceLink from the Terraform state.

func (*NetworkInterfaceLink) GetID

func (i *NetworkInterfaceLink) GetID() (string, error)

GetID returns "<SystemID>:<InterfaceID>:<SubnetID>" to be used as the Terraform resource ID.

func (*NetworkInterfaceLink) Params

Params returns a type that can be used to create and delete a MaaS Interface.

func (*NetworkInterfaceLink) UpdateResource

func (i *NetworkInterfaceLink) UpdateResource(d *schema.ResourceData) (err error)

UpdateResource updates the Terraform state to reflect the state of the struct.

type NetworkInterfacePhysical

type NetworkInterfacePhysical struct {
	InterfaceID int
	SystemID    string
	Name        string
	MACAddress  string
	Tags        []string
	VLAN        string
	MTU         int
	AcceptRA    bool
	Autoconf    bool
}

NetworkInterfacePhysical represents a maas_interface_physical

func NewNetworkInterfacePhysical

func NewNetworkInterfacePhysical(d *schema.ResourceData) *NetworkInterfacePhysical

NewNetworkInterfacePhysical creates an NetworkInterfacePhysical from the Terraform state.

func (*NetworkInterfacePhysical) GetID

func (i *NetworkInterfacePhysical) GetID() (string, error)

GetID returns "<SystemID>:<InterfaceID>" to be used as the Terraform resource ID.

func (*NetworkInterfacePhysical) Params

Params returns a type that can be used to create and update a MaaS Interface.

func (*NetworkInterfacePhysical) UpdateResource

func (i *NetworkInterfacePhysical) UpdateResource(d *schema.ResourceData) (err error)

UpdateResource updates the Terraform state to reflect the state of the struct.

type Resource

type Resource map[string]*Schema

Resource wraps a Terraform resource's Schema. It provides functionality for parsing a struct{} into a map[string]*Schema for use in Terraform resources and providers.

func NewResource

func NewResource(typ Endpoint) (Resource, error)

NewResource transforms a struct{} into a map for a TF schema.Resource. The first return value of this function is the Schema property of the resource, and the function can handle recursion (ie nested structs). TODO: Make this type handle recursion so it can handle a struct within a struct

func (Resource) TFResource

func (s Resource) TFResource() map[string]*schema.Schema

TFResource returns a type that is compatible with Terraform's schema.Resource

type Schema

type Schema struct {
	schema.Schema
	BoolTags   map[string]*bool
	StringTags map[string]*string
	FuncTags   map[string]interface{}
}

Schema wraps a Terraform Schema with additional functionality for parsing struct fields. Use this type to convert a struct field into a Terraform schema, using struct tags to handle the various schema attributes (eg required, computed).

func NewSchema

func NewSchema(f *reflect.StructField) *Schema

func (*Schema) Parse

func (s *Schema) Parse(f *reflect.StructField) (err error)

Parse introspects the struct field to populate the helper.Schema. It will find the Terraform ValueType of the field, search for any struct tags, and set the default value, if there is one.

func (*Schema) ParseTags

func (s *Schema) ParseTags(tags reflect.StructTag) error

ParseTags sets values in the schema based on the values of struct tags.

func (*Schema) SetDefault

func (s *Schema) SetDefault(val string) (err error)

SetDefault sets the schema's Default value.

func (*Schema) SetValueType

func (s *Schema) SetValueType(t reflect.Kind) error

SetValueType sets the schema's Terraform ValueType

func (*Schema) TFSchema

func (s *Schema) TFSchema() *schema.Schema

TFSchema returns the underlying Terraform schema

Jump to

Keyboard shortcuts

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