Blockers/Dependencies
- Blocked on story to add DestinationGUIDs to CFRoute CR
Background
As a client of the API shim
I want to be able to add a destination to a Route
So that I can route traffic to an application
Acceptance Scenarios
GIVEN I have the API shim running locally
THEN I can make perform the following scenarios
Happy Path
GIVEN I have applied a CFRoute CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following request
curl "https://api.example.org/v3/routes/<route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"app": {
"guid": "1cb006ee-fb05-47e1-b541-c34179ddc446"
}
},
{
"app": {
"guid": "01856e12-8ee8-11e9-98a5-bb397dbc818f",
"process": {
"type": "api"
}
},
"port": 9000,
"protocol": "http1"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 200 OK
Content-Type: application/json
{
"destinations": [
{
"guid": "89323d4e-2e84-43e7-83e9-adbf50a20c0e",
"app": {
"guid": "1cb006ee-fb05-47e1-b541-c34179ddc446",
"process": {
"type": "web"
}
},
"weight": null,
"port": 8080,
"protocol": "http1"
},
{
"guid": "fbef10a2-8ee7-11e9-aa2d-abeeaf7b83c5",
"app": {
"guid": "01856e12-8ee8-11e9-98a5-bb397dbc818f",
"process": {
"type": "api"
}
},
"weight": null,
"port": 9000,
"protocol": "http1"
}
],
"links": {
"self": {
"href": "https://api.example.org/v3/routes/cbad697f-cac1-48f4-9017-ac08f39dfb31/destinations"
},
"route": {
"href": "https://api.example.org/v3/routes/cbad697f-cac1-48f4-9017-ac08f39dfb31"
}
}
}
AND I can use kubectl
to view the destinations in the CFRoute
resource.
Route does not exist
GIVEN I have do not have a CFRoute with the GUID below
WHEN I make the following API request
curl "https://api.example.org/v3/routes/<non-existent-route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"app": {
"guid": "1cb006ee-fb05-47e1-b541-c34179ddc446"
}
},
{
"app": {
"guid": "01856e12-8ee8-11e9-98a5-bb397dbc818f",
"process": {
"type": "api"
}
},
"port": 9000,
"protocol": "http1"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 422 Unprocessable Entity
{
"errors": [
{
"detail": "Route is invalid. Ensure it exists and you have access to it.",
"title": "CF-UnprocessableEntity",
"code": 10008
}
]
}
Invalid destination app (missing)
GIVEN I have applied a CFRoute CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following API request
curl "https://api.example.org/v3/routes/<non-existent-route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"port": 9000,
"protocol": "http1"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 422 Unprocessable Entity
{
"errors": [
{
"detail": "Destinations[0]: must have an \"app\".",
"title": "CF-UnprocessableEntity",
"code": 10008
}
]
}
Invalid destination app (missing GUID)
GIVEN I have applied a CFRoute CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following API request
curl "https://api.example.org/v3/routes/<non-existent-route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"app": {}
},
"port": 9000,
"protocol": "http1"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 422 Unprocessable Entity
{
"errors": [
{
"detail": "Destinations[0]: app must have the structure {\"guid\": \"app_guid\"}",
"title": "CF-UnprocessableEntity",
"code": 10008
}
]
}
Invalid destination app (missing process type)
GIVEN I have applied a CFRoute CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following API request
curl "https://api.example.org/v3/routes/<non-existent-route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"app": {
"guid": "01856e12-8ee8-11e9-98a5-bb397dbc818f",
"process": {}
},
"port": 9000,
"protocol": "http1"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 422 Unprocessable Entity
{
"errors": [
{
"detail": "Destinations[0]: process must have the structure {\"type\": \"process_type\"}",
"title": "CF-UnprocessableEntity",
"code": 10008
}
]
}
Invalid destination app (invalid protocol)
GIVEN I have applied a CFRoute CR to the cluster (see cf-k8s-controllers samples)
WHEN I make the following API request
curl "https://api.example.org/v3/routes/<non-existent-route-guid>/destinations" \
-X POST \
-H "Authorization: bearer <some-placeholder-token>" \
-H "Content-type: application/json" \
-d '{
"destinations": [
{
"app": {
"guid": "01856e12-8ee8-11e9-98a5-bb397dbc818f",
"process": {
"type": "api"
}
},
"port": 9000,
"protocol": "http"
}
]
}'
THEN I get a response that looks like the following
HTTP/1.1 422 Unprocessable Entity
{
"errors": [
{
"detail": "Destinations[0]: protocol must be 'http1'",
"title": "CF-UnprocessableEntity",
"code": 10008
}
]
}
Documentation
Document this endpoint in our API docs
Dev Notes