types

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PluginManagerLocal is the key of the terraform.PluginManager in the thread.
	PluginManagerLocal = "plugin_manager"
)

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

BuiltinBackend returns a starlak.Builtin function capable of instantiate new Backend instances.

outline: types
  functions:
    backend(type) Backend
      Instantiates a new [`Backend`](#backend)

      params:
        type string
          [Backend type](https://www.terraform.io/docs/backends/types/index.html).

func BuiltinEvaluate added in v0.1.0

func BuiltinEvaluate(predeclared starlark.StringDict) starlark.Value

BuiltinEvaluate returns a starlak.Builtin function to evalute Starlark files.

outline: types
  functions:
    evaluate(filename, predeclared=None) dict
      Evaluates a Starlark file and returns its global context. Kwargs may
      be used to set predeclared.
      examples:
        evaluable.star
        evaluate.star
      params:
        filename string
          Name of the file to execute.
        predeclared dict
          Defines the predeclared context for the execution. Execution does
          not modify this dictionary

func BuiltinFunctionAttribute added in v1.0.0

func BuiltinFunctionAttribute() starlark.Value

BuiltinFunctionAttribute returns a built-in function that wraps Attributes in HCL functions.

outline: types
  functions:
    fn(name, target) Attribute
      Fn wraps an Attribute in a HCL function. Since the Attributes value
      are only available in the `apply` phase of Terraform, the only method
      to manipulate this values is using the Terraform
      [HCL functions](https://www.terraform.io/docs/configuration/functions.html).

      params:
        name string
          Name of the HCL function to be applied. Eg.: `base64encode`
        target Attribute
          Target Attribute of the HCL function.

func BuiltinHCL

func BuiltinHCL() starlark.Value

BuiltinHCL returns a starlak.Builtin function to generate HCL from objects implementing the HCLCompatible interface.

outline: types
  functions:
    hcl(resource) string
      Returns the HCL encoding of the given resource.
      params:
        resource <resource>
          resource to be encoded.

func BuiltinProvisioner

func BuiltinProvisioner() starlark.Value

BuiltinProvisioner returns a starlak.Builtin function capable of instantiate new Provisioner instances.

outline: types
  functions:
    provisioner(type) Provisioner
      Instantiates a new Provisioner

      params:
        type string
          Provisioner type.

func BuiltinRef added in v1.3.0

func BuiltinRef() starlark.Value

BuiltinRef returns a starlak.Builtin function to generate a reference to a resource argument.

outline: types
  functions:
    ref(resource, argument) string
      Returns a reference to a resource argument.
      params:
        resource <resource>
          resource to be referenced.
        field string
          field to be referenced.

      examples:
        ref.star

func BuiltinValidate added in v1.1.0

func BuiltinValidate() starlark.Value

BuiltinValidate returns a starlak.Builtin function to validate objects implementing the Validabler interface.

outline: types
  functions:
    validate(resource) list
      Returns a list with validating errors if any. A validating error is
      a struct with two fields: `msg` and `pos`
      params:
        resource <resource>
          resource to be validated.

func MakeBackend

func MakeBackend(
	t *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple,
) (starlark.Value, error)

MakeBackend defines the Backend constructor.

func MakeProvider

func MakeProvider(
	t *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple,
) (starlark.Value, error)

MakeProvider defines the Provider constructor.

func MakeProvisioner

func MakeProvisioner(
	t *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple,
) (starlark.Value, error)

MakeProvisioner defines the Provisioner constructor.

func MakeResource

func MakeResource(
	c *ResourceCollection,
	t *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple,
) (starlark.Value, error)

MakeResource defines the Resource constructor.

Types

type Attribute added in v1.0.0

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

Attribute is a reference to an argument of a Resource. Used mainly for Computed arguments of Resources.

outline: types
  types:
    Attribute
      Attribute is a reference to an argument of a Resource. Used mainly
      for Computed arguments of Resources.

      Attribute behaves as the type of the argument represented, this means
      that them can be assigned to other resource arguments of the same
      type. And, if the type is a list are indexable.

      examples:
        attribute.star

      fields:
        __resource__ Resource
          Resource of the attribute.
        __type__ string
          Type of the attribute. Eg.: `string`

func NewAttribute added in v1.0.0

func NewAttribute(r *Resource, t cty.Type, name string) *Attribute

NewAttribute returns a new Attribute for a given value or block of a Resource. The path is calculated traversing the parents of the given Resource.

func NewAttributeWithPath added in v1.0.0

func NewAttributeWithPath(r *Resource, t cty.Type, name, path string) *Attribute

NewAttributeWithPath returns a new Attribute for a given value or block of a Resource.

func (*Attribute) Attr added in v1.0.0

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

Attr honors the starlark.HasAttrs interface.

func (*Attribute) AttrNames added in v1.0.0

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

AttrNames honors the starlark.HasAttrs interface.

func (*Attribute) Get added in v1.1.1

func (c *Attribute) Get(key starlark.Value) (v starlark.Value, found bool, err error)

Get honors the starlark.Mapping interface.

func (*Attribute) Index added in v1.0.0

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

Index honors the starlark.Indexable interface.

func (*Attribute) InnerType added in v1.0.0

func (c *Attribute) InnerType() *Type

InnerType returns the inner Type represented by this Attribute.

func (*Attribute) Len added in v1.0.0

func (c *Attribute) Len() int

Len honors the starlark.Indexable interface.

func (*Attribute) String added in v1.1.1

func (c *Attribute) String() string

func (*Attribute) Type added in v1.0.0

func (c *Attribute) Type() string

Type honors the starlark.Value interface.

type Backend

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

Backend represent a Terraform Backend.

outline: types
  types:
    Backend
      The part of Terraform's core that determines how Terraform stores
      state and performs operations (like plan, apply, import, etc.).
      Terraform has multiple [backends](https://www.terraform.io/docs/backends/index.html)
      to choose from, which can be configured in a variety of ways.

      fields:
        __kind__ string
          Kind of the backend. Fixed value `backend`.
        __type__ string
          Type of the backend. Eg.: `local`.
        __dict__ Dict
          A dictionary containing all the config values of the backend.
        <argument> <scalar>
          Arguments defined by the backend schema, thus can be of any
          scalar type.

      methods:
        state(module="", workspace="default") State
          Loads the latest state for a given module or workspace.
          params:
            module string
              name of the module, empty equals to root.
            workspace string
              backend workspace

func NewBackend added in v1.0.0

func NewBackend(pm *terraform.PluginManager, typ string, cs starlark.CallStack) (*Backend, error)

NewBackend returns a new Backend instance based on given arguments,

func (*Backend) Attr added in v0.1.0

func (b *Backend) Attr(name string) (starlark.Value, error)

Attr honors the starlark.HasAttrs interface.

func (*Backend) AttrNames added in v0.1.0

func (b *Backend) AttrNames() []string

AttrNames honors the starlark.HasAttrs interface.

func (*Backend) String added in v1.0.0

func (b *Backend) String() string

String honors the starlark.Value interface.

func (*Backend) ToHCL

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

ToHCL honors the HCLCompatible interface.

func (*Backend) Type added in v0.1.0

func (b *Backend) Type() string

Type honors the starlark.Value interface.

type Dict added in v1.0.0

type Dict struct {
	*starlark.Dict
}

Dict is a starlark.Dict HCLCompatible.

func NewDict added in v1.0.0

func NewDict() *Dict

NewDict returns a new empty Dict.

func (*Dict) ToHCL added in v1.0.0

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

ToHCL honors the HCLCompatible interface.

func (*Dict) Validate added in v1.1.0

func (d *Dict) Validate() (errs ValidationErrors)

Validate honors the Validabler interface.

type HCLCompatible

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

HCLCompatible defines if the struct is suitable of by encoded in HCL.

type Kind

type Kind string

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

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

Resource Kind constants.

func (Kind) IsNamed added in v1.0.0

func (k Kind) IsNamed() bool

IsNamed returns true if this kind of resources contains a name.

func (Kind) IsProviderRelated added in v1.0.0

func (k Kind) IsProviderRelated() bool

IsProviderRelated returns true if this kind of resources contains a provider.

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.

outline: types
  types:
    Provider
      A plugin for Terraform that makes a collection of related resources
      available. A provider plugin is responsible for understanding API
      interactions with some kind of service and exposing resources based
      on that API.

      examples:
        provider.star
        provider_resource.star
          Resource instantiation from a Provider.

      fields:
        __version__ string
          Provider version
        __kind__ string
          Kind of the provider. Fixed value `provider`
        __type__ string
          Type of the resource. Eg.: `aws_instance`
        __name__ string
          Local name of the provider, if none was provided to the constructor,
          the name is auto-generated following the pattern `id_%s`.  At
          Terraform is called [`alias`](https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-instances)
        __dict__ Dict
          A dictionary containing all set arguments and blocks of the provider.
        data MapSchema
          Data sources defined by the provider.
        resource MapSchema
          Resources defined by the provider.
        <argument> <scalar>
          Arguments defined by the provider schema, thus can be of any
          scalar type.
        <block> Resource
          Blocks defined by the provider schema, thus are nested resources,
          containing other arguments and/or blocks.

      methods:
        set_prefix(enable, prefix="")
          If enabled, all the resource names belonging to this provider
          are prefixed, with the given prefix or by default the alias name.
          params:
            enable bool
              if True enables the the prefix of resources.
            prefix string
              string to be used as prefix of the resources, if None, the
              provider name it's used as prefix.

func NewProvider added in v1.0.0

func NewProvider(pm *terraform.PluginManager, typ, version, name string, cs starlark.CallStack) (*Provider, error)

NewProvider returns a new Provider instance from a given type, version and name.

func (*Provider) Attr

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

Attr honors the starlark.Attr interface.

func (*Provider) AttrNames

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

AttrNames honors the starlark.HasAttrs interface.

func (*Provider) CompareSameType

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

CompareSameType honors starlark.Comparable interface.

func (*Provider) String

func (p *Provider) String() string

func (*Provider) ToHCL

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

ToHCL honors the HCLCompatible interface.

func (*Provider) Type

func (p *Provider) Type() string

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

func (*Provider) Validate added in v1.1.0

func (p *Provider) Validate() (errs ValidationErrors)

Validate honors the Validabler interface.

type ProviderCollection added in v0.1.0

type ProviderCollection struct {
	*Dict
	// contains filtered or unexported fields
}

ProviderCollection represents a nested Dict of providers, indexed by provider type and provider name.

outline: types
  types:
    ProviderCollection
      ProviderCollection holds the providers in a nested dictionary,
      indexed by provider type and provider name. The values can be
      accessed by indexing or using the built-in method of `dict`.

      examples:
        provider_collection.star

      methods:
        __call__(type, version="", name="") Provider
          Returns a new provider instance of the given type.

          examples:
            tf_provider.star
              Defining multiple providers and traversing `tf.providers`

          params:
            type string
              Provider type. Eg.: `aws`
            version string
              Version [value](https://www.terraform.io/docs/configuration/providers.html#provider-versions)
              , if `None` latest version available it's used.
            name string
              Local name of the resource, if `None` is provided it's
              autogenerated.

func NewProviderCollection added in v0.1.0

func NewProviderCollection(pm *terraform.PluginManager) *ProviderCollection

NewProviderCollection returns a new ProviderCollection.

func (*ProviderCollection) CallInternal added in v0.1.0

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

CallInternal honors the starlark.Callable interface.

func (*ProviderCollection) Freeze added in v0.1.0

func (c *ProviderCollection) Freeze()

Freeze honors the starlark.Value interface.

func (*ProviderCollection) Hash added in v0.1.0

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

Hash honors the starlark.Value interface.

func (*ProviderCollection) Name added in v0.1.0

func (c *ProviderCollection) Name() string

Name honors the starlark.Callable interface.

func (*ProviderCollection) Truth added in v0.1.0

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

Truth honors the starlark.Value interface.

func (*ProviderCollection) Type added in v0.1.0

func (c *ProviderCollection) Type() string

Type honors the starlark.Value interface.

type Provisioner

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

Provisioner represents a Terraform provider of a specif type.

outline: types
  types:
    Provisioner
      Provisioner represents a Terraform provider of a specif type. As
      written in the terraform documentation: "*Provisioners are a Last Resort*"

      fields:
        __kind__ string
          Kind of the provisioner. Fixed value `provisioner`
        __type__ string
          Type of the resource. Eg.: `aws_instance
        <argument> <scalar>
          Arguments defined by the provisioner schema, thus can be of any
          scalar type.
        <block> Resource
          Blocks defined by the provisioner schema, thus are nested resources,
          containing other arguments and/or blocks.

func NewProvisioner added in v1.0.0

func NewProvisioner(pm *terraform.PluginManager, typ string, cs starlark.CallStack) (*Provisioner, error)

NewProvisioner returns a new Provisioner for the given type.

func (*Provisioner) String added in v1.0.0

func (p *Provisioner) String() string

func (*Provisioner) ToHCL

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

ToHCL honors the HCLCompatible interface.

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.

outline: types
  types:
    Resource
      [Resources](https://www.terraform.io/docs/configuration/resources.html)
      are the most important element in the Terraform language. Each
      resource block describes one or more infrastructure objects, such as
      virtual networks, compute instances, or higher-level components such
      as DNS records.

      Each resource is associated with a single resource type, which
      determines the kind of infrastructure object it manages and what
      arguments and other attributes the resource supports.

      Each resource type in turn belongs to a provider, which is a plugin
      for Terraform that offers a collection of resource types. A provider
      usually provides resources to manage a single cloud or on-premises
      infrastructure platform.

      Following the schema of HCL Terraform resources each type of
      arguments and blocks are transformed in native AsCode elements:

      * [Blocks](https://www.terraform.io/docs/glossary.html#block) defined
        as a list of Resources are transformed into: `ResourceCollection<nested>`,
        if the `Block` is a list capped to one item, its represented as
        `Resource<nested>`.

      * [Arguments](https://www.terraform.io/docs/glossary.html#argument)
        are transformed as basic scalar types.

      * [Attributes](https://www.terraform.io/docs/glossary.html#attribute)
        aka computed arguments are transformed in `Attributes`

      examples:
        resource.star

      fields:
        __provider__ Provider
          Provider of this resource if any.
        __kind__ string
          Kind of the resource. Eg.: `data`
        __type__ string
          Type of the resource. Eg.: `aws_instance`
        __name__ string
          Local name of the resource, if none was provided to the constructor
          the name is auto-generated following the partern `id_%s`. Nested kind
          resources are unamed.
        __dict__ Dict
          A dictionary containing all set arguments and blocks of the resource.
        <argument> <scalar>/Computed
          Arguments defined by the resource schema, thus can be of any
          scalar type or Computed values.
        <block> Resource/ResourceCollection
          Blocks defined by the resource schema, thus are nested resources,
          containing other arguments and/or blocks.

      methods:
        depends_on(resource)
          Explicitly declares a dependency on another resource. Use the
          [depends_on](https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies)
          meta-argument to handle hidden resource dependencies that
          Terraform can't automatically infer.
          (Only in resources of kind "resource")
          params:
            resource Resource
              depended data or resource kind.
        add_provisioner(provisioner)
          Create-time actions like these can be described using resource
          provisioners. A provisioner is another type of plugin supported
          by Terraform, and each provisioner takes a different kind of
          action in the context of a resource being created.
          Provisioning steps should be used sparingly, since they represent
          non-declarative actions taken during the creation of a resource
          and so Terraform is not able to model changes to them as it can
          for the declarative portions of the Terraform language.
          (Only in resources of kind "resource")
          params:
            provisioner Provisioner
              provisioner resource to be executed.

func NewResource added in v1.0.0

func NewResource(
	name, typ string, k Kind,
	b *configschema.Block, provider *Provider, parent *Resource,
	cs starlark.CallStack,
) *Resource

NewResource 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) CallStack added in v1.1.0

func (r *Resource) CallStack() starlark.CallStack

func (*Resource) CompareSameType

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

CompareSameType honors starlark.Comparable 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) Name

func (r *Resource) Name() string

Name returns the resource name based.

func (*Resource) Path added in v1.0.0

func (r *Resource) Path() string

Path returns the path of the Resource.

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)

ToHCL honors the HCLCompatible interface.

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.

func (*Resource) Validate added in v1.1.0

func (r *Resource) Validate() ValidationErrors

Validate honors the Validabler interface.

type ResourceCollection

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

ResourceCollection stores and instantiates resources for specific provider and resource.

outline: types
  types:
    ResourceCollection
        ResourceCollection stores and instantiates resources for a specific
        pair of provider and resource. The resources can be accessed by
        indexing or using the built-in method of `dict`.

      fields:
        __provider__ Provider
          Provider of this resource collection.
        __kind__ string
          Kind of the resource collection. Eg.: `data`
        __type__ string
          Type of the resource collection. Eg.: `aws_instance`

      methods:
        __call__(name="", values={}) Resource
          Returns a new resourced with the given name and values.

          examples:
            resource_collection_call.star
               Resource instantiation using values, dicts or kwargs.

          params:
            name string
              Local name of the resource, if `None` is provided it's
              autogenerated.
            values dict
              List of arguments and nested blocks to be set in the new
              resource, these values can also be defined using `kwargs`.
        search(key="id", value) list
          Return all the Resources with the given value in the given key.

          examples:
            resource_collection_search.star

          params:
            name string
              Key to search. The default value is `id`.
            value <any>
              Value to match in the given key.

func NewNestedResourceCollection added in v1.1.0

func NewNestedResourceCollection(
	typ string, block *configschema.NestedBlock, provider *Provider, parent *Resource,
) *ResourceCollection

NewNestedResourceCollection returns

func NewResourceCollection

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

NewResourceCollection returns a new ResourceCollection for the given values.

func (*ResourceCollection) Attr added in v0.1.0

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

Attr honors the starlark.HasAttrs interface.

func (*ResourceCollection) AttrNames added in v0.1.0

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

AttrNames honors the starlark.HasAttrs interface.

func (*ResourceCollection) CallInternal

func (c *ResourceCollection) CallInternal(
	t *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) Name

func (c *ResourceCollection) Name() string

Name honors the starlark.Callable interface.

func (*ResourceCollection) Path added in v1.0.0

func (c *ResourceCollection) Path() string

Path returns the path of the ResourceCollection.

func (*ResourceCollection) String

func (c *ResourceCollection) String() string

String honors the starlark.Value interface.

func (*ResourceCollection) ToHCL

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

ToHCL honors the HCLCompatible interface.

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.

func (*ResourceCollection) Validate added in v1.1.0

func (c *ResourceCollection) Validate() (errs ValidationErrors)

Validate honors the Validabler interface.

type ResourceCollectionGroup added in v1.0.0

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

ResourceCollectionGroup represents a group by kind (resource or data resource) of ResourceCollections for a given provider.

outline: types
  types:
    ResourceCollectionGroup
      ResourceCollectionGroup represents a group by kind (resource or data
      resource) of ResourceCollections for a given provider.

      fields:
        __provider__ Provider
          Provider of this group.
        __kind__ string
          Kind of the resources (`data` or `resource`).
        <resource-name> ResourceCollection
          Returns a ResourceCollection if the resource name is valid for
          the schema of the provider. The resource name should be provided
          without the provider prefix, `aws_instance` becomes
          just an `instance`.

func NewResourceCollectionGroup added in v1.0.0

func NewResourceCollectionGroup(p *Provider, k Kind, schema map[string]providers.Schema) *ResourceCollectionGroup

NewResourceCollectionGroup returns a new ResourceCollectionGroup for a given provider and kind based on the given schema.

func (*ResourceCollectionGroup) Attr added in v1.0.0

Attr honors the starlark.HasAttrs interface.

func (*ResourceCollectionGroup) AttrNames added in v1.0.0

func (g *ResourceCollectionGroup) AttrNames() []string

AttrNames honors the starlark.HasAttrs interface.

func (*ResourceCollectionGroup) Freeze added in v1.0.0

func (*ResourceCollectionGroup) Freeze()

Freeze honors the starlark.Value interface.

func (*ResourceCollectionGroup) Hash added in v1.0.0

func (g *ResourceCollectionGroup) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (*ResourceCollectionGroup) Path added in v1.0.0

func (g *ResourceCollectionGroup) Path() string

Path returns the path of the ResourceCollectionGroup.

func (*ResourceCollectionGroup) String added in v1.0.0

func (g *ResourceCollectionGroup) String() string

String honors the starlark.String interface.

func (*ResourceCollectionGroup) ToHCL added in v1.0.0

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

ToHCL honors the HCLCompatible interface.

func (*ResourceCollectionGroup) Truth added in v1.0.0

Truth honors the starlark.Value interface. True even if empty.

func (*ResourceCollectionGroup) Type added in v1.0.0

func (g *ResourceCollectionGroup) Type() string

Type honors the starlark.Value interface.

func (*ResourceCollectionGroup) Validate added in v1.1.0

func (g *ResourceCollectionGroup) Validate() (errs ValidationErrors)

Validate honors the Validabler interface.

type State added in v0.1.0

type State struct {
	*starlark.Dict
	// contains filtered or unexported fields
}

State represents a Terraform state read by a backend. https://www.terraform.io/docs/state/index.html

outline: types
  types:
    State
      Terraform's cached information about your managed infrastructure
      and configuration. This [state](https://www.terraform.io/docs/state/index.html)
      is used to persistently map the same real world resources to your
      configuration from run-to-run, keep track of metadata, and improve
      performance for large infrastructures.

      State implements a Dict, where the first level are the providers
      containing the keys `data` with the data sources and `resources` with
      the resources.

      examples:
        backend_local.star
          An example of how to print a resume of providers and resources
          count from the state.

      fields:
        <provider> AttrDict
          provider and all the resources state.

func NewState added in v1.0.0

func NewState(pm *terraform.PluginManager, module string, state *states.State) (*State, error)

NewState returns a new instance of State based on the given arguments,

type Terraform added in v0.1.0

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

Terraform is a representation of Terraform as a starlark.Value

outline: types
  types:
    Terraform
      Terraform holds all the configuration defined by a script. A global
      variable called `tf` contains a unique instance of Terraform.

      examples:
        tf_overview.star

      fields:
        version string
          Terraform version.
        backend Backend
          Backend used to store the state, if None a `local` backend it's
          used.
        provider ProviderCollection
          Dict with all the providers defined by provider type.

func NewTerraform added in v1.0.0

func NewTerraform(pm *terraform.PluginManager) *Terraform

NewTerraform returns a new instance of Terraform

func (*Terraform) Attr added in v0.1.0

func (t *Terraform) Attr(name string) (starlark.Value, error)

Attr honors the starlark.HasAttrs interface.

func (*Terraform) AttrNames added in v0.1.0

func (t *Terraform) AttrNames() []string

AttrNames honors the starlark.HasAttrs interface.

func (*Terraform) Freeze added in v0.1.0

func (t *Terraform) Freeze()

Freeze honors the starlark.Value interface.

func (*Terraform) Hash added in v0.1.0

func (t *Terraform) Hash() (uint32, error)

Hash honors the starlark.Value interface.

func (*Terraform) SetField added in v0.1.0

func (t *Terraform) SetField(name string, val starlark.Value) error

SetField honors the starlark.HasSetField interface.

func (*Terraform) String added in v0.1.0

func (t *Terraform) String() string

String honors the starlark.Value interface.

func (*Terraform) ToHCL added in v0.1.0

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

ToHCL honors the HCLCompatible interface.

func (*Terraform) Truth added in v0.1.0

func (t *Terraform) Truth() starlark.Bool

Truth honors the starlark.Value interface.

func (*Terraform) Type added in v0.1.0

func (t *Terraform) Type() string

Type honors the starlark.Value interface.

func (*Terraform) Validate added in v1.1.0

func (t *Terraform) Validate() (errs ValidationErrors)

Validate honors the Validabler 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 against the type.

type Validabler added in v1.1.0

type Validabler interface {
	Validate() ValidationErrors
}

Validabler defines if the resource is validable.

type ValidationError added in v1.1.0

type ValidationError struct {
	// Msg reason of the error
	Msg string
	// CallStack of the instantiation of the value being validated.
	CallStack starlark.CallStack
}

ValidationError is an error returned by Validabler.Validate.

func NewValidationError added in v1.1.0

func NewValidationError(cs starlark.CallStack, format string, args ...interface{}) *ValidationError

NewValidationError returns a new ValidationError.

func (*ValidationError) Error added in v1.1.0

func (e *ValidationError) Error() string

func (*ValidationError) Value added in v1.1.0

func (e *ValidationError) Value() starlark.Value

Value returns the error as a starlark.Value.

type ValidationErrors added in v1.1.0

type ValidationErrors []*ValidationError

ValidationErrors represents a list of ValidationErrors.

func (ValidationErrors) Value added in v1.1.0

func (e ValidationErrors) Value() starlark.Value

Value returns the errors as a starlark.Value.

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) Cty added in v0.1.0

func (a Values) Cty(schema *configschema.Block) cty.Value

Cty returns the cty.Value based on a given schema.

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