This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add resource package #878
Add resource package #878
Changes from all commits
e71bc5a
4b3bba9
361940e
2e51332
06fb0e2
8bc50df
41841a5
0222b25
90b9980
3b6d965
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Do you need this to be public (exported)?
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.
It's not used internally at all, so it's only here for public use. Seemed good to have and we already have a use case with the tool that runs discoveries and produces envvars.
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.
You can document that most users will depend on FromEnv in the godoc.
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.
In which one? Seems odd to document that getter X will be used more frequently in the docstring of a encoder.
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.
Documenting what most users might prefer in godoc is a style we often use at Google and elsewhere. We don't have to do it, I just want users to have an easier time finding an entry point.
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.
Same comment about public.
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.
Since we have
EncodeLabels
public, it seems to make sense to have the symmetric encoding function as well.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 think there's an argument to make both EncodeLabels and DecodeLabels private and just document the expected format in the FromEnv godoc: How do we expect users to use EncodeLabels? Won't they usually just set environment variables in something like a k8s yaml file or shell script? If so, how does it help to have a Go function exported?
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.
We already have a use case for
EncodeLabels
here. I think it is a very legitimate one and the Encode/Decode symmetry should generally be given.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.
If EnvVarType is empty, wouldn't it make more sense to return a
nil
resource here?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.
The type is not mandatory per our specs so I don't think we necessarily have to handle it specially here.
In general the empty resource is equivalent to the unset resource. Just that an empty struct requires less special handling by the caller, which seems preferable.