kcp

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWorkspacePollInterval is the default interval for polling kcp workspaces
	DefaultWorkspacePollInterval = 60 * time.Second
	// DefaultWorkspaceDebounceWindow is the default debounce window for workspace changes
	DefaultWorkspaceDebounceWindow = 5 * time.Second
)

Variables

View Source
var WorkspaceGVR = schema.GroupVersionResource{
	Group:    "tenancy.kcp.io",
	Version:  "v1alpha1",
	Resource: "workspaces",
}

WorkspaceGVR is the GroupVersionResource for kcp workspaces.

Functions

func ConstructWorkspaceURL

func ConstructWorkspaceURL(baseURL, workspace string) string

ConstructWorkspaceURL builds a full kcp server URL for a workspace.

func DiscoverAllWorkspaces

func DiscoverAllWorkspaces(
	ctx context.Context,
	baseRestConfig *rest.Config,
	rootWorkspace string,
) ([]string, error)

DiscoverAllWorkspaces discovers all workspaces starting from a root workspace. It returns a slice of all discovered workspace paths.

func DiscoverWorkspacesRecursive

func DiscoverWorkspacesRecursive(
	ctx context.Context,
	baseRestConfig *rest.Config,
	parentWorkspace string,
	discovered map[string]bool,
) error

DiscoverWorkspacesRecursive recursively discovers child workspaces starting from a parent workspace. It populates the discovered map with all found workspace paths. The function creates dynamic clients for each workspace and queries the kcp tenancy API.

func ExtractWorkspaceFromURL

func ExtractWorkspaceFromURL(serverURL string) string

ExtractWorkspaceFromURL returns the workspace name from a full kcp URL.

func ParseServerURL

func ParseServerURL(serverURL string) (baseURL, workspace string)

ParseServerURL extracts the base server URL and workspace path from a kcp server URL. Example: "https://10.95.33.40:6443/clusters/root" -> ("https://10.95.33.40:6443", "root")

Types

type Kcp

type Kcp struct {
	// contains filtered or unexported fields
}

Kcp provides operations for interacting with kcp workspaces.

func NewKcp

func NewKcp(kubernetes Kubernetes) *Kcp

NewKcp creates a new Kcp instance.

func (*Kcp) DescribeWorkspace

func (k *Kcp) DescribeWorkspace(ctx context.Context, name string) (map[string]any, error)

DescribeWorkspace returns detailed information about a specific kcp workspace.

func (*Kcp) ListWorkspaces

func (k *Kcp) ListWorkspaces(ctx context.Context) ([]string, error)

ListWorkspaces returns all available kcp workspaces discovered recursively from the current workspace.

type Kubernetes

type Kubernetes interface {
	RESTConfig() *rest.Config
	DynamicClient() dynamic.Interface
}

Kubernetes defines the minimal interface required for kcp operations.

type WorkspaceWatcher

type WorkspaceWatcher struct {
	// contains filtered or unexported fields
}

WorkspaceWatcher watches for changes in kcp workspaces by polling the tenancy API.

func NewWorkspaceWatcher

func NewWorkspaceWatcher(dynamicClient dynamic.Interface, rootWorkspace string) *WorkspaceWatcher

NewWorkspaceWatcher creates a new workspace watcher that polls the kcp tenancy API for workspace changes.

func (*WorkspaceWatcher) Close

func (w *WorkspaceWatcher) Close()

Close stops the workspace watcher and cleans up resources.

func (*WorkspaceWatcher) Watch

func (w *WorkspaceWatcher) Watch(onChange func() error)

Watch starts watching for workspace changes. The onChange callback is called when workspace changes are detected after debouncing. This can only be called once per WorkspaceWatcher instance.

Jump to

Keyboard shortcuts

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