types

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NameGenerator = func() string {
	t := time.Now()
	entropy := ulid.Monotonic(rand.New(rand.NewSource(t.UnixNano())), 0)

	return fmt.Sprintf("id_%s", ulid.MustNew(ulid.Timestamp(t), entropy))
}

NameGenerator function used to generate Resource names, by default is based on a ULID generator.

Functions

func BuiltinBackend

func BuiltinBackend() starlark.Value

func BuiltinFunctionComputed

func BuiltinFunctionComputed() starlark.Value

func BuiltinHCL

func BuiltinHCL() starlark.Value

func BuiltinProvider

func BuiltinProvider(pm *terraform.PluginManager) starlark.Value

func BuiltinProvisioner

func BuiltinProvisioner(pm *terraform.PluginManager) starlark.Value

Types

type Backend

type Backend struct {
	*Resource
}

func MakeBackend

func MakeBackend(name string) (*Backend, error)

func (*Backend) ToHCL

func (s *Backend) ToHCL(b *hclwrite.Body)

type Computed

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

func NewComputed

func NewComputed(r *Resource, t cty.Type, name string) *Computed

func NewComputedWithPath

func NewComputedWithPath(r *Resource, t cty.Type, name, path string) *Computed

func (*Computed) Attr

func (c *Computed) Attr(name string) (starlark.Value, error)

func (*Computed) AttrNames

func (c *Computed) AttrNames() []string

func (*Computed) Index

func (c *Computed) Index(i int) starlark.Value

func (*Computed) InnerType

func (c *Computed) InnerType() *Type

func (*Computed) Len

func (c *Computed) Len() int

func (*Computed) Type

func (*Computed) Type() string

type HCLCompatible

type HCLCompatible interface {
	ToHCL(b *hclwrite.Body)
}

type Kind

type Kind string

Kind describes what kind of resource is represented by a Resource isntance.

const (
	ProviderKind   Kind = "provider"
	ResourceKind   Kind = "resource"
	DataSourceKind Kind = "data"
	NestedKind     Kind = "nested"
	BackendKind    Kind = "backend"
)

type MapSchema

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

func NewMapSchema

func NewMapSchema(p *Provider, prefix string, k Kind, schemas map[string]providers.Schema) *MapSchema

func (*MapSchema) Attr

func (m *MapSchema) Attr(name string) (starlark.Value, error)

func (*MapSchema) AttrNames

func (s *MapSchema) AttrNames() []string

func (*MapSchema) Freeze

func (m *MapSchema) Freeze()

func (*MapSchema) Hash

func (m *MapSchema) Hash() (uint32, error)

func (*MapSchema) Name

func (m *MapSchema) Name() string

func (*MapSchema) String

func (m *MapSchema) String() string

func (*MapSchema) ToHCL

func (t *MapSchema) ToHCL(b *hclwrite.Body)

func (*MapSchema) Truth

func (m *MapSchema) Truth() starlark.Bool

func (*MapSchema) Type

func (m *MapSchema) Type() string

type NamedValue

type NamedValue struct {
	Name string
	*Value
}

NamedValue represents a Value with a given name.

type Provider

type Provider struct {
	*Resource
	// contains filtered or unexported fields
}

Provider represents a provider as a starlark.Value.

func MakeProvider

func MakeProvider(pm *terraform.PluginManager, name, version, alias string) (*Provider, error)

MakeProvider returns a new Provider instance from a given name version and alias.

func (*Provider) Attr

func (p *Provider) Attr(name string) (starlark.Value, error)

Attr honors the starlark.HasAttrs interface.

func (*Provider) AttrNames

func (p *Provider) AttrNames() []string

AttrNames honors the starlark.HasAttrs interface.

func (*Provider) CompareSameType

func (x *Provider) CompareSameType(op syntax.Token, y_ starlark.Value, depth int) (bool, error)

CompareSameType honors starlark.Comprable interface.

func (*Provider) String

func (p *Provider) String() string

func (*Provider) ToHCL

func (s *Provider) ToHCL(b *hclwrite.Body)

func (*Provider) Type

func (p *Provider) Type() string

Type honors the starlark.Value interface. It shadows p.Resource.Type.

type Provisioner

type Provisioner struct {
	*Resource
	// contains filtered or unexported fields
}

func MakeProvisioner

func MakeProvisioner(pm *terraform.PluginManager, name string) (*Provisioner, error)

func (*Provisioner) ToHCL

func (s *Provisioner) ToHCL(b *hclwrite.Body)

func (*Provisioner) Type

func (p *Provisioner) Type() string

Type honors the starlark.Value interface. It shadows p.Resource.Type.

type Resource

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

Resource represents a resource as a starlark.Value, it can be of four kinds, provider, resource, data source or a nested resource.

func MakeResource

func MakeResource(name, typ string, k Kind, b *configschema.Block, provider *Provider, parent *Resource) *Resource

MakeResource returns a new resource of the given kind, type based on the given configschema.Block.

func (*Resource) Attr

func (r *Resource) Attr(name string) (starlark.Value, error)

Attr honors the starlark.HasAttrs interface.

func (*Resource) AttrNames

func (r *Resource) AttrNames() []string

AttrNames honors the starlark.HasAttrs interface.

func (*Resource) CompareSameType

func (x *Resource) CompareSameType(op syntax.Token, y_ starlark.Value, depth int) (bool, error)

CompareSameType honors starlark.Comprable interface.

func (*Resource) Freeze

func (r *Resource) Freeze()

Freeze honors the starlark.Value interface.

func (*Resource) Hash

func (r *Resource) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (*Resource) LoadDict

func (r *Resource) LoadDict(d *starlark.Dict) error

LoadDict loads a dict in the resource.

func (*Resource) Name

func (r *Resource) Name() string

Name returns the resource name based on the hash.

func (*Resource) SetField

func (r *Resource) SetField(name string, v starlark.Value) error

SetField honors the starlark.HasSetField interface.

func (*Resource) String

func (r *Resource) String() string

String honors the starlark.Value interface.

func (*Resource) ToHCL

func (r *Resource) ToHCL(b *hclwrite.Body)

func (*Resource) Truth

func (r *Resource) Truth() starlark.Bool

Truth honors the starlark.Value interface.

func (*Resource) Type

func (r *Resource) Type() string

Type honors the starlark.Value interface.

type ResourceCollection

type ResourceCollection struct {
	*starlark.List
	// contains filtered or unexported fields
}

func NewResourceCollection

func NewResourceCollection(
	typ string, k Kind, block *configschema.Block, provider *Provider, parent *Resource,
) *ResourceCollection

func (*ResourceCollection) CallInternal

func (c *ResourceCollection) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

CallInternal honors the starlark.Callable interface.

func (*ResourceCollection) Freeze

func (c *ResourceCollection) Freeze()

Freeze honors the starlark.Value interface.

func (*ResourceCollection) Hash

func (c *ResourceCollection) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (*ResourceCollection) LoadList

func (c *ResourceCollection) LoadList(l *starlark.List) error

LoadList loads a list of dicts on the collection. It clears the collection.

func (*ResourceCollection) MakeResource

func (c *ResourceCollection) MakeResource(name string, dict *starlark.Dict) (*Resource, error)

MakeResource it makes a new resource and loads the dict on it.

func (*ResourceCollection) Name

func (c *ResourceCollection) Name() string

Name honors the starlark.Callable interface.

func (*ResourceCollection) String

func (c *ResourceCollection) String() string

String honors the starlark.Value interface.

func (*ResourceCollection) ToHCL

func (c *ResourceCollection) ToHCL(b *hclwrite.Body)

func (*ResourceCollection) Truth

func (c *ResourceCollection) Truth() starlark.Bool

Truth honors the starlark.Value interface.

func (*ResourceCollection) Type

func (c *ResourceCollection) Type() string

Type honors the starlark.Value interface.

type Type

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

Type is a helper to manipulate and transform starlark.Type and cty.Type

func MustTypeFromCty

func MustTypeFromCty(typ cty.Type) *Type

MustTypeFromCty returns a Type froma given cty.Type. Panics if error.

func MustTypeFromStarlark

func MustTypeFromStarlark(typ string) *Type

MustTypeFromStarlark returns a Type from a given starlark type string. Panics if error.

func NewTypeFromCty

func NewTypeFromCty(typ cty.Type) (*Type, error)

NewTypeFromCty returns a Type froma given cty.Type.

func NewTypeFromStarlark

func NewTypeFromStarlark(typ string) (*Type, error)

NewTypeFromStarlark returns a Type from a given starlark type string.

func (*Type) Cty

func (t *Type) Cty() cty.Type

Cty returns the type as cty.Type.

func (*Type) Starlark

func (t *Type) Starlark() string

Starlark returns the type as starlark type string.

func (*Type) Validate

func (t *Type) Validate(v starlark.Value) error

Validate validates a value againts the type.

type Value

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

Value is helper to manipulate and transform starlark.Value to go types and cty.Value.

func MustValue

func MustValue(v starlark.Value) *Value

MustValue returns a Value from a starlark.Value, it panics if error.

func NewValue

func NewValue(v starlark.Value) (*Value, error)

NewValue returns a Value from a starlark.Value.

func (*Value) Cty

func (v *Value) Cty() cty.Value

Cty returns the cty.Value.

func (*Value) Hash

func (v *Value) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (*Value) Interface

func (v *Value) Interface() interface{}

Interface returns the value as a Go value.

func (*Value) Starlark

func (v *Value) Starlark() starlark.Value

Starlark returns the starlark.Value.

func (*Value) Type

func (v *Value) Type() *Type

Type returns the Type of the value.

type Values

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

Values is a list of NamedValues.

func NewValues

func NewValues() *Values

NewValues return a new instance of Values

func (Values) ForEach

func (a Values) ForEach(cb func(*NamedValue) error) error

ForEach call cb for each value on Values, it stop the iteration an error is returned.

func (Values) Get

func (a Values) Get(name string) *NamedValue

Get returns the NamedValue with the given name, if any.

func (Values) Has

func (a Values) Has(name string) bool

Has returns true if Values contains a NamedValue with this name.

func (Values) Hash

func (a Values) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (Values) Len

func (a Values) Len() int

Len return the length.

func (Values) List

func (a Values) List() []*NamedValue

List return a list of NamedValues sorted by name.

func (*Values) Set

func (a *Values) Set(name string, v *Value) *NamedValue

Set sets a name and a value and returns it as a NamedValue.

func (Values) ToStringDict

func (a Values) ToStringDict(d starlark.StringDict)

ToStringDict adds a name/value entry to d for each field of the struct.

Jump to

Keyboard shortcuts

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