types

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const TypeModule = "module"

TypeModule is the resource string for a Module resource

View Source
const TypeOutput = "output"
View Source
const TypeRoot = "root"

TypeModule is the resource string for a Module resource

View Source
const TypeVariable = "variable"

Variables

View Source
var TypeResource = "resource"

Functions

This section is empty.

Types

type ErrTypeNotRegistered

type ErrTypeNotRegistered struct {
	Type string
}

func NewTypeNotRegisteredError added in v0.2.1

func NewTypeNotRegisteredError(t string) *ErrTypeNotRegistered

func (*ErrTypeNotRegistered) Error added in v0.2.1

func (e *ErrTypeNotRegistered) Error() string

type Findable

type Findable interface {
	FindResource(path string) (Resource, error)
	FindRelativeResource(path string, parentModule string) (Resource, error)
	FindResourcesByType(t string) ([]Resource, error)
	FindModuleResources(module string, includeSubModules bool) ([]Resource, error)
}

Findable defines an interface used for locating resources

type Module

type Module struct {
	ResourceMetadata `hcl:",remain"`

	Source string `hcl:"source" json:"source"`

	Variables interface{} `hcl:"variables,optional" json:"variables,omitempty"`

	// SubContext is used to store the variables as a context that can be
	// passed to child resources
	SubContext *hcl.EvalContext
}

Module allows Shipyard configuration to be imported from external folder or GitHub repositories

type Output

type Output struct {
	ResourceMetadata `hcl:",remain"`

	Value       string `hcl:"value,optional" json:"value,omitempty"`             // value of the output
	Description string `hcl:"description,optional" json:"description,omitempty"` // description for the output
}

Output defines an output variable which can be set by a module

type Parsable added in v0.3.0

type Parsable interface {
	// Parse is called when the resource is created from a file
	//
	// Note: it is not possible to set resource properties from parse
	// as all properties are overwritten when the resource is processed
	// by the dag and any dependencies are resolved.
	//
	// ResourceMetadata can be set by this method as this is not overridden
	// when processed.
	//
	// Returning an error stops the execution of Parse for other resources
	// in the configuration
	Parse() error
}

Parsable defines an optional interface that allows a resource to be modified directly after it has been loaded from a file

Parsable should be implemented when you want to do basic validation of resources before they are processed by the graph.

Parse is called sequentially for each resource as it is loaded from the config file. This occurs before the graph of dependent resources has been built.

type Processable

type Processable interface {
	// Process is called by the parser when when the graph of resources is walked.
	//
	// Returning an error from Process stops the processing of other resources
	// and terminates all parsing.
	Process() error
}

Processable defines an optional interface that allows a resource to define a callback that is executed when the resources is processed by the graph.

Unlike Parsable, Process for a resource is called in strict order based upon its dependency to other resources. You can set calculated fields and perform operations in Process and this information will be available to dependent resources.

type RegisteredTypes

type RegisteredTypes map[string]Resource

func DefaultTypes

func DefaultTypes() RegisteredTypes

DefaultTypes is a collection of the default config types

func (RegisteredTypes) CreateResource

func (r RegisteredTypes) CreateResource(resourceType, resourceName string) (Resource, error)

CreateResource creates a new instance of a resource from one of the registered types.

type Resource

type Resource interface {
	// return the resource Metadata
	Metadata() *ResourceMetadata
}

Resource is an interface that all

type ResourceFQRN added in v0.5.0

type ResourceFQRN struct {
	// Name of the module
	Module string
	// Type of the resource
	Type string
	// Resource name
	Resource string
	// Attribute for the resource
	Attribute string
}

ResourceFQRN is the fully qualified resource name

func FQDNFromResource

func FQDNFromResource(r Resource) *ResourceFQRN

FQDNFromResource returns the ResourceFQDN for the given Resource

func ParseFQRN added in v0.5.0

func ParseFQRN(fqdn string) (*ResourceFQRN, error)

ParseFQRN parses a "resource" fqrn and returns the individual components e.g:

get the "resource" container called mine that is in the root "module" which also has "attributes" // resource.container.mine.property.value

get the "resource" container called mine that is in the root "module" // resource.container.mine

get the "output" called mine that is in the root "module" // output.mine

get the container "resource" called mine in the "module" module2 that is in the "module" module1 // module1.module2.resource.container.mine

get the "output" called mine in the "module" module2 that is in the "module" module1 // module1.module2.output.mine

get the "module" resource called module2 in the "module" module1 // module1.module2

get the "module" resource called module1 in the root "module" // module1

func (*ResourceFQRN) AppendParentModule added in v0.5.0

func (f *ResourceFQRN) AppendParentModule(parent string) ResourceFQRN

AppendParentModule creates a new FQRN by adding the parent module to the reference.

func (ResourceFQRN) String added in v0.5.0

func (f ResourceFQRN) String() string

type ResourceMetadata

type ResourceMetadata struct {
	// ID is the unique id for the resource
	// this follows the convention module_name.resource_name
	// i.e module.module1.module2.resource.container.mine
	ID string `json:"id"`

	// Name is the name of the resource
	// this is an internal property that is set from the stanza label
	Name string `json:"name"`

	// Type is the type of resource, this is the text representation of the golang type
	// this is an internal property that can not be set with hcl
	Type string `json:"type"`

	// Module is the name of the module if a resource has been loaded from a module
	// this is an internal property that can not be set with hcl
	Module string `json:"module,omitempty"`

	// Linked resources which must be set before this config can be processed
	// this is an internal property that can not be set with hcl
	ResourceLinks []string `json:"resource_links,omitempty"`

	// File is the absolute path of the file where the resource is defined
	// this is an internal property that can not be set with hcl
	File string `json:"file"`

	// Line is the starting line number where the resource is located in the
	// file from where it was originally parsed
	Line int `json:"line"`

	// Column is the starting column number where the resource is located in the
	// file from where it was originally parsed
	Column int `json:"column"`

	// ParentConfig allows the location of other resources in the config
	// this is an internal property that can not be set with hcl
	ParentConfig Findable `json:"-"`

	// Properties holds a collection that can be used to store adhoc data
	Properties map[string]interface{} `json:"properties,omitempty"`

	// DependsOn is a user configurable list of dependencies for this resource
	DependsOn []string `hcl:"depends_on,optional" json:"depends_on,omitempty"`

	// Enabled determines if a resource is enabled and should be processed
	Disabled bool `hcl:"disabled,optional" json:"disabled,omitempty"`
}

ResourceMetadata is the embedded type for any config resources it defines common meta data that all resources share

func (*ResourceMetadata) Metadata

func (r *ResourceMetadata) Metadata() *ResourceMetadata

Metadata is a function that ensures the struct that embeds the ResourceMetadata struct conforms to the interface Resource

type Root added in v0.5.0

type Root struct {
	ResourceMetadata `hcl:",remain"`
}

Module allows Shipyard configuration to be imported from external folder or GitHub repositories

type Variable

type Variable struct {
	ResourceMetadata `hcl:",remain"`
	Default          interface{} `hcl:"default" json:"default"`                            // default value for a variable
	Description      string      `hcl:"description,optional" json:"description,omitempty"` // description of the variable
}

Output defines an output variable which can be set by a module

Jump to

Keyboard shortcuts

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