Capture the binding metadata CF sends - #36
Merged
Conversation
VCAP_SERVICES carries eleven fields per binding; the decoder kept six and silently dropped the rest. syslog_drain_url is the one a user-provided instance depends on -- it is what cf cups -l sets -- and without instance_name there was no way to recover the instance name for a named binding, since Name holds the binding name when one exists. mapstructure does not map snake_case to CamelCase on its own, so each field carries an explicit tag, as volume_mounts already did. Closes #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #25.
The actual gap
The literal question in #25 — "can I read the user-provided env?" — was already
answered by existing behavior:
VCAP_SERVICESunder theuser-providedlabel, soServices.WithLabel("user-provided"),WithNameand
WithTaghave always resolved them.cf set-envare ordinary process environment, alreadyreturned by
CurrentEnv().What was genuinely broken is next door:
VCAP_SERVICEScarries eleven fieldsper binding object and the decoder kept six, silently discarding the rest.
name,label,tags,plan,credentials,volume_mountssyslog_drain_urlSyslogDrainURLinstance_guid,instance_nameInstanceGUID,InstanceNamebinding_guid,binding_nameBindingGUID,BindingNamesyslog_drain_urlis the one a user-provided instance depends on — it is whatcf cups -lsets. Andinstance_namematters becausenameholds the bindingname when a binding has one, so without it there was no way to recover the
instance name for a named binding.
Implementation note
mapstructuredoes not map snake_case onto CamelCase by itself — verified byadding the fields untagged first and watching four of the five stay empty. Each
field therefore carries an explicit tag, as
volume_mountsalready did.The
NameandLabeldoc comments were corrected while here:Nameis thebinding name if the binding has one and otherwise the instance name, and
Labelis the service offering name, which is
user-providedfor a user-providedinstance.
API impact
gorelease -base=v1.20.0:Purely additive.
Verification
make checkclean,make test-racepasseswhere CF omits every new field
Also carries the
changelog.dsweep for the fragments v1.20.0 consumed.