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

Add IsSensitive to AttributeSchema #42

Merged
merged 1 commit into from
Jun 2, 2021

Conversation

beandrad
Copy link
Contributor

@beandrad beandrad commented Jun 1, 2021

So that sensitive attributes can be flagged.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

We'll need to reflect this new field also in hover data:

func detailForAttribute(attr *schema.AttributeSchema) string {

Also would you mind adding some test cases for the public CandidatesAtPos here

testCases := []struct {
name string
pos hcl.Pos
expectedCandidates lang.Candidates
}{

and similar for HoverAtPos here

testCases := []struct {
name string
pos hcl.Pos
expectedData *lang.HoverData
}{

One case in each (with sensitive attribute) should suffice; if you want to be thorough you could add one with AttributeSchema where Expr is ObjectExpr with sensitive attribute nested within, although I'm not sure what's the current handling of it as nested expressions aren't well supported yet - but it's still nice to have a test that reflects the current behaviour - and will fail (and be fixed) as part of implementing hashicorp/terraform-ls#496

decoder/attribute_candidates.go Show resolved Hide resolved
@radeksimko
Copy link
Member

As per conversation in hashicorp/terraform-schema#49 (comment) we should also add some tests which test AttributeSchema with no explicit required/optional during completion or hover. I think the validation should keep reporting it as failure/error, but we can treat it as "soft enforcement" for pragmatic reasons, so the decoder should account for this edge case and test for it.

So that sensitive attributes can be flagged.
@beandrad beandrad force-pushed the ia.sensitive-attr branch from 34f98c4 to b631d54 Compare June 2, 2021 11:32
if attr.IsRequired {
detail = "Required"
details = append(details, "required")
Copy link
Member

Choose a reason for hiding this comment

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

This is a reasonable change, but just FYI there will be some existing test data in the need of update potentially in terraform-schema and in terraform-ls 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds exciting 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants