definitions

package
v0.4.3-final-apache Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockKindDocument     = "document"
	BlockKindConfig       = "config"
	BlockKindContent      = "content"
	BlockKindPublish      = "publish"
	BlockKindData         = "data"
	BlockKindMeta         = "meta"
	BlockKindVars         = "vars"
	BlockKindSection      = "section"
	BlockKindGlobalConfig = "fabric"
	BlockKindDynamic      = "dynamic"

	PluginTypeRef    = "ref"
	AttrRefBase      = "base"
	AttrTitle        = "title"
	AttrDependsOn    = "depends_on"
	AttrLocalVar     = "local_var"
	AttrRequiredVars = "required_vars"
	AttrIsIncluded   = "is_included"
	AttrDynamicItems = "items"
)
View Source
const LocalVarName = "local"

Variables

View Source
var DefaultEnvVarsPattern = glob.MustCompile("FABRIC_*")

Functions

func NewNestingDiag

func NewNestingDiag(what string, block *hclsyntax.Block, body *hclsyntax.Body, validChildren []string) *hcl.Diagnostic

func ToCtyValue

func ToCtyValue(b FabricBlock) cty.Value

Types

type Config

type Config struct {
	*hclsyntax.Block
	// contains filtered or unexported fields
}

Configuration block.

func DefineConfig

func DefineConfig(block *hclsyntax.Block) (config *Config, diags diagnostics.Diag)

func (*Config) ApplicableTo

func (c *Config) ApplicableTo(plugin *Plugin) bool

func (*Config) CtyType

func (c *Config) CtyType() cty.Type

func (*Config) Exists

func (c *Config) Exists() bool

Exists implements evaluation.Configuration.

func (*Config) GetHCLBlock

func (c *Config) GetHCLBlock() *hclsyntax.Block

func (*Config) GetKey

func (c *Config) GetKey() *Key

func (*Config) ParseConfig

func (c *Config) ParseConfig(ctx context.Context, spec *dataspec.RootSpec) (val *dataspec.Block, diags diagnostics.Diag)

ParseConfig implements Configuration.

type ConfigEmpty

type ConfigEmpty struct {
	Plugin *Plugin
}

Empty config, storing the range of the original block

func (*ConfigEmpty) Exists

func (c *ConfigEmpty) Exists() bool

Exists implements evaluation.Configuration.

func (*ConfigEmpty) ParseConfig

func (c *ConfigEmpty) ParseConfig(ctx context.Context, spec *dataspec.RootSpec) (val *dataspec.Block, diags diagnostics.Diag)

ParseConfig implements Configuration.

func (*ConfigEmpty) Range

func (c *ConfigEmpty) Range() hcl.Range

Range implements Configuration.

type ConfigPtr

type ConfigPtr struct {
	Cfg *Config
	Ptr *hcl.Attribute
}

Attribute referencing a configuration block (`config = path.to.config`).

func (*ConfigPtr) Exists

func (c *ConfigPtr) Exists() bool

Exists implements evaluation.Configuration.

func (*ConfigPtr) ParseConfig

func (c *ConfigPtr) ParseConfig(ctx context.Context, spec *dataspec.RootSpec) (val *dataspec.Block, diags diagnostics.Diag)

ParseConfig implements Configuration.

func (*ConfigPtr) Range

func (c *ConfigPtr) Range() hcl.Range

Range implements Configuration.

type ConfigResolver

type ConfigResolver func(pluginKind, pluginName string) (config *Config)

type Document

type Document struct {
	Block *hclsyntax.Block
	Name  string
	Meta  *MetaBlock
}

func DefineDocument

func DefineDocument(block *hclsyntax.Block) (doc *Document, diags diagnostics.Diag)

func (*Document) CtyType

func (d *Document) CtyType() cty.Type

func (*Document) GetHCLBlock

func (d *Document) GetHCLBlock() *hclsyntax.Block

type Dynamic

type Dynamic struct {
	ParseResult *ParsedDynamic
}

type FabricBlock

type FabricBlock interface {
	GetHCLBlock() *hclsyntax.Block
	CtyType() cty.Type
}

type GlobalConfig

type GlobalConfig struct {
	CacheDir       string            `hcl:"cache_dir,optional"`
	PluginRegistry *PluginRegistry   `hcl:"plugin_registry,block"`
	PluginVersions map[string]string `hcl:"plugin_versions,optional"`
	EnvVarsPattern glob.Glob
}

func (*GlobalConfig) Merge added in v0.4.0

func (g *GlobalConfig) Merge(other *GlobalConfig)

type GlobalConfigDefinition added in v0.4.2

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

func DefineGlobalConfig

func DefineGlobalConfig(block *hclsyntax.Block) (config *GlobalConfigDefinition, diags diagnostics.Diag)

func (*GlobalConfigDefinition) GetHCLBlock added in v0.4.2

func (g *GlobalConfigDefinition) GetHCLBlock() *hclsyntax.Block

func (*GlobalConfigDefinition) Parse added in v0.4.2

func (g *GlobalConfigDefinition) Parse(ctx context.Context) (cfg *GlobalConfig, diags diagnostics.Diag)

type Key

type Key struct {
	PluginKind string
	PluginName string
	BlockName  string
}

Identifies a plugin block

type MetaBlock

type MetaBlock struct {
	Name        string   `hcl:"name,optional"`
	Description string   `hcl:"description,optional"`
	Url         string   `hcl:"url,optional"`
	License     string   `hcl:"license,optional"`
	Authors     []string `hcl:"authors,optional"`
	Tags        []string `hcl:"tags,optional"`
	UpdatedAt   string   `hcl:"updated_at,optional"`
	Version     string   `hcl:"version,optional"`
}

func (*MetaBlock) AsPluginData

func (m *MetaBlock) AsPluginData() plugindata.Data

func (*MetaBlock) MatchesTags

func (m *MetaBlock) MatchesTags(requiredTags []string) bool

type ParsedContent

type ParsedContent struct {
	Section *ParsedSection
	Plugin  *ParsedPlugin
	Dynamic *ParsedDynamic
}

type ParsedDocument

type ParsedDocument struct {
	Source       *Document
	Meta         *MetaBlock
	Vars         *ParsedVars
	RequiredVars []string
	Content      []*ParsedContent
	Data         []*ParsedPlugin
	Publish      []*ParsedPlugin
}

type ParsedDynamic

type ParsedDynamic struct {
	Block *hclsyntax.Block
	// Items is a list of items to be iterated over dynamically.
	// Always present.
	Items   *hclsyntax.Attribute
	Content []*ParsedContent
}

type ParsedPlugin

type ParsedPlugin struct {
	Source       *Plugin
	PluginName   string
	BlockName    string
	Meta         *MetaBlock
	Config       evaluation.Configuration
	Invocation   *evaluation.BlockInvocation
	Vars         *ParsedVars
	RequiredVars []string
	DependsOn    []string
	IsIncluded   *hclsyntax.Attribute
}

type ParsedSection

type ParsedSection struct {
	Source       *Section
	Meta         *MetaBlock
	Title        *ParsedContent
	Content      []*ParsedContent
	Vars         *ParsedVars
	RequiredVars []string
	IsIncluded   *hclsyntax.Attribute
}

func (ParsedSection) Name added in v0.4.1

func (s ParsedSection) Name() string

type ParsedVars added in v0.4.2

type ParsedVars struct {
	// stored in the order of definition
	Variables []*dataspec.Attr
	ByName    map[string]int
}

func (*ParsedVars) AppendVar added in v0.4.2

func (pv *ParsedVars) AppendVar(variable *dataspec.Attr)

AppendVar append a variable to the parsed vars struct (last in evaluation order).

func (*ParsedVars) Empty added in v0.4.2

func (pv *ParsedVars) Empty() bool

func (*ParsedVars) MergeWithBaseVars added in v0.4.2

func (pv *ParsedVars) MergeWithBaseVars(baseVars *ParsedVars) *ParsedVars

MergeWithBaseVars handles merging with vars from ref base. Shadowing has different rules, and will be handled at the evaluation stage.

type Plugin

type Plugin struct {
	Block *hclsyntax.Block

	Once        sync.Once
	Parsed      bool
	ParseResult *ParsedPlugin
}

func DefinePlugin

func DefinePlugin(block *hclsyntax.Block, atTopLevel bool) (plugin *Plugin, diags diagnostics.Diag)

func (*Plugin) BlockName

func (p *Plugin) BlockName() string

func (*Plugin) CtyType

func (p *Plugin) CtyType() cty.Type

func (*Plugin) DefRange

func (p *Plugin) DefRange() hcl.Range

func (*Plugin) GetHCLBlock

func (p *Plugin) GetHCLBlock() *hclsyntax.Block

func (*Plugin) GetKey

func (p *Plugin) GetKey() *Key

func (*Plugin) IsRef

func (p *Plugin) IsRef() bool

Whether or not the original block is a ref.

func (*Plugin) Kind

func (p *Plugin) Kind() string

func (*Plugin) Name

func (p *Plugin) Name() string

type PluginRegistry

type PluginRegistry struct {
	BaseURL   string `hcl:"base_url,optional"`
	MirrorDir string `hcl:"mirror_dir,optional"`
}

type Section

type Section struct {
	Block       *hclsyntax.Block
	Once        sync.Once
	Parsed      bool
	ParseResult *ParsedSection
}

func DefineSection

func DefineSection(block *hclsyntax.Block, atTopLevel bool) (section *Section, diags diagnostics.Diag)

func (*Section) CtyType

func (*Section) CtyType() cty.Type

func (*Section) GetHCLBlock

func (s *Section) GetHCLBlock() *hclsyntax.Block

func (*Section) IsRef

func (s *Section) IsRef() bool

func (*Section) Name

func (s *Section) Name() string

Jump to

Keyboard shortcuts

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