-
Notifications
You must be signed in to change notification settings - Fork 5
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
fields: parse tagged fields in struct values and apply secrets to them #80
Conversation
54a9141
to
9646968
Compare
fields/example_test.go
Outdated
} | ||
defer st.Close() | ||
|
||
// Apply the requested secrets to the fields. |
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, having it as a separate package makes for an unfortunate 3-step dance to discover, register, then install the secrets. But I can't think of a better way that doesn't pull reflect sadness into the main setec client library...
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.
Based on our discussion in Slack, I reworked this a bit along that suggestion.
// tagged name, separated with a slash ("/"). | ||
// | ||
// See [Fields] for a description of the struct tags and types recognized. | ||
func ParseFields(v any, namePrefix string) (*Fields, error) { |
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.
Deliberately still exported? The example seems to point to usage that doesn't require the machinery to be exposed. Or are we keeping it as an alternative way to do this?
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 left it exported so that you can still apply secrets to a struct even if that struct isn't available when the store is constructed. I reworked the examples and the docs to focus on the pre-declared case, but in some of our existing use we wouldn't be able to do this, because we don't get the struct until later.
Given a pointer to a struct with specially-tagged fields, use reflection to locate these fields and plumb secrets from a setec.Store into them.
0641a00
to
36230c7
Compare
Given a pointer to a struct with specially-tagged fields, use reflection to
locate these fields and plumb secrets from a setec.Store into them.