hashicorp / hc-install

Go module for downloading or locating HashiCorp binaries, verifying signatures and checksums, and asserting version constraints.

Home Page:https://pkg.go.dev/github.com/hashicorp/hc-install

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Add `String` function to `src.Source`s

gdavison opened this issue · comments

It would be useful to have a String function that describes src.Sources. One use is in cases such as hashicorp/terraform-plugin-testing#133, where they are logged or displayed to users

I'm not opposed to the idea of adding String functions, but from what I can tell by reading the original linked issue, the real problem is usefulness of error types/messages, is it not?

So maybe we should ensure that errors returned from Ensure, Install and Remove, i.e. all essential methods on the Installer are wrapped in a custom error type, which also exposes what source produced that error?

The friction point I see with implementing String() is that it will be difficult to come up with an implementation that satisfies completeness and/or readability in all contexts.

cc @austinvalle

I'm not opposed to the idea of adding String functions, but from what I can tell by reading the original linked issue, the real problem is usefulness of error types/messages, is it not?

Yes, that was the root problem we were looking at. I think exposing the source via a custom error, as you mentioned, would be good, however, if the errors are detailed enough that information may not be needed.

I didn't run into any particular errors from a source that were confusing so I'd be hesitant to suggest a change to hc-install without more detail.