環境變量VCAP_SERVICES
中的值將是您需要解析的JSON字符串,它將爲您提供一個描述所有綁定服務的對象,其中包括名稱,標籤和計劃等數據。如果您的Google「vcap服務」或「雲代工環境變量」的第一個結果是this doc,並且它有一個section on VCAP_SERVICES
。下面是他們提供的這是什麼JSON對象看起來像(後解析)的例子:
{
"elephantsql": [
{
"name": "elephantsql-c6c60",
"label": "elephantsql",
"tags": [
"postgres",
"postgresql",
"relational"
],
"plan": "turtle",
"credentials": {
"uri": "postgres://seilbmbd:[email protected]:5432/seilbmbd"
}
}
],
"sendgrid": [
{
"name": "mysendgrid",
"label": "sendgrid",
"tags": [
"smtp"
],
"plan": "free",
"credentials": {
"hostname": "smtp.sendgrid.net",
"username": "QvsXMbJ3rK",
"password": "HCHMOYluTv"
}
}
]
}