definitions

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockKindDocument     = "document"
	BlockKindConfig       = "config"
	BlockKindContent      = "content"
	BlockKindData         = "data"
	BlockKindMeta         = "meta"
	BlockKindSection      = "section"
	BlockKindGlobalConfig = "fabric"

	PluginTypeRef = "ref"
	AttrRefBase   = "base"
	AttrTitle     = "title"
)

Variables

This section is empty.

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 {
	*hcl.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() *hcl.Block

func (*Config) GetKey

func (c *Config) GetKey() *Key

func (*Config) ParseConfig

func (c *Config) ParseConfig(spec hcldec.Spec) (val cty.Value, diags diagnostics.Diag)

ParseConfig implements Configuration.

func (*Config) Range

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

Range implements Configuration.

type ConfigEmpty

type ConfigEmpty struct {
	MissingItemRange hcl.Range
}

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(spec hcldec.Spec) (val cty.Value, 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(spec hcldec.Spec) (val cty.Value, 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
}

Document and section are very similar conceptually.

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() *hcl.Block

type FabricBlock

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

type GlobalConfig

type GlobalConfig struct {
	CacheDir       string
	PluginRegistry *PluginRegistry
	PluginVersions map[string]string
	// contains filtered or unexported fields
}

func DefineGlobalConfig

func DefineGlobalConfig(block *hclsyntax.Block) (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"`
	Author      string   `hcl:"author,optional"`
	Tags        []string `hcl:"tags,optional"`
	UpdatedAt   string   `hcl:"updated_at,optional"`
}

func (*MetaBlock) AsJQData

func (m *MetaBlock) AsJQData() plugin.Data

type ParsedContent

type ParsedContent ParsedPlugin

func NewTitle

func NewTitle(title *hclsyntax.Attribute, resolver ConfigResolver) *ParsedContent

func (*ParsedContent) EvalQuery

func (c *ParsedContent) EvalQuery(dataCtx *evaluation.DataContext) (diags diagnostics.Diag)

func (*ParsedContent) Render

func (c *ParsedContent) Render(ctx context.Context, caller evaluation.ContentCaller, dataCtx evaluation.DataContext, result *evaluation.Result) (diags diagnostics.Diag)

Render implements Renderable.

type ParsedData

type ParsedData ParsedPlugin

type ParsedDocument

type ParsedDocument struct {
	Meta    *MetaBlock
	Content []Renderable
	Data    []*ParsedData
}

func (*ParsedDocument) Render

func (d *ParsedDocument) Render(ctx context.Context, caller evaluation.PluginCaller) (result []string, diags diagnostics.Diag)

type ParsedPlugin

type ParsedPlugin struct {
	PluginName string
	BlockName  string
	Meta       *MetaBlock
	Config     evaluation.Configuration
	Invocation evaluation.Invocation
}

func (*ParsedPlugin) GetBlockInvocation

func (pe *ParsedPlugin) GetBlockInvocation() *evaluation.BlockInvocation

type ParsedSection

type ParsedSection struct {
	Meta    *MetaBlock
	Title   *ParsedContent
	Content []Renderable
}

func (ParsedSection) Render

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() *hcl.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 {
	MirrorDir string
}

type Renderable

type Renderable interface {
	Render(ctx context.Context, caller evaluation.ContentCaller, dataCtx evaluation.DataContext, result *evaluation.Result) diagnostics.Diag
}

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() *hcl.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