Documentation
¶
Overview ¶
Package framework provides a the required interfaces, structs and generic implementation that allow creating kcp virtual workspaces with a minimal amount of work.
To create virtual workspaces you have to:
- define the implementation of the VirtualWorkspaces you want to expose (for example with utilities found in the `fixedgvs` or `dynamic` packages)
- define the sub-command that will expose the related CLI arguments, Bootstrap and start those VirtualWorkspaces.
Index ¶
Constants ¶
const ( // ClusterWildcard names the http.ServeMux wildcard of a virtual workspace path pattern that holds the logical cluster. ClusterWildcard = "cluster" // TrailWildcard names the http.ServeMux wildcard holding the kube-like API path after the virtual workspace path pattern. TrailWildcard = "trail" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PathMatch ¶ added in v0.34.0
type PathMatch struct {
// Path is the full request path.
Path string
// Trail is the kube-like API path after the pattern, "" if none.
Trail string
// contains filtered or unexported fields
}
PathMatch is a parsed request path.
Virtual workspaces registers in the framework with http.ServeMux patterns like this:
/services/apiexport/{exportCluster}/{exportName}/clusters/{cluster}
The framework registers each pattern once by itself and once with a trail wildcard.
A request with this path and the above pattern:
/services/apiexport/root:providers/widgets/clusters/root:org/apis/example.io/v1/widgets
Is parsed into a PathMatch like this:
Path: "/services/apiexport/root:providers/widgets/clusters/root:org/apis/example.io/v1/widgets"
Trail: "apis/example.io/v1/widgets"
Value("exportCluster"): "root:providers"
Value("exportName"): "widgets"
Value(ClusterWildcard): "root:org"
PrefixToStrip(): "/services/apiexport/root:providers/widgets/clusters/root:org"
For tests the NewPathMatch function can be used to build a valid PathMatch.
func NewPathMatch ¶ added in v0.34.0
NewPathMatch returns a PathMatch with the given wildcard values.
func PathMatchFromRequest ¶ added in v0.34.0
PathMatchFromRequest returns the PathMatch of a request routed by a http.ServeMux pattern with a trailing TrailWildcard.
func (PathMatch) PrefixToStrip ¶ added in v0.34.0
PrefixToStrip returns the path up to the trail, without the separator, the default prefix to strip before delegating to the virtual workspace. A path ending in the separator keeps it as the remaining path.
type ReadyChecker ¶
type ReadyChecker interface {
IsReady() error
}
type ReadyFunc ¶
type ReadyFunc func() error
ReadyFunc is the type of readiness check functions exposed by types implementing the VirtualWorkspace interface.
type RootPathResolver ¶
type RootPathResolver interface {
// ResolveRootPath returns whether the request should be accepted and served by a given VirtualWorkspace.
//
// match holds the wildcards of the virtual workspace's path pattern;
// the logical cluster named by ClusterWildcard is already set on ctx.
//
// If accepted, prefixToStrip is the prefix in front of the kube-like API
// surface (including `/clusters/<something>`), usually match.PrefixToStrip().
// E.g. for
//
// /services/initializingworkspaces/<initializer>/clusters/<something>/apis/workload.kcp.io/v1alpha1/synctargets
//
// the prefixToStrip is `/services/initializingworkspaces/<initializer/clusters/<something>`.
//
// Depending on virtual workspace type, the returned context holds e.g. the APIDomainKey
// or other values like scope, if that is part of the URL path.
ResolveRootPath(ctx context.Context, match PathMatch) (accepted bool, prefixToStrip string, completedContext context.Context)
}
type RootPathResolverFunc ¶
type RootPathResolverFunc func(ctx context.Context, match PathMatch) (accepted bool, prefixToStrip string, completedContext context.Context)
RootPathResolverFunc adapts a function to RootPathResolver.
func (RootPathResolverFunc) ResolveRootPath ¶
type VirtualWorkspace ¶
type VirtualWorkspace interface {
authorizer.Authorizer
admission.Mutator
admission.Validator
RootPathResolver
ReadyChecker
Register(name string, rootAPIServerConfig genericapiserver.CompletedConfig, delegateAPIServer genericapiserver.DelegationTarget) (genericapiserver.DelegationTarget, error)
}
VirtualWorkspace is the definition of a virtual workspace that will be registered and made available, at a given prefix, inside a Root API server as a delegated API Server.
It will be implemented by several types of virtual workspaces.
One example is the FixedGroupVersionsVirtualWorkspace located in the fixedgvs package, which allows adding well-defined APIs in a limited number of group/versions, implemented as Rest storages.