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 separate testing scope for reference validation #33339

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

liamcervante
Copy link
Member

@liamcervante liamcervante commented Jun 9, 2023

We need to reference outputs and check blocks from the testing scope. This PR introduces a separate function for parsing referencing that can be called from within the testing context. It also updates the existing functions that create hcl.EvalContext objects so they now accept a function to parse references as part of their signature. This way callers can customise the scope by providing their own list of acceptable references via the parse references function.

A follow up PR will actually use the new functionality from the testing scope. I've split those up to keep reviewing things as easy as possible. This means this PR is essentially a refactor, with no behaviour change or new functionality introduced.

This PR:

  • Adds GetOutput and GetCheckBlock functions to the lang.Data interface.
  • Marks addrs.OutputValue as referenceable
  • Adds a new ParseRef function that retrieves a different set of references for within the testing scope
  • Updates the lang.Scope struct to dynamically retrieve different references based on the caller, so the testing scope and main context scope can be different.

type OutputValue struct {
referenceable
Copy link
Member

Choose a reason for hiding this comment

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

I cannot find any cases of this, but something to look out for is code which is meant to exclude things like outputs by checking if the address is referenceable.

@liamcervante liamcervante merged commit 212ae6c into main Jun 28, 2023
@liamcervante liamcervante deleted the liamcervante/testing-scope-one branch June 28, 2023 07:47
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

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 contributions.
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 Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants