config

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config holds the operator-supplied registry of webhook-backed resources.

Out of tree, providers cannot register a webhook themselves: kcp's cache server only replicates a hardcoded set of kinds, so a provider-owned CRD carrying webhook configuration would never reach the shard resolving the request. Registration therefore goes through this file, owned by whoever runs the virtual workspace. That is also the de facto authorization gate for the feature.

Index

Constants

View Source
const (
	// Kind is the kind of the configuration document.
	Kind = "EphemeralWebhookConfiguration"

	// APIVersion is the apiVersion of the configuration document.
	APIVersion = "ephemeral.contrib.kcp.io/v1alpha1"

	// DefaultTimeoutSeconds bounds how long the virtual workspace waits for a
	// webhook response when the entry does not say.
	DefaultTimeoutSeconds int32 = 10

	// MaxTimeoutSeconds is the hard cap on webhook timeouts. A slow webhook
	// holds a request goroutine for its whole duration, so this is not
	// negotiable per entry.
	MaxTimeoutSeconds int32 = 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	metav1.TypeMeta `json:",inline"`

	// Resources enumerates the webhook-backed resources this virtual workspace
	// serves.
	Resources []ResourceConfiguration `json:"resources"`
}

Configuration is the root of the configuration file.

func Load

func Load(path string) (*Configuration, error)

Load reads and validates a configuration file.

func (*Configuration) Validate

func (c *Configuration) Validate() field.ErrorList

Validate checks the configuration for internal consistency.

type ExportReference

type ExportReference struct {
	// Path is the logical cluster path the APIExport lives in, e.g.
	// "root:providers:s3".
	Path string `json:"path"`

	// Name is the name of the APIExport.
	Name string `json:"name"`
}

ExportReference points at an APIExport by workspace path and name.

func (ExportReference) String

func (e ExportReference) String() string

type ResourceConfiguration

type ResourceConfiguration struct {
	// Export identifies the APIExport that exposes the resource. The virtual
	// workspace reads the APIResourceSchema referenced by the export's
	// spec.resources entry for Group/Resource, so the schema does not have to be
	// named here.
	Export ExportReference `json:"export"`

	// Group is the API group of the served resource.
	Group string `json:"group"`

	// Resource is the plural resource name of the served resource.
	Resource string `json:"resource"`

	// Webhook describes the endpoint that answers requests for this resource.
	Webhook WebhookConfiguration `json:"webhook"`
}

ResourceConfiguration binds one resource of one APIExport to one webhook.

type WebhookConfiguration

type WebhookConfiguration struct {
	// URL is the HTTPS endpoint to call. Plain http is rejected. There is no
	// service variant: a Service in a logical cluster has no backing endpoints.
	URL string `json:"url"`

	// CABundleFile is a PEM file used to verify the endpoint's serving
	// certificate. Empty means the system trust store.
	//
	// +optional
	CABundleFile string `json:"caBundleFile,omitempty"`

	// ClientCertFile and ClientKeyFile are the client certificate this virtual
	// workspace presents to the webhook.
	//
	// The webhook is told who the user is via request.userInfo, which puts it in
	// the position an aggregated API server is in: it must know the assertion
	// came from a party entitled to make it. Without client authentication,
	// anyone who can reach the endpoint asserts arbitrary identity. Configuring
	// them is strongly recommended and providers should verify the chain, not
	// merely require a certificate.
	//
	// +optional
	ClientCertFile string `json:"clientCertFile,omitempty"`
	// +optional
	ClientKeyFile string `json:"clientKeyFile,omitempty"`

	// TimeoutSeconds bounds how long to wait for a response. Defaults to 10,
	// capped at 30.
	//
	// +optional
	TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
}

WebhookConfiguration describes how to reach a provider's webhook.

func (WebhookConfiguration) Timeout

func (w WebhookConfiguration) Timeout() time.Duration

Timeout returns the effective timeout for this webhook.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL