framework

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 5 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewPathMatch(path, trail string, values map[string]string) PathMatch

NewPathMatch returns a PathMatch with the given wildcard values.

func PathMatchFromRequest added in v0.34.0

func PathMatchFromRequest(req *http.Request) PathMatch

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

func (m PathMatch) PrefixToStrip() string

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.

func (PathMatch) Value added in v0.34.0

func (m PathMatch) Value(name string) string

Value returns the segment matched by the named wildcard of the pattern, "" if there is none.

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.

func (ReadyFunc) IsReady

func (r ReadyFunc) IsReady() error

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

func (r RootPathResolverFunc) ResolveRootPath(ctx context.Context, match PathMatch) (accepted bool, prefixToStrip string, completedContext context.Context)

type VirtualWorkspace

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.

Jump to

Keyboard shortcuts

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