-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Refactor writing of Terraform data sources #14713
Conversation
if s, ok := item.(string); ok { | ||
return terraformWriter.LiteralFromStringValue(s), nil | ||
} | ||
if s, ok := item.(*string); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could probably swap the string
and *string
checks and just fall-through (as we do with reflect.Pointer below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to avoid calling reflect
on strings. But that's an unnecessary micro-optimization.
for _, field := range reflect.VisibleFields(v.Type()) { | ||
key := field.Tag.Get("cty") | ||
if key == "" { | ||
var b strings.Builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe refactor this into its own method, defaultCtyName
or similar, just because it would make this method much easier to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
LGTM. I see the tests are passing. Do we have test coverage on the formatting, or are we testing only after passing through a |
8f91570
to
b9b433a
Compare
b9b433a
to
6c1684d
Compare
The integration tests give us coverage. This particular change is covered by |
/retest |
1 similar comment
/retest |
Thanks @johngmyers - looks great /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.