Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateMikrotikResource(resourceName, commandBasePath string, ...) error
- func GenerateMikrotikResourceTest(resourceName string, s *Struct, w io.Writer) error
- func GenerateResource(s *Struct, w io.Writer) error
- func GenerateResourceTest(s *Struct, w io.Writer) error
- func SourceFormatHook(p []byte) ([]byte, error)
- type Field
- type SourceWriteHookFunc
- type Struct
- type Type
Constants ¶
View Source
const ( // List of declaration identifiers from ast package while parsing the source code AstVarTypeString = "string" AstVarTypeInt = "int" AstVarTypeBool = "bool" )
Variables ¶
View Source
var ( // Handle custom types from the client package AstVarTypeMikrotikList = reflect.TypeOf(types.MikrotikList{}).Name() AstVarTypeMikrotikIntList = reflect.TypeOf(types.MikrotikIntList{}).Name() AstVarTypeMikrotikDuration = reflect.TypeOf(types.MikrotikDuration(0)).Name() )
Functions ¶
func GenerateMikrotikResource ¶ added in v0.13.0
func GenerateMikrotikResource(resourceName, commandBasePath string, consoleCommandDefinition consoleinspected.ConsoleItem, w io.Writer) error
func GenerateMikrotikResourceTest ¶ added in v0.16.0
func GenerateResource ¶
GenerateResource generates Terraform resource and writes it to specified output
func GenerateResourceTest ¶ added in v0.16.0
GenerateResourceTest generates Terraform resource acceptance test and writes it to specified output
func SourceFormatHook ¶
SourceFormatHook formats code using Go's formatter
Types ¶
type Field ¶
type Field struct { // OriginalName is an original field name without chnages. OriginalName string // Name is a field name defined by struct tag. Name string // Required marks field as `required` in Terraform definition. Required bool // Optional marks field as `optional` in Terraform definition. Optional bool // Computed marks field as `computed` in Terraform definition. Computed bool // Type holds a field type. Type string // ElemType holds an element type if field type is List or Set ElemType string }
Field holds information about particular field in parsed struct.
type SourceWriteHookFunc ¶
SourceWriteHookFunc defines a hook func to mutate source before writing to destination
type Struct ¶
type Struct struct { // Name is a of parsed struct. Name string // MikrotikIDField is a field name which holds MikroTik resource ID. MikrotikIDField string // TerraformIDField holds a field name which will be used as Terraform resource ID. TerraformIDField string // DeleteField holds a field name to use when deleting resource on MikroTik system. DeleteField string // Fields is a collection of field definitions in the parsed struct. Fields []*Field }
Struct holds information about parsed struct.
type Type ¶
type Type interface { // Type returns a type name as string. // It must be stable for the same type. Name() string // Is checks whether two types are the same. Is(Type) bool }
Type represents Terraform field type to use for particular MikroTik field.
var ( StringType Type = basetype{/* contains filtered or unexported fields */} Int64Type Type = basetype{/* contains filtered or unexported fields */} ListType Type = basetype{/* contains filtered or unexported fields */} SetType Type = basetype{/* contains filtered or unexported fields */} BoolType Type = basetype{/* contains filtered or unexported fields */} StringSliceType Type = basetype{/* contains filtered or unexported fields */} IntSliceType Type = basetype{/* contains filtered or unexported fields */} UnknownType Type = basetype{/* contains filtered or unexported fields */} )
Click to show internal directories.
Click to hide internal directories.