Documentation
¶
Index ¶
- Constants
- Variables
- func ConstructWorkspaceURL(baseURL, workspace string) string
- func DiscoverAllWorkspaces(ctx context.Context, baseRestConfig *rest.Config, rootWorkspace string) ([]string, error)
- func DiscoverWorkspacesRecursive(ctx context.Context, baseRestConfig *rest.Config, parentWorkspace string, ...) error
- func ExtractWorkspaceFromURL(serverURL string) string
- func ParseServerURL(serverURL string) (baseURL, workspace string)
- type Kcp
- type Kubernetes
- type WorkspaceWatcher
Constants ¶
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 ¶
var WorkspaceGVR = schema.GroupVersionResource{
Group: "tenancy.kcp.io",
Version: "v1alpha1",
Resource: "workspaces",
}
WorkspaceGVR is the GroupVersionResource for kcp workspaces.
Functions ¶
func ConstructWorkspaceURL ¶
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 ¶
ExtractWorkspaceFromURL returns the workspace name from a full kcp URL.
func ParseServerURL ¶
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 (*Kcp) DescribeWorkspace ¶
DescribeWorkspace returns detailed information about a specific kcp workspace.
type Kubernetes ¶
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.