internal

package
v0.0.0-...-237971a Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STRING          = "string"
	NUMBER          = "number"
	BOOLEAN         = "bool"
	LIST            = "list"
	OBJECT          = "object"
	FORMAT_TYPE     = "format_type"
	FORMAT_REQUIRED = "format_required"
	FORMAT_CHILDREN = "format_children"
	FORMAT_KEY      = "format_key"
)

Variables

This section is empty.

Functions

func CapitalizeFirstLetterOfWord

func CapitalizeFirstLetterOfWord(word string) string

func CurrentWorkingDir

func CurrentWorkingDir() string

CurrentWorkingDir returns the value of the working directory that the CLI is executed in.

func IsAnyFormatNode

func IsAnyFormatNode(value cty.Value) bool

IsAnyFormatNode is a simple check to make sure a particular value conforms to one of the format node structures. This function does not deep check any nested children, just the top level.

func IsFormatConstraintNode

func IsFormatConstraintNode(value cty.Value) bool

IsFormatConstraintNode checks to see whether a value conforms to the structure of a constraint node, which will/should be true for all leaf nodes in a value object

func IsFormatKeyValNode

func IsFormatKeyValNode(value cty.Value) bool

IsFormatKeyValNode checks to see whether a value conforms to the structure of a key/val node where all values conform to the constraint node type. A KeyValNode should exist at the top level of the format value, and in some FORMAT_CHILDREN values (those that are "nested" objects)

func MergeMaps

func MergeMaps[T any](mapOne map[string]T, mapTwo map[string]T) map[string]T

func PackageName

func PackageName(source string) string

func Ptr

func Ptr[T any](t T) *T

Ptr is a Helper function to return a pointer value to any type

func SchemaFormatSpecType

func SchemaFormatSpecType(schema cty.Value) cty.Type

SchemaFormatSpecType is a recursive function that returns the full cty.Type from the root of the provided schema. All leafs will be structured to what schematic returns.

func ValidateValueAgainstSpec

func ValidateValueAgainstSpec(val cty.Value, spec Spec, keyPath string) []error

ValidateValueAgainstSpec will go through an entire value and ensure it meets the constraints of the spe

Types

type DefaultOsManager

type DefaultOsManager struct{}

func (*DefaultOsManager) CreateDirectoryIfNotExists

func (d *DefaultOsManager) CreateDirectoryIfNotExists(path string) error

func (*DefaultOsManager) GetCurrentWorkingDirectory

func (d *DefaultOsManager) GetCurrentWorkingDirectory() string

type DefaultPluginManager

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

func (*DefaultPluginManager) KillAllPlugins

func (pm *DefaultPluginManager) KillAllPlugins()

func (*DefaultPluginManager) KillPlugin

func (pm *DefaultPluginManager) KillPlugin(name string) error

func (*DefaultPluginManager) LoadPlugin

func (pm *DefaultPluginManager) LoadPlugin(provider RequiredProviderBlock) error

func (*DefaultPluginManager) LoadedPlugins

func (pm *DefaultPluginManager) LoadedPlugins() []string

func (*DefaultPluginManager) PluginClient

func (pm *DefaultPluginManager) PluginClient(name string) (*plugin.Client, error)

func (*DefaultPluginManager) ProviderInstance

func (pm *DefaultPluginManager) ProviderInstance(name string) (sbsdk.Provider, error)

type ListSpec

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

func (*ListSpec) Children

func (s *ListSpec) Children() map[string]Spec

func (*ListSpec) IsKey

func (s *ListSpec) IsKey() bool

func (*ListSpec) IsRequired

func (s *ListSpec) IsRequired() bool

func (*ListSpec) Type

func (s *ListSpec) Type() cty.Type

func (*ListSpec) Valid

func (s *ListSpec) Valid() bool

type MapSpec

type MapSpec map[string]Spec

MapSpec allows us to solve the unique case of the root of all format objects and children being a key/val instead of a standard format schema-looking object.

func ShallowMergeMapSpecs

func ShallowMergeMapSpecs(leftSpec MapSpec, rightSpec MapSpec) MapSpec

ShallowMergeMapSpecs takes two specs and merges them, with the rightSpec taking precedent over any duplicates on the left.

func (*MapSpec) Children

func (s *MapSpec) Children() map[string]Spec

func (*MapSpec) IsKey

func (s *MapSpec) IsKey() bool

func (*MapSpec) IsRequired

func (s *MapSpec) IsRequired() bool

func (*MapSpec) Type

func (s *MapSpec) Type() cty.Type

func (*MapSpec) Valid

func (s *MapSpec) Valid() bool

type ObjectSpec

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

func (*ObjectSpec) Children

func (s *ObjectSpec) Children() map[string]Spec

func (*ObjectSpec) IsKey

func (s *ObjectSpec) IsKey() bool

func (*ObjectSpec) IsRequired

func (s *ObjectSpec) IsRequired() bool

func (*ObjectSpec) Type

func (s *ObjectSpec) Type() cty.Type

func (*ObjectSpec) Valid

func (s *ObjectSpec) Valid() bool

type OsManager

type OsManager interface {
	GetCurrentWorkingDirectory() string
	CreateDirectoryIfNotExists(path string) error
}

func NewDefaultOsManager

func NewDefaultOsManager() OsManager

type PluginConfig

type PluginConfig struct {
	Name    string
	Source  string
	Version string
	Client  *plugin.Client
}

type PluginManager

type PluginManager interface {
	LoadPlugin(RequiredProviderBlock) error
	PluginClient(string) (*plugin.Client, error)
	ProviderInstance(string) (sbsdk.Provider, error)
	KillPlugin(string) error
	KillAllPlugins()
	LoadedPlugins() []string
}

func NewDefaultPluginManager

func NewDefaultPluginManager() PluginManager

type PrimitiveSpec

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

func (*PrimitiveSpec) Children

func (s *PrimitiveSpec) Children() map[string]Spec

func (*PrimitiveSpec) IsKey

func (s *PrimitiveSpec) IsKey() bool

func (*PrimitiveSpec) IsRequired

func (s *PrimitiveSpec) IsRequired() bool

func (*PrimitiveSpec) Type

func (s *PrimitiveSpec) Type() cty.Type

func (*PrimitiveSpec) Valid

func (s *PrimitiveSpec) Valid() bool

type ProviderBlock

type ProviderBlock struct {
	// BlockName will match the first label of the config block. As a convention, this name
	// should map to a required_provider. If not, 'required_provider' should be set to explicitly
	// tell switchboard what required provider it should map to.
	BlockName string
	// ProviderName is the actual provider this block maps to. Will be the same as BlockName
	// if 'required_provider' field was not set
	ProviderName string
	// InitPayload includes all the provider-specific data passed in the config. This data will
	// be passed to the plugin on initialization. The schema is also validated against what the provider
	// plugin expects to be here (which happens during the parsing step)
	InitPayload cty.Value
}

ProviderBlock block lets a user configure various settings for a particular provider, such as auth contexts and other provider-specific settings. Refer to an individual provider plugin documentation for more details

type RequiredProviderBlock

type RequiredProviderBlock struct {
	Name    string
	Source  string
	Version string
}

RequiredProviderBlock tells us where a provider should be pulled from, and which version it should use.

type RootSwitchboardConfig

type RootSwitchboardConfig struct {
	Variables   []VariableBlock
	Switchboard SwitchboardBlock
	Providers   []ProviderBlock
	Schemas     []SchemaBlock
}

RootSwitchboardConfig is a container for all fully parsed and decoded static config settings as provided by the user. They are the result of processing all hcl block types in isolation, in an appropriate order. Most values come as discrete primitives from the config, while others are computed expressions.

Certain attributes are not known at the config parsing stage, such as variables derived from triggers or workflow steps. These values will be evaluated during individual workflow cycles.

func (*RootSwitchboardConfig) EvalContext

func (conf *RootSwitchboardConfig) EvalContext() *hcl.EvalContext

EvalContext is the high level evaluation context object used for evaluating expressions throughout the various blocks of the parent configuration. Note: The RootSwitchboardConfig.Variables should already be calculated and set before this can be used to evaluate other root blocks on the RootSwitchboardConfig object.

type SchemaBlock

type SchemaBlock struct {
	Name     string         `hcl:"name,label"`
	IsList   *bool          `hcl:"name"`
	Format   Spec           `hcl:"format"`
	Variants []VariantBlock `hcl:"variant,block"`
}

type Spec

type Spec interface {
	IsRequired() bool
	IsKey() bool
	Type() cty.Type
	Children() map[string]Spec
	Valid() bool
}

func SchemaFormatValueToSpec

func SchemaFormatValueToSpec(val cty.Value) Spec

SchemaFormatValueToSpec transforms a format value to a Spec struct. This function should only be used after validating the format structure, given cty.Value is inherently dynamic

type SwitchboardBlock

type SwitchboardBlock struct {
	Version string
	//Host              HostBlock
	RequiredProviders []RequiredProviderBlock
}

SwitchboardBlock contains the primary global configuration elements of all workflows, including the required providers, log settings, retry settings, and more.

type VariableBlock

type VariableBlock struct {
	Name  string
	Type  cty.Type
	Value cty.Value
}

VariableBlock contains the final variable value as calculated by the Load command, which may contain a mixture of default and override values, as provided by the user.

type VariantBlock

type VariantBlock struct {
	Name   string `hcl:"name,label"`
	Key    string `hcl:"key"`
	Format Spec   `hcl:"format"`
}

Jump to

Keyboard shortcuts

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