Define initial config file format

- Users may want to consume pkg/config to generate configuration files.
- This also involved putting config-related utilities in the config
  package for ease of consumption.
- We did not add in versioning into the Config type for now...this is
  something we will likely do in the future, but it is not deemed
  necessary this early in the project.
- The config file format tries to follow the patterns of Kube. One such
  example of this is requiring the use of base64-encoded CA bundle PEM
  bytes instead of a file path. This also slightly simplifies the config
  file handling because we don't have to 1) read in a file or 2) deal
  with the error case of the file not being there.

- The webhook code from k8s.io/apiserver is really exactly what we want
  here. If this dependency gets too burdensome, we can always drop it,
  but the pros outweigh the cons at the moment.
- Writing out a kubeconfig to disk to configure the webhook is a little
  janky, but hopefully this won't hurt performance too much in the year
  2020.

- Also bonus: call the right *Serve*() function when starting our
  servers.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler
2020-07-14 11:50:28 -04:00
parent 5a66b56b93
commit 63f5416b21
11 changed files with 334 additions and 9 deletions
+23
View File
@@ -0,0 +1,23 @@
/*
Copyright 2020 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
*/
package api
// Config contains knobs to setup an instance of placeholder-name.
type Config struct {
WebhookConfig WebhookConfigSpec `json:"webhook"`
}
// WebhookConfig contains configuration knobs specific to placeholder-name's use
// of a webhook for token validation.
type WebhookConfigSpec struct {
// URL contains the URL of the webhook that placeholder-name will use
// to validate external credentials.
URL string `json:"url"`
// CABundle contains PEM-encoded certificate authority certificates used
// to validate TLS connections to the WebhookURL.
CABundle []byte `json:"caBundle"`
}