Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce validation of *.tfvars files #1413

Merged
merged 3 commits into from
Sep 25, 2023

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Sep 19, 2023

Depends on:

Closes #1410


UX Examples

Screenshot 2023-09-19 at 09 47 37 Screenshot 2023-09-19 at 09 48 31

@@ -988,7 +988,7 @@ func (s *ModuleStore) SetModuleDiagnosticsState(path string, source ast.Diagnost
func (s *ModuleStore) UpdateVarsDiagnostics(path string, source ast.DiagnosticSource, diags ast.VarsDiags) error {
txn := s.db.Txn(true)
txn.Defer(func() {
s.SetVarsDiagnosticsState(path, ast.HCLParsingSource, op.OpStateLoaded)
s.SetVarsDiagnosticsState(path, source, op.OpStateLoaded)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct source is already being passed in

sErr = modStore.UpdateVarsDiagnostics(modPath, ast.HCLParsingSource, diags)
so this seems to be just a bug which was never surfaced as we never had any other sources up to this point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@radeksimko radeksimko marked this pull request as ready for review September 21, 2023 12:09
@radeksimko radeksimko requested a review from a team as a code owner September 21, 2023 12:09
Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -988,7 +988,7 @@ func (s *ModuleStore) SetModuleDiagnosticsState(path string, source ast.Diagnost
func (s *ModuleStore) UpdateVarsDiagnostics(path string, source ast.DiagnosticSource, diags ast.VarsDiags) error {
txn := s.db.Txn(true)
txn.Defer(func() {
s.SetVarsDiagnosticsState(path, ast.HCLParsingSource, op.OpStateLoaded)
s.SetVarsDiagnosticsState(path, source, op.OpStateLoaded)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@radeksimko radeksimko merged commit daaa726 into f-early-validation Sep 25, 2023
21 checks passed
@radeksimko radeksimko deleted the f-validation-tfvars branch September 25, 2023 09:59
dbanck pushed a commit that referenced this pull request Sep 27, 2023
* Introduce validation of tfvars files

* clarify existing job name/type

* add tests
dbanck pushed a commit that referenced this pull request Sep 28, 2023
* Introduce validation of tfvars files

* clarify existing job name/type

* add tests
dbanck added a commit that referenced this pull request Sep 28, 2023
* Introduce a new setting for early validation (#1353)

Adds `validation.earlyValidation` as a new setting.

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

* Introduce a new job for running early validation (#1346)

* Implement unreferenced variable validation (#1357)

Add the ability to use the collected origin and target references in early validation by providing a hook for validation funcs. This also adds a validator for unreferenced variables.

Validation funcs will be provided by terraform-ls for now, but may be moved into hcl-lang in the future.

* Introduce ValidationDiagnostics field to module

* Publish early validation diagnostics

* Include validation diagnotics in changes check

* Introduce early validation job

* Check ValidationDiagnosticsState when running validation

* Run early validation job after collection jobs

* Bump hcl-lang to `b6a3f8`

* Update internal/terraform/module/module_ops.go

Co-authored-by: Radek Simko <radek.simko@gmail.com>

---------

Co-authored-by: James Pogran <jpogran@outlook.com>
Co-authored-by: Radek Simko <radek.simko@gmail.com>

* Centralize diagnostics publishing (#1361)

* Introduce different source for diagnostics

* Add reference validation job

* Run terraform validate as a job

* Track validation job states

* Review feedback

* Pass pathCtx to reference validation funcs

* Rename early validation job

* Bump hcl-lang to `29034e`

* Introduce VarsDiagnosticsState

* Fix tests

* Check early validation setting before scheduling jobs (#1363)

* Introduce new context for valiation settings

* Check context before scheduling jobs

* Only validate a single file on `didChange` (#1370)

* Introduce new RPCContextData for storing rpc info

* Attach RPCContextData to jobs

* Add RPCContextData to walker ctx, fix params

* Check RPCContext on SchemaValidation

* Bump hcl-lang to `485c60`

* Review feedback

* Add progress reporting for Terraform validate (#1373)

* validations: Limit ref. validation to only LocalOrigin(s) (#1379)

* validations: Limit ref. validation to only LocalOrigin(s)

* validations: add test for disabled origins

* validations: Validate only first 2 segments of a reference (#1380)

* validations: Enable reference validation of locals (#1381)

* validations: Enable reference validation of locals

* Update internal/decoder/validations/unreferenced_origin.go

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

* fix imports

---------

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

* decoder: Update comments about validation of other Origin types (#1396)

* Update diagnostic source to `Terraform` (#1399)

* early validation - bump `hcl-lang` and reflect upstream changes (#1416)

* deps: bump hcl-lang to aa9b38d (#1414)

* re-define decoupled validators

* Introduce validation of `*.tfvars` files (#1413)

* Introduce validation of tfvars files

* clarify existing job name/type

* add tests

* Fix delayed diagnostics / job ordering (#1417)

* Move everything into defer

* Add comment about lsctx

* Have module registry job depend on module metadata

* Fix RPCContext related test failures

---------

Co-authored-by: James Pogran <jpogran@outlook.com>
Co-authored-by: Radek Simko <radek.simko@gmail.com>
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
diagnostics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants