-
Notifications
You must be signed in to change notification settings - Fork 26
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
Service binding resolver #228
Conversation
ff66737
to
30fc702
Compare
f996636
to
c05d818
Compare
c05d818
to
e8ee253
Compare
4ae6333
to
76b3032
Compare
a2684e5
to
a423807
Compare
3c4cbfb
to
2110375
Compare
b407b4e
to
1015930
Compare
314b163
to
2f961af
Compare
8117e28
to
cb730d7
Compare
a0652fa
to
4340825
Compare
4340825
to
623e6c7
Compare
// 2. CNB_BINDINGS environment variable, if above is not set | ||
// 3. `<platformDir>/bindings`, if both above are not set | ||
func (r *Resolver) Resolve(typ string, provider string, platformDir string) ([]Binding, error) { | ||
if newRoot := bindingRoot(platformDir); r.bindingRoot != newRoot { |
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.
Now that the platform is part of this method: If the binding root changes, we'll refresh and cache new bindings. Note that this implicitly occurs on a new resolver, due to the root being initialized to ""
.
I'm happy with where this is heading now. @sophiewigmore do you have anything else you'd like to see before we think about getting this merged? |
@ryanmoran @sophiewigmore Just let me know before you merge, and I'll clean up the commit history |
@ryanmoran @menehune23 hey y'all. sorry I missed the update earlier. I've been following along with these discussions and this sounds good to me! |
@menehune23 I am still a little unsure about the removal of the |
@ForestEckhardt That's a good point. I'll restore it and its tests until later. |
Signed-off-by: Brayan Henao <bhenao@vmware.com>
d067bbb
to
f9083e4
Compare
Summary
Adds a
servicebindings.Resolver
type which can be used to lazily load and resolve service bindings according to the k8s spec.Implementation notes:
Because the new spec relies on a
$SERVICE_BINDING_ROOT
env var, this PR maintains backwards compatibility by falling back to$CNB_BINDINGS
, then<platform>/bindings
if neither env var is set.Bindings can be read from either the new k8s format or the legacy format.
Rather than providing top-level functions, this PR uses a dedicated type so that consumers can create interfaces for it and also mock/fake it in unit tests to keep them simple (for instance, this eliminates the need to understand the spec's implementation and write files to the filesystem during unit tests that rely on a binding).
Entry values are of a new
io.ReadCloser
-compatible type,Entry
-- rather than simply astring
or[]byte
-- that can stream the entry from the file system. It also supports.ReadString()
and.ReadBytes()
for ease of use. (Credit to @ryanmoran for the great idea).Checklist
Closes #107