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

Consider removing constraints from collected ref. origins #269

Open
3 tasks
radeksimko opened this issue Apr 25, 2023 · 0 comments
Open
3 tasks

Consider removing constraints from collected ref. origins #269

radeksimko opened this issue Apr 25, 2023 · 0 comments

Comments

@radeksimko
Copy link
Member

Context

Currently we collect constraints closest to the reference. For example, given attribute schema

{

	"foo": &schema.AttributeSchema{
		Constraint:  schema.LiteralType{Type: cty.List(cty.String)},
		IsOptional:  true,
	}
}

and relevant config

foo = [var.bar]

we collect var.bar as origin with cty.String constraint.

This enables us to be more precise when matching origins against targets, i.e. we can filter out any clear mismatches, such as if var.bar of type cty.Map().

The benefit of such accurate matching was questioned from both UX and maintenance burden perspective.

// Constraints represents any traversal expression constraints
// for the attribute where the origin was found.
//
// Further matching against decoded reference targets is needed
// for >1 constraints, which is done later at runtime as
// targets and origins can be decoded at different times.
Constraints OriginConstraints

Importantly we still need to distinguish between type-less and type-aware references, such as

depends_on = [ aws_instance.foo ]

VS

value = aws_instance.foo # object

but we should be able to still do that without having to distinguish between different types. i.e. it should be sufficient to know that a reference is type-aware, but not what exact type it is.

Proposal

  • Loosen up origin/target matching logic to avoid type matching
  • Expose this under feature toggle to all users, first opt-in, then opt-out
  • Remove matching logic and OriginConstraints entirely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant