Documentation ¶
Index ¶
- func DecodeReferenceOrigins(ctx context.Context, modStore *state.ModuleStore, ...) error
- func DecodeReferenceTargets(ctx context.Context, modStore *state.ModuleStore, ...) error
- func DecodeVarsReferences(ctx context.Context, modStore *state.ModuleStore, ...) error
- func GetModuleDataFromRegistry(ctx context.Context, regClient registry.Client, modStore *state.ModuleStore, ...) error
- func GetTerraformVersion(ctx context.Context, modStore *state.ModuleStore, modPath string) error
- func IsModuleNotFound(err error) bool
- func IsTerraformNotFound(err error) bool
- func LoadModuleMetadata(ctx context.Context, modStore *state.ModuleStore, modPath string) error
- func ObtainSchema(ctx context.Context, modStore *state.ModuleStore, ...) error
- func ParseModuleConfiguration(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, ...) error
- func ParseModuleManifest(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, ...) error
- func ParseProviderVersions(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, ...) error
- func ParseVariables(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 SchemaVariablesValidation(ctx context.Context, modStore *state.ModuleStore, ...) error
- func TerraformExecPath(ctx context.Context) (string, error)
- func TerraformExecutorForModule(ctx context.Context, modPath string) (exec.TerraformExecutor, error)
- func TerraformValidate(ctx context.Context, modStore *state.ModuleStore, modPath string) error
- type DeferFunc
- type ModuleNotFoundErr
- type ModuleOperation
- type NoTerraformExecPathErr
- type ReadOnlyFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeReferenceOrigins ¶ added in v0.19.0
func DecodeReferenceOrigins(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, 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 ¶ added in v0.18.2
func DecodeReferenceTargets(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, 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 DecodeVarsReferences ¶ added in v0.26.0
func DecodeVarsReferences(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, modPath string) error
DecodeVarsReferences collects reference origins within variable files (*.tfvars) where each valid attribute (as informed by schema provided via LoadModuleMetadata) is considered an origin.
This is useful in hovering over those variable names, go-to-definition and go-to-references.
func GetModuleDataFromRegistry ¶ added in v0.29.0
func GetModuleDataFromRegistry(ctx context.Context, regClient registry.Client, modStore *state.ModuleStore, modRegStore *state.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 GetTerraformVersion ¶
GetTerraformVersion obtains "installed" Terraform version which can inform what version of core schema to pick. Knowing the version is not required though as we can rely on the constraint in `required_version` (as parsed via LoadModuleMetadata and compare it against known released versions.
func IsModuleNotFound ¶
func IsTerraformNotFound ¶ added in v0.14.0
func LoadModuleMetadata ¶ added in v0.16.0
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 ObtainSchema ¶
func ObtainSchema(ctx context.Context, modStore *state.ModuleStore, schemaStore *state.ProviderSchemaStore, modPath string) error
ObtainSchema obtains provider schemas via Terraform CLI. This is useful if we do not have the schemas available from the embedded FS (i.e. in PreloadEmbeddedSchema).
func ParseModuleConfiguration ¶ added in v0.18.0
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 ParseModuleManifest ¶
func ParseModuleManifest(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, modPath string) error
ParseModuleManifest parses the "module manifest" which contains records of installed modules, e.g. where they're installed on the filesystem. This is useful for processing any modules which are not local nor hosted in the Registry (which would be handled by GetModuleDataFromRegistry).
func ParseProviderVersions ¶ added in v0.29.0
func ParseProviderVersions(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, modPath string) error
ParseProviderVersions is a job complimentary to ObtainSchema in that it obtains versions of providers/schemas from Terraform CLI's lock file.
func ParseVariables ¶ added in v0.18.0
func ParseVariables(ctx context.Context, fs ReadOnlyFS, modStore *state.ModuleStore, modPath string) error
ParseVariables parses the variables configuration, i.e. turns bytes of `*.tfvars` files into AST (*hcl.File).
func PreloadEmbeddedSchema ¶ added in v0.29.3
func PreloadEmbeddedSchema(ctx context.Context, logger *log.Logger, fs fs.ReadDirFS, modStore *state.ModuleStore, schemaStore *state.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 ¶ added in v0.32.0
func ReferenceValidation(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, 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 ¶ added in v0.32.0
func SchemaModuleValidation(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, 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 SchemaVariablesValidation ¶ added in v0.32.0
func SchemaVariablesValidation(ctx context.Context, modStore *state.ModuleStore, schemaReader state.SchemaReader, modPath string) error
SchemaVariablesValidation does schema-based validation of variable files (*.tfvars) and produces diagnostics associated with any "invalid" parts of code.
It relies on previously parsed AST (via ParseVariables) and schema, as provided via LoadModuleMetadata).
func TerraformExecPath ¶ added in v0.14.0
func TerraformValidate ¶ added in v0.32.0
TerraformValidate uses Terraform CLI to run validate subcommand and turn the provided (JSON) output into diagnostics associated with "invalid" parts of code.
Types ¶
type ModuleNotFoundErr ¶
type ModuleNotFoundErr struct {
Dir string
}
func (*ModuleNotFoundErr) Error ¶
func (e *ModuleNotFoundErr) Error() string
type ModuleOperation ¶
type ModuleOperation struct { ModulePath string Type op.OpType Defer DeferFunc // contains filtered or unexported fields }
func NewModuleOperation ¶
func NewModuleOperation(modPath string, typ op.OpType) ModuleOperation
type NoTerraformExecPathErr ¶ added in v0.14.0
type NoTerraformExecPathErr struct{}
func (NoTerraformExecPathErr) Error ¶ added in v0.14.0
func (NoTerraformExecPathErr) Error() string