Documentation ¶
Index ¶
- func DecodeReferenceOrigins(ctx context.Context, modStore *state.ModuleStore, ...) error
- func DecodeReferenceTargets(ctx context.Context, modStore *state.ModuleStore, ...) error
- func GetModuleDataFromRegistry(ctx context.Context, regClient registry.Client, modStore *state.ModuleStore, ...) error
- func LoadModuleMetadata(ctx context.Context, modStore *state.ModuleStore, modPath string) error
- func ParseModuleConfiguration(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, ...) error
- func PreloadEmbeddedSchema(ctx context.Context, logger *log.Logger, fs fs.ReadDirFS, ...) error
- func ReferenceValidation(ctx context.Context, modStore *state.ModuleStore, ...) error
- func SchemaModuleValidation(ctx context.Context, modStore *state.ModuleStore, ...) error
- func TerraformValidate(ctx context.Context, modStore *state.ModuleStore, modPath string) error
- type ReadOnlyFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeReferenceOrigins ¶
func DecodeReferenceOrigins(ctx context.Context, modStore *state.ModuleStore, rootFeature fdecoder.RootReader, modPath string) error
DecodeReferenceOrigins collects reference origins, using previously parsed AST (via ParseModuleConfiguration), core schema of appropriate version (as obtained via [GetTerraformVersion]) and provider schemas (PreloadEmbeddedSchema or [ObtainSchema]).
For example it tells us that there is a reference address var.foobar at a particular LOC. This can be later matched with targets (as obtained via DecodeReferenceTargets) during hover or go-to-definition.
func DecodeReferenceTargets ¶
func DecodeReferenceTargets(ctx context.Context, modStore *state.ModuleStore, rootFeature fdecoder.RootReader, modPath string) error
DecodeReferenceTargets collects reference targets, using previously parsed AST (via ParseModuleConfiguration), core schema of appropriate version (as obtained via [GetTerraformVersion]) and provider schemas (PreloadEmbeddedSchema or [ObtainSchema]).
For example it tells us that variable block between certain LOC can be referred to as var.foobar. This is useful e.g. during completion, go-to-definition or go-to-references.
func GetModuleDataFromRegistry ¶
func GetModuleDataFromRegistry(ctx context.Context, regClient registry.Client, modStore *state.ModuleStore, modRegStore *globalState.RegistryModuleStore, modPath string) error
GetModuleDataFromRegistry obtains data about any modules (inputs & outputs) from the Registry API based on module calls which were previously parsed via LoadModuleMetadata. The same data could be obtained via [ParseModuleManifest] but getting it from the API comes with little expectations, specifically the modules do not need to be installed on disk and we don't need to parse and decode all files.
func LoadModuleMetadata ¶
LoadModuleMetadata loads data about the module in a version-independent way that enables us to decode the rest of the configuration, e.g. by knowing provider versions, Terraform Core constraint etc.
func ParseModuleConfiguration ¶
func ParseModuleConfiguration(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, modPath string) error
ParseModuleConfiguration parses the module configuration, i.e. turns bytes of `*.tf` files into AST (*hcl.File).
func PreloadEmbeddedSchema ¶
func PreloadEmbeddedSchema(ctx context.Context, logger *log.Logger, fs fs.ReadDirFS, modStore *state.ModuleStore, schemaStore *globalState.ProviderSchemaStore, modPath string) error
PreloadEmbeddedSchema loads provider schemas based on provider requirements parsed earlier via LoadModuleMetadata. This is the cheapest way of getting provider schemas in terms of resources, time and complexity/UX.
func ReferenceValidation ¶
func ReferenceValidation(ctx context.Context, modStore *state.ModuleStore, rootFeature fdecoder.RootReader, modPath string) error
ReferenceValidation does validation based on (mis)matched reference origins and targets, to flag up "orphaned" references.
It relies on DecodeReferenceTargets and DecodeReferenceOrigins to supply both origins and targets to compare.
func SchemaModuleValidation ¶
func SchemaModuleValidation(ctx context.Context, modStore *state.ModuleStore, rootFeature fdecoder.RootReader, modPath string) error
SchemaModuleValidation does schema-based validation of module files (*.tf) and produces diagnostics associated with any "invalid" parts of code.
It relies on previously parsed AST (via ParseModuleConfiguration), core schema of appropriate version (as obtained via [GetTerraformVersion]) and provider schemas (PreloadEmbeddedSchema or [ObtainSchema]).
func TerraformValidate ¶
TerraformValidate uses Terraform CLI to run validate subcommand and turn the provided (JSON) output into diagnostics associated with "invalid" parts of code.