Skip to content

Commit

Permalink
Add detail on how to configure the webhook path
Browse files Browse the repository at this point in the history
Signed-off-by: Jackline Mutua <[email protected]>
  • Loading branch information
katmutua committed Apr 21, 2022
1 parent a81c519 commit 1096ace
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
37 changes: 9 additions & 28 deletions api/openapi-spec/conventions-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ openapi: 3.0.0
info:
title: Conventions Server API
description: |
This API must be implemented in order to relay conventions to be be applied.
This API defines the expected request and response format from the conventions server. The webhook path can be configured in the ClusterPodConvention
on either .spec.webhook.clientConfig.url or .spec.webhook.clientConfig.service.path with the later preferred if the
convention server is to run on the same cluster as workoads.
version: 1.0.0-alpha.1
license:
name: Apache-2.0
Expand All @@ -17,23 +19,16 @@ paths:
$ref: "#/components/schemas/PodConventionContext"
responses:
200:
description: Return a succes message once all conventions are applied successfully
description: Expected response once all conventions are applied successfully
content:
"application/json":
schema:
$ref: "#/components/schemas/PodConventionContext"
400:
description: Return an error if unable to decode request body into a PodConventionContext type or if request body is nil.
content:
"application/json":
schema:
$ref: "#/components/schemas/ErrorResponse"
500:
description: Internal server error
content:
"application/json":
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Return an error if unable to apply conventions.

components:
schemas:
PodConventionContext:
Expand Down Expand Up @@ -82,12 +77,10 @@ components:
properties:
annotations:
type: object
additionalProperties:
type: string
additionalProperties: true
labels:
type: object
additionalProperties:
type: string
additionalProperties: true
ImageConfig:
type: object
properties:
Expand Down Expand Up @@ -135,16 +128,4 @@ components:
"convention-1",
"convention-2",
"convention-4"
]
Error:
type: object
properties:
message:
type: string
example: "Some unexpected error"

ErrorResponse:
type: object
properties:
error:
$ref: "#/components/schemas/Error"
]
3 changes: 3 additions & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ In the future other mechanisms may be defined to provide conventions other than
#### Webhook Helper Library

Extentions author can define convention by creating a webhook server which is registered with the controller via the `ClusterPodConvention` resource. The webhook server can be written in any programming language. See the [Open API Specification](/api/openapi-spec/conventions-server.yaml) that defines how to to create your own conventions server.

The webhook path can be configured by setting the ClusterPoodConvention's `.spec.webhook.clientConfig.url` or `.spec.webhook.clientConfig.service.path`. If the convention server is to be deployed in the same cluster as your target workloads, then the service path is preferred.

Go developers can use a [helper library](https://pkg.go.dev/github.com/vmware-tanzu/cartographer-conventions/webhook) that streamlines handling the http response for the webhook.

## Lifecycle
Expand Down

0 comments on commit 1096ace

Please sign in to comment.