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

Create diag package and switch all applicable []tfprotov6.Diagnostic usage #110

Merged
merged 14 commits into from
Sep 3, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Aug 18, 2021

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.

@bflad bflad added the enhancement New feature or request label Aug 18, 2021
@bflad bflad force-pushed the bflad-f-diagnostics branch 2 times, most recently from 6c2a877 to fcb754d Compare August 18, 2021 19:24
bflad added a commit that referenced this pull request Aug 18, 2021
@paddycarver paddycarver added this to the v0.3.0 milestone Aug 30, 2021
diag/attribute_error_diagnostic.go Show resolved Hide resolved
diag/attribute_error_diagnostic.go Outdated Show resolved Hide resolved
diag/diagnostic.go Outdated Show resolved Hide resolved
diag/diagnostic.go Outdated Show resolved Hide resolved
diag/diagnostic.go Outdated Show resolved Hide resolved
diag/diagnostics.go Show resolved Hide resolved
//
// Usage of this method outside the framework is not supported nor considered
// for backwards compatibility promises.
func (diags Diagnostics) ToTfprotov6Diagnostics() []*tfprotov6.Diagnostic {
Copy link
Contributor

Choose a reason for hiding this comment

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

two things:

  1. 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?
  2. 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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.)

Copy link
Contributor Author

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?

Copy link
Contributor

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.

bflad added a commit that referenced this pull request Sep 1, 2021
@bflad bflad force-pushed the bflad-f-diagnostics branch from faa9b33 to 9da1f1b Compare September 1, 2021 14:06
@bflad
Copy link
Contributor Author

bflad commented Sep 1, 2021

Rebased after #102

bflad added a commit that referenced this pull request Sep 1, 2021
@bflad bflad force-pushed the bflad-f-diagnostics branch from 22441b3 to cdee112 Compare September 1, 2021 17:29
@bflad bflad force-pushed the bflad-f-diagnostics branch from cdee112 to 9517ae4 Compare September 1, 2021 17:42
@bflad bflad marked this pull request as ready for review September 2, 2021 15:24
@bflad bflad requested a review from a team September 2, 2021 15:24
.changelog/110.txt Outdated Show resolved Hide resolved
@bflad bflad requested review from kmoe and paddycarver September 3, 2021 12:10
Copy link
Contributor

@paddycarver paddycarver left a 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
Copy link
Contributor

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.

@paddycarver paddycarver merged commit 7055f97 into main Sep 3, 2021
@paddycarver paddycarver deleted the bflad-f-diagnostics branch September 3, 2021 20:22
paddycarver added a commit that referenced this pull request Sep 8, 2021
* 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>
@github-actions
Copy link

github-actions bot commented Oct 4, 2021

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 Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define Diagnostics type and helpers.
3 participants