GoogleCloudPlatform/gcp-service-broker

Use VCAP_SERVICES to get the database

Closed this issue · 0 comments

Several customers have the desire to use the broker with databases that are bound to the application via an environment variable injected by CF.

This would allow the customers to provision a database for the broker in a one-click kind of way and would pave the way toward each team installing their own broker that can manage their own projects.

Currently, the broker parses environment variables listed in docs/customization.

There should be an alternate mode where if those variables are not defined and there is a database bound via the VCAP_SERVICES environment variable then the broker should use that instead.

An example of that environment variable is the following: https://docs.pivotal.io/p-mysql/2-6/use.html#vcap

We'll want to search the list for credentials that have a tag of "mysql", fail if we find more or fewer than 1, and use the credentials there. If a URI is supplied, then we should parse it to fill in any missing fields. If the database is one provided by our service broker, we should make sure to also use the client_cert, ca_cert and client_key fields.

The existing code to open a connection to the database is the following: https://github.com/GoogleCloudPlatform/gcp-service-broker/blob/master/db_service/setup_db.go