Documentation ¶
Index ¶
- Variables
- func AddReferences(resource modconfig.HclResource, block *hcl.Block, parseCtx *ModParseContext) hcl.Diagnostics
- func ContextFunctions(workspaceDir string) map[string]function.Function
- func DecodeConnection(block *hcl.Block) (*modconfig.Connection, hcl.Diagnostics)
- func DecodeOptions(block *hcl.Block) (options.Options, hcl.Diagnostics)
- func GetMetadataForParsedResource(resourceName string, srcRange hcl.Range, fileData map[string][]byte, ...) (*modconfig.ResourceMetadata, error)
- func LoadFileData(paths ...string) (map[string][]byte, hcl.Diagnostics)
- func LoadWorkspaceProfiles(workspaceProfilePath string) (profileMap map[string]*modconfig.WorkspaceProfile, err error)
- func ModfileExists(modPath string) bool
- func ParseHclFiles(fileData map[string][]byte) (hcl.Body, hcl.Diagnostics)
- func ParseMod(fileData map[string][]byte, pseudoResources []modconfig.MappableResource, ...) (*modconfig.Mod, *modconfig.ErrorAndWarnings)
- func ParseModDefinition(modPath string) (*modconfig.Mod, error)
- func ParseModResourceNames(fileData map[string][]byte) (*modconfig.WorkspaceResources, error)
- func ParseQueryInvocation(arg string) (string, *modconfig.QueryArgs, error)
- func VariableValueCtyMap(variables map[string]*modconfig.Variable) map[string]cty.Value
- type InstalledMod
- type ModParseContext
- func (m *ModParseContext) AddDependencies(block *hcl.Block, name string, ...) hcl.Diagnostics
- func (m *ModParseContext) AddInputVariables(inputVariables *modconfig.ModVariableMap)
- func (m *ModParseContext) AddLoadedDependencyMod(mod *modconfig.Mod)
- func (m *ModParseContext) AddMod(mod *modconfig.Mod) hcl.Diagnostics
- func (m *ModParseContext) AddResource(resource modconfig.HclResource) hcl.Diagnostics
- func (m *ModParseContext) AddVariablesToReferenceMap()
- func (m *ModParseContext) CreatePseudoResources() bool
- func (m *ModParseContext) DetermineBlockName(block *hcl.Block) string
- func (m *ModParseContext) EnsureWorkspaceLock(mod *modconfig.Mod) error
- func (m *ModParseContext) GetCachedBlockName(block *hcl.Block) (string, bool)
- func (m *ModParseContext) GetCachedBlockShortName(block *hcl.Block) (string, bool)
- func (m *ModParseContext) GetDecodedResourceForBlock(block *hcl.Block) (modconfig.HclResource, bool)
- func (m *ModParseContext) GetLoadedDependencyMod(requiredModVersion *modconfig.ModVersionConstraint, mod *modconfig.Mod) (*modconfig.Mod, error)
- func (m *ModParseContext) GetMod(modShortName string) *modconfig.Mod
- func (m *ModParseContext) GetResource(parsedName *modconfig.ParsedResourceName) (resource modconfig.HclResource, found bool)
- func (m *ModParseContext) GetResourceMaps() *modconfig.ResourceMaps
- func (m *ModParseContext) GetTopLevelDependencyMods() modconfig.ModMap
- func (m *ModParseContext) IsTopLevelBlock(block *hcl.Block) bool
- func (m *ModParseContext) PeekParent() string
- func (m *ModParseContext) PopParent() string
- func (m *ModParseContext) PushParent(parent modconfig.ModTreeItem)
- func (m *ModParseContext) SetCurrentMod(mod *modconfig.Mod)
- func (m *ModParseContext) SetDecodeContent(content *hcl.BodyContent, fileData map[string][]byte)
- func (m *ModParseContext) ShouldCreateDefaultMod() bool
- type ParseContext
- func (r *ParseContext) AddDependencies(block *hcl.Block, name string, ...) hcl.Diagnostics
- func (r *ParseContext) BlocksToDecode() (hcl.Blocks, error)
- func (r *ParseContext) ClearDependencies()
- func (r *ParseContext) EvalComplete() bool
- func (r *ParseContext) FormatDependencies() string
- func (r *ParseContext) SetDecodeContent(content *hcl.BodyContent, fileData map[string][]byte)
- func (r *ParseContext) ShouldIncludeBlock(block *hcl.Block) bool
- type ParseModFlag
- type ReferenceTypeValueMap
- type WorkspaceProfileParseContext
Constants ¶
This section is empty.
Variables ¶
var BenchmarkBlockSchema = &hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
{Name: "children"},
{Name: "description"},
{Name: "documentation"},
{Name: "tags"},
{Name: "title"},
{Name: "width"},
{Name: "base"},
{Name: "type"},
{Name: "display"},
},
}
var ConfigBlockSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{}, Blocks: []hcl.BlockHeaderSchema{ { Type: "connection", LabelNames: []string{"name"}, }, { Type: "options", LabelNames: []string{"type"}, }, { Type: "workspace", LabelNames: []string{"name"}, }, }, }
var ConnectionBlockSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{ { Name: "plugin", Required: true, }, { Name: "type", }, { Name: "connections", }, }, Blocks: []hcl.BlockHeaderSchema{ { Type: "options", LabelNames: []string{"type"}, }, }, }
var DashboardBlockSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: modconfig.BlockTypeInput, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeParam, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeWith, }, { Type: modconfig.BlockTypeContainer, }, { Type: modconfig.BlockTypeCard, }, { Type: modconfig.BlockTypeChart, }, { Type: modconfig.BlockTypeBenchmark, }, { Type: modconfig.BlockTypeControl, }, { Type: modconfig.BlockTypeFlow, }, { Type: modconfig.BlockTypeGraph, }, { Type: modconfig.BlockTypeHierarchy, }, { Type: modconfig.BlockTypeImage, }, { Type: modconfig.BlockTypeTable, }, { Type: modconfig.BlockTypeText, }, }, }
DashboardBlockSchema is only used to validate the blocks of a Dashboard
var DashboardContainerBlockSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: modconfig.BlockTypeInput, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeParam, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeContainer, }, { Type: modconfig.BlockTypeCard, }, { Type: modconfig.BlockTypeChart, }, { Type: modconfig.BlockTypeBenchmark, }, { Type: modconfig.BlockTypeControl, }, { Type: modconfig.BlockTypeFlow, }, { Type: modconfig.BlockTypeGraph, }, { Type: modconfig.BlockTypeHierarchy, }, { Type: modconfig.BlockTypeImage, }, { Type: modconfig.BlockTypeTable, }, { Type: modconfig.BlockTypeText, }, }, }
DashboardContainerBlockSchema is only used to validate the blocks of a DashboardContainer
var ModBlockSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: modconfig.BlockTypeRequire, }, }, }
ModBlockSchema contains schema for the mod blocks which must be manually decoded
var NodeAndEdgeProviderSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{ {Name: "args"}, }, Blocks: []hcl.BlockHeaderSchema{ { Type: "param", LabelNames: []string{"name"}, }, { Type: "category", LabelNames: []string{"name"}, }, { Type: "with", LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeNode, }, { Type: modconfig.BlockTypeEdge, }, }, }
NodeAndEdgeProviderSchema is used to decode graph/hierarchy/flow (EXCEPT categories)
var ParamDefBlockSchema = &hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
{Name: "description"},
{Name: "default"},
},
}
var QueryProviderBlockSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{ {Name: "args"}, }, Blocks: []hcl.BlockHeaderSchema{ { Type: "param", LabelNames: []string{"name"}, }, { Type: "with", LabelNames: []string{"name"}, }, }, }
QueryProviderBlockSchema schema for all blocks satisfying QueryProvider interface NOTE: these are just the blocks/attributes that are explicitly decoded other query provider properties are implicitly decoded using tags
var RequireBlockSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: modconfig.BlockTypeMod, LabelNames: []string{"name"}, }, }, }
var RequireModBlockSchema = &hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
{Name: "args"},
},
}
var VariableBlockSchema = &hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
{
Name: "description",
},
{
Name: "default",
},
{
Name: "type",
},
{
Name: "sensitive",
},
},
Blocks: []hcl.BlockHeaderSchema{
{
Type: "validation",
},
},
}
var WorkspaceBlockSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{}, Blocks: []hcl.BlockHeaderSchema{ { Type: string(modconfig.BlockTypeMod), LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeVariable, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeQuery, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeControl, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeBenchmark, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeDashboard, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeCard, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeChart, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeFlow, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeGraph, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeHierarchy, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeImage, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeInput, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeTable, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeText, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeNode, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeEdge, LabelNames: []string{"name"}, }, { Type: modconfig.BlockTypeLocals, }, { Type: modconfig.BlockTypeCategory, LabelNames: []string{"name"}, }, }, }
WorkspaceBlockSchema is the top level schema for all workspace resources
var WorkspaceProfileBlockSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: "options", LabelNames: []string{"type"}, }, }, }
Functions ¶
func AddReferences ¶
func AddReferences(resource modconfig.HclResource, block *hcl.Block, parseCtx *ModParseContext) hcl.Diagnostics
AddReferences populates the 'References' resource field, used for the introspection tables
func ContextFunctions ¶
ContextFunctions returns the set of functions that should be used to when evaluating expressions
func DecodeConnection ¶
func DecodeConnection(block *hcl.Block) (*modconfig.Connection, hcl.Diagnostics)
func DecodeOptions ¶
DecodeOptions decodes an options block
func LoadFileData ¶
LoadFileData builds a map of filepath to file data
func LoadWorkspaceProfiles ¶ added in v0.17.0
func LoadWorkspaceProfiles(workspaceProfilePath string) (profileMap map[string]*modconfig.WorkspaceProfile, err error)
func ModfileExists ¶
ModfileExists returns whether a mod file exists at the specified path
func ParseHclFiles ¶
ParseHclFiles parses hcl file data and returns the hcl body object
func ParseMod ¶
func ParseMod(fileData map[string][]byte, pseudoResources []modconfig.MappableResource, parseCtx *ModParseContext) (*modconfig.Mod, *modconfig.ErrorAndWarnings)
ParseMod parses all source hcl files for the mod path and associated resources, and returns the mod object NOTE: the mod definition has already been parsed (or a default created) and is in opts.RunCtx.RootMod
func ParseModDefinition ¶
ParseModDefinition parses the modfile only it is expected the calling code will have verified the existence of the modfile by calling ModfileExists this is called before parsing the workspace to, for example, identify dependency mods
func ParseModResourceNames ¶
func ParseModResourceNames(fileData map[string][]byte) (*modconfig.WorkspaceResources, error)
ParseModResourceNames parses all source hcl files for the mod path and associated resources, and returns the resource names
func ParseQueryInvocation ¶ added in v0.19.0
ParseQueryInvocation parses a query invocation and extracts the args (if any) supported formats are:
1) positional args query.my_prepared_statement('val1','val1')
2) named args query.my_prepared_statement(my_arg1 => 'test', my_arg2 => 'test2')
Types ¶
type ModParseContext ¶ added in v0.17.0
type ModParseContext struct { ParseContext // the mod which is currently being parsed CurrentMod *modconfig.Mod // the workspace lock data WorkspaceLock *versionmap.WorkspaceLock Flags ParseModFlag ListOptions *filehelpers.ListOptions // map of loaded dependency mods, keyed by DependencyPath (including version) // there may be multiple versions of same mod in this map LoadedDependencyMods modconfig.ModMap // Variables is a map of the variables in the current mod // it is used to populate the variables property on the mod Variables map[string]*modconfig.Variable // DependencyVariables is a map of the variables in the dependency mods of the current mod // it is used to populate the variables values on child parseContexts when parsing dependencies // (keyed by mod DependencyPath) DependencyVariables map[string]map[string]*modconfig.Variable ParentParseCtx *ModParseContext // contains filtered or unexported fields }
func NewChildModParseContext ¶ added in v0.20.0
func NewChildModParseContext(parent *ModParseContext, rootEvalPath string) *ModParseContext
func NewModParseContext ¶ added in v0.17.0
func NewModParseContext(workspaceLock *versionmap.WorkspaceLock, rootEvalPath string, flags ParseModFlag, listOptions *filehelpers.ListOptions) *ModParseContext
func (*ModParseContext) AddDependencies ¶ added in v0.17.0
func (m *ModParseContext) AddDependencies(block *hcl.Block, name string, dependencies map[string]*modconfig.ResourceDependency) hcl.Diagnostics
AddDependencies :: the block could not be resolved as it has dependencies 1) store block as unresolved 2) add dependencies to our tree of dependencies
func (*ModParseContext) AddInputVariables ¶ added in v0.17.0
func (m *ModParseContext) AddInputVariables(inputVariables *modconfig.ModVariableMap)
AddInputVariables adds variables to the run context. This function is called for the root run context after loading all input variables
func (*ModParseContext) AddLoadedDependencyMod ¶ added in v0.20.0
func (m *ModParseContext) AddLoadedDependencyMod(mod *modconfig.Mod)
func (*ModParseContext) AddMod ¶ added in v0.17.0
func (m *ModParseContext) AddMod(mod *modconfig.Mod) hcl.Diagnostics
AddMod is used to add a mod to the eval context
func (*ModParseContext) AddResource ¶ added in v0.17.0
func (m *ModParseContext) AddResource(resource modconfig.HclResource) hcl.Diagnostics
AddResource stores this resource as a variable to be added to the eval context.
func (*ModParseContext) AddVariablesToReferenceMap ¶
func (m *ModParseContext) AddVariablesToReferenceMap()
func (*ModParseContext) CreatePseudoResources ¶ added in v0.17.0
func (m *ModParseContext) CreatePseudoResources() bool
CreatePseudoResources returns whether the flag is set to create pseudo resources
func (*ModParseContext) DetermineBlockName ¶ added in v0.17.0
func (m *ModParseContext) DetermineBlockName(block *hcl.Block) string
func (*ModParseContext) EnsureWorkspaceLock ¶ added in v0.17.0
func (m *ModParseContext) EnsureWorkspaceLock(mod *modconfig.Mod) error
func (*ModParseContext) GetCachedBlockName ¶ added in v0.17.0
func (m *ModParseContext) GetCachedBlockName(block *hcl.Block) (string, bool)
func (*ModParseContext) GetCachedBlockShortName ¶ added in v0.17.0
func (m *ModParseContext) GetCachedBlockShortName(block *hcl.Block) (string, bool)
func (*ModParseContext) GetDecodedResourceForBlock ¶ added in v0.17.0
func (m *ModParseContext) GetDecodedResourceForBlock(block *hcl.Block) (modconfig.HclResource, bool)
func (*ModParseContext) GetLoadedDependencyMod ¶ added in v0.20.0
func (m *ModParseContext) GetLoadedDependencyMod(requiredModVersion *modconfig.ModVersionConstraint, mod *modconfig.Mod) (*modconfig.Mod, error)
func (*ModParseContext) GetMod ¶ added in v0.17.0
func (m *ModParseContext) GetMod(modShortName string) *modconfig.Mod
GetMod finds the mod with given short name, looking only in first level dependencies this is used to resolve resource references specifically when the 'children' property of dashboards and benchmarks refers to resource in a dependency mod
func (*ModParseContext) GetResource ¶ added in v0.19.0
func (m *ModParseContext) GetResource(parsedName *modconfig.ParsedResourceName) (resource modconfig.HclResource, found bool)
func (*ModParseContext) GetResourceMaps ¶ added in v0.17.0
func (m *ModParseContext) GetResourceMaps() *modconfig.ResourceMaps
func (*ModParseContext) GetTopLevelDependencyMods ¶ added in v0.20.0
func (m *ModParseContext) GetTopLevelDependencyMods() modconfig.ModMap
GetTopLevelDependencyMods build a mod map of top level loaded dependencies, keyed by mod name
func (*ModParseContext) IsTopLevelBlock ¶ added in v0.17.0
func (m *ModParseContext) IsTopLevelBlock(block *hcl.Block) bool
func (*ModParseContext) PeekParent ¶ added in v0.17.0
func (m *ModParseContext) PeekParent() string
func (*ModParseContext) PopParent ¶ added in v0.17.0
func (m *ModParseContext) PopParent() string
func (*ModParseContext) PushParent ¶ added in v0.17.0
func (m *ModParseContext) PushParent(parent modconfig.ModTreeItem)
func (*ModParseContext) SetCurrentMod ¶ added in v0.20.0
func (m *ModParseContext) SetCurrentMod(mod *modconfig.Mod)
func (*ModParseContext) SetDecodeContent ¶ added in v0.17.0
func (m *ModParseContext) SetDecodeContent(content *hcl.BodyContent, fileData map[string][]byte)
func (*ModParseContext) ShouldCreateDefaultMod ¶ added in v0.17.0
func (m *ModParseContext) ShouldCreateDefaultMod() bool
ShouldCreateDefaultMod returns whether the flag is set to create a default mod if no mod definition exists
type ParseContext ¶ added in v0.17.0
type ParseContext struct { UnresolvedBlocks map[string]*unresolvedBlock FileData map[string][]byte // the eval context used to decode references in HCL EvalCtx *hcl.EvalContext RootEvalPath string // if set, only decode these blocks BlockTypes []string // if set, exclude these block types BlockTypeExclusions []string // contains filtered or unexported fields }
func NewParseContext ¶ added in v0.17.0
func NewParseContext(rootEvalPath string) ParseContext
func (*ParseContext) AddDependencies ¶ added in v0.17.0
func (r *ParseContext) AddDependencies(block *hcl.Block, name string, dependencies map[string]*modconfig.ResourceDependency) hcl.Diagnostics
AddDependencies is called when a block could not be resolved as it has dependencies 1) store block as unresolved 2) add dependencies to our tree of dependencies
func (*ParseContext) BlocksToDecode ¶ added in v0.17.0
func (r *ParseContext) BlocksToDecode() (hcl.Blocks, error)
BlocksToDecode builds a list of blocks to decode, the order of which is determined by the dependency order
func (*ParseContext) ClearDependencies ¶ added in v0.17.0
func (r *ParseContext) ClearDependencies()
func (*ParseContext) EvalComplete ¶ added in v0.17.0
func (r *ParseContext) EvalComplete() bool
EvalComplete returns whether all elements in the dependency tree fully evaluated
func (*ParseContext) FormatDependencies ¶ added in v0.17.0
func (r *ParseContext) FormatDependencies() string
func (*ParseContext) SetDecodeContent ¶ added in v0.17.0
func (r *ParseContext) SetDecodeContent(content *hcl.BodyContent, fileData map[string][]byte)
func (*ParseContext) ShouldIncludeBlock ¶ added in v0.17.0
func (r *ParseContext) ShouldIncludeBlock(block *hcl.Block) bool
type ParseModFlag ¶
type ParseModFlag uint32
const ( CreateDefaultMod ParseModFlag = 1 << iota CreatePseudoResources )
type ReferenceTypeValueMap ¶
ReferenceTypeValueMap is the raw data used to build the evaluation context
When resolving hcl references like : - query.q1 - var.v1 - mod1.query.my_query.sql
ReferenceTypeValueMap is keyed by resource type, then by resource name
type WorkspaceProfileParseContext ¶ added in v0.17.0
type WorkspaceProfileParseContext struct { ParseContext // contains filtered or unexported fields }
func NewWorkspaceProfileParseContext ¶ added in v0.17.0
func NewWorkspaceProfileParseContext(rootEvalPath string) *WorkspaceProfileParseContext
func (*WorkspaceProfileParseContext) AddResource ¶ added in v0.17.0
func (c *WorkspaceProfileParseContext) AddResource(workspaceProfile *modconfig.WorkspaceProfile) hcl.Diagnostics
AddResource stores this resource as a variable to be added to the eval context. It alse
Source Files ¶
- connection.go
- context_functions.go
- decode.go
- decode_args.go
- decode_body.go
- decode_children.go
- decode_mod.go
- decode_options.go
- decode_result.go
- hcl_blocks.go
- installed_mod.go
- metadata.go
- mod_parse_context.go
- mod_parse_context_blocks.go
- parse_context.go
- parser.go
- query_invocation.go
- references.go
- schema.go
- unresolved_block.go
- validate.go
- workspace_profile.go
- workspace_profile_parse_context.go