-
Notifications
You must be signed in to change notification settings - Fork 94
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
Create diag package and switch all applicable []tfprotov6.Diagnostic usage #110
Conversation
6c2a877
to
fcb754d
Compare
// | ||
// Usage of this method outside the framework is not supported nor considered | ||
// for backwards compatibility promises. | ||
func (diags Diagnostics) ToTfprotov6Diagnostics() []*tfprotov6.Diagnostic { |
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.
two things:
- This doesn't appear to require any privileged access to the
diag
package or benefit from being a method on theDiagnostics
type. Is there a reason we shouldn't just make it a function intfsdk
? - I think
Tfprotov6
in this may be unnecessarily verbose.ToProto6Diagnostics
is probably sufficient; we know which protocol we're talking about, and we're unlikely to be talking about any other protocol's diagnostics except Terraform's.
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.
This doesn't appear to require any privileged access to the diag package or benefit from being a method on the Diagnostics type. Is there a reason we shouldn't just make it a function in tfsdk?
It does keep the diagnostics implementation altogether.
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.
Hm. Is that worth having an exported method we don't want people to call? 🤔 (I don't know the answer, I'm wondering out loud.)
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.
Another option here would be to move that exported function into a separate internal
package, maybe along the lines of diag/internal/convert
. I'd be more apt to do this so at least the code is tangential the other diagnostics code. I'd be worried about import cycles if we tried to setup something more generic like internal/toproto6
.
@kmoe do you have any opinions?
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'd still prefer this to be unexported as we don't expect provider developers to use it, and I'm worried about what they'll do with this unintended compatibility interface, but I'm not gonna hold this up over it.
faa9b33
to
9da1f1b
Compare
Rebased after #102 |
22441b3
to
cdee112
Compare
…except where interfacing directly with the underlying protocol type
Co-authored-by: Paddy <paddy@hashicorp.com>
cdee112
to
9517ae4
Compare
Co-authored-by: Paddy <paddy@hashicorp.com>
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.
This looks good to me. Great work, @bflad. 🚀
return resp, nil | ||
} | ||
|
||
// validateProviderConfigResponse is a thin abstraction to allow native Diagnostics usage |
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.
nitpick: ideally we'd call out why this allows native Diagnostics usage, but we can fast-follow with that.
* Don't recursively validate SingleNestedAttribute if it is Null. * Add CHANGELOG entry. * Use 'o.Null' check. * Also check for 'o.Unknown'. * Update .changelog/118.txt Co-authored-by: Paddy <paddy@carvers.co> * Use diag package helpers (#110). Co-authored-by: Paddy <paddy@carvers.co>
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. |
Pending #108
Closes #24
This is an implementation of diagnostics as an interface type. It is intended to serve as a discussion starting point and may be thrown away or updated depending on the outcomes of #108.