Skip to content

Commit

Permalink
Introduce a new setting for early validation
Browse files Browse the repository at this point in the history
Adds `terraform.validation.earlyValidation` setting to the initializationOptions sent to terraform-ls.

I chose to use `terraform.validation` as we expect to add future settings for this feature.

This relies on functionality to be added to terraform-ls to parse the new setting.
  • Loading branch information
jpogran committed Aug 7, 2023
1 parent c88fa34 commit 245dcea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@
"type": "boolean",
"default": false,
"description": "Display reference counts above top level blocks and attributes."
},
"terraform.validation.earlyValidation": {
"scope": "window",
"type": "boolean",
"default": true,
"description": "Enable early validation of Terraform files and modules"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface InitializationOptions {
experimentalFeatures?: ExperimentalFeatures;
ignoreSingleFileWarning?: boolean;
terraform?: TerraformOptions;
validation?: ValidationOptions;
}

export interface TerraformOptions {
Expand All @@ -28,12 +29,19 @@ export interface ExperimentalFeatures {
prefillRequiredFields: boolean;
}

export interface ValidationOptions {
earlyValidation: boolean;
}

export function getInitializationOptions() {
/*
This is basically a set of settings masquerading as a function. The intention
here is to make room for this to be added to a configuration builder when
we tackle #791
*/
const validation = config('terraform').get<ValidationOptions>('validation', {
earlyValidation: true,
});
const terraform = config('terraform').get<TerraformOptions>('languageServer.terraform', {
path: '',
timeout: '',
Expand All @@ -55,6 +63,7 @@ export function getInitializationOptions() {
}

const initializationOptions: InitializationOptions = {
validation,
experimentalFeatures,
ignoreSingleFileWarning,
terraform,
Expand Down

0 comments on commit 245dcea

Please sign in to comment.