apiurl

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package apiurl is the single source of truth for all railgrid service path construction and URL parsing. All packages that build or decompose railgrid hub URLs should use the helpers here instead of hand-crafting strings.

Index

Constants

View Source
const (
	// PathPrefixMCP + PathPrefixLinuxMCP were removed in the MCP
	// collapse refactor — both surfaces live behind PathPrefixMCPServer
	// (the aggregate endpoint) now.
	PathPrefixMCPServer      = "/services/mcpserver"
	PathPrefixProvidersUI    = "/ui/providers"
	PathPrefixProvidersProxy = "/services/providers"
	// PathPrefixAPIExportVW is kcp's APIExport virtual-workspace prefix, which
	// the hub forwards verbatim to kcp so a provider running OUTSIDE the
	// platform can watch its own APIExport. Shape:
	//
	//	/services/apiexport/{cluster}/{export}/clusters/{wildcard}/...
	//
	// Unlike the prefixes above, the hub does not own this path — it is kcp's,
	// and the segments are kcp's to interpret. The hub only authorizes and
	// relays. See docs/byo-providers.md.
	PathPrefixAPIExportVW = "/services/apiexport"
	PathAuthAuthorize     = "/auth/authorize"
	PathAuthCallback      = "/auth/callback"
	PathAuthRefresh       = "/auth/refresh"
	PathAuthTokenLogin    = "/auth/token-login"
	PathHealthz           = "/healthz"
	PathVersion           = "/version"
)

Path prefix constants for railgrid virtual-workspace services and auth endpoints. Hub-specific endpoints live under /services and /auth — distinct from kcp's native /clusters, /apis/<group>, /api/v1 paths, which are forwarded straight to kcp.

View Source
const (
	EdgesAPIGroup   = "edges.railgrid.ai"
	EdgesAPIVersion = "v1alpha1"
)

EdgesAPIGroup and EdgesAPIVersion are the edges provider's API coordinates, shared by every edge verb helper below.

Variables

This section is empty.

Functions

func EdgeAPIPath

func EdgeAPIPath(cluster, edgeName string) string

EdgeAPIPath returns the kcp API path for an Edge resource, suitable for use as a client Host suffix or in kubeconfig server URLs.

Pattern: /clusters/{cluster}/apis/railgrid.ai/v1alpha1/edges/{name}

func EdgeProviderCoordinates

func EdgeProviderCoordinates(edgeType string) (provider, group, resource string)

EdgeProviderCoordinates resolves an edge type ("kubernetes" | "server" | "macos") to the owning provider's name, API group and resource. The edge plane is one provider `edges` holding all kinds under group edges.railgrid.ai; only the resource differs by type. Unknown values default to kubernetes for backwards compatibility with callers that omitted the edge type.

func EdgeServiceProxyPath

func EdgeServiceProxyPath(cluster, name, verb string) string

EdgeServiceProxyPath returns the kube path of a verb on a Service published from an edge, served by the edges provider as a custom subresource.

verb is "proxy" (HTTP data plane) or "mcp".

Pattern: /clusters/{cluster}/apis/edges.railgrid.ai/v1alpha1/services/{name}/{verb}

func EdgeServiceProxyURL

func EdgeServiceProxyURL(hubBase, cluster, name, verb string) string

EdgeServiceProxyURL returns the full Service verb URL.

func EdgeVerbPath added in v0.2.7

func EdgeVerbPath(cluster, resource, name, verb string) string

EdgeVerbPath returns the kube path of a verb on an edge (a kubernetescluster, linuxserver or macosserver): its Kubernetes API ("k8s"), its SSH session ("ssh"), its MCP server ("mcp"), or an agent's own credential verbs ("agent-token", "ssh-credentials", "addon-credentials").

func EdgeVerbURL added in v0.2.7

func EdgeVerbURL(hubBase, edgeType, cluster, name, verb string) string

EdgeVerbURL is EdgeVerbPath against a hub base URL, resolving the resource from the edge type.

func ExternalizeURL

func ExternalizeURL(edgeURL, hubBase string) (string, error)

ExternalizeURL replaces the scheme and host in edgeURL with those from hubBase, making an internal edge-proxy URL routable through the public hub.

If edgeURL does not start with /services/ it is returned unchanged.

func HubServerURL

func HubServerURL(hubBase, cluster string) string

HubServerURL returns a URL with a /clusters/<cluster> suffix, suitable for both user-facing kubeconfigs (routed via the hub) and internal kcp client configurations. The hub forwards /clusters/* paths straight to kcp, so the same URL form works for both purposes.

If hubBase already contains a /clusters/ path it is replaced.

Example: HubServerURL("https://hub:9443", "abc123") → "https://hub:9443/clusters/abc123"

func KCPClusterURL

func KCPClusterURL(kcpBase, cluster string) string

KCPClusterURL is an alias for HubServerURL. In earlier iterations the hub had a prefix (/api or /apis) that the router stripped before forwarding to kcp, which required distinguishing "external hub" vs "internal kcp" URL forms. That distinction is gone; /clusters/ goes straight through.

func MCPServerPath

func MCPServerPath(cluster, mcpServerName string) string

MCPServerPath returns the URL path for the unified MCPServer virtual workspace endpoint (aggregates kube + linux edges).

Pattern: /services/mcpserver/{cluster}/apis/railgrid.ai/v1alpha1/mcpservers/{name}/mcp

func MCPServerURL

func MCPServerURL(hubBase, cluster, mcpServerName string) string

MCPServerURL returns the full MCPServer endpoint URL.

func ProviderAgentProxyPath

func ProviderAgentProxyPath(provider, resource, cluster, edgeName, verb string) string

ProviderAgentProxyPath returns the agent-ingress path for an edge provider's reverse-tunnel control connection: Pillar 2 route class (f), routed through the hub backend proxy to the provider Service. It is not a data-plane verb (the agent is not a kcp client; it authenticates with a join token or its edge ServiceAccount and holds a long-lived tunnel), so it is the one provider path that stays on the hub proxy. The provider sees the path unmodified.

Pattern: /services/providers/{provider}/agent/clusters/{cluster}/{resource}/{name}/proxy

func ProviderAgentProxyURL

func ProviderAgentProxyURL(hubBase, edgeType, cluster, edgeName, verb string) string

ProviderAgentProxyURL returns the full agent-ingress URL for use when dialling the hub from the agent, resolving the provider coordinates from the edge type.

func ProviderVerbPath added in v0.2.7

func ProviderVerbPath(cluster, group, version, resource, name, verb string) string

ProviderVerbPath returns the path of a provider data-plane verb: the kcp custom subresource "{resource}/{verb}" the provider publishes on its APIExport, addressed like any other kube API path on the front door the caller holds a credential for (the hub's /clusters/{id}). kcp authorizes SSAR "create" on the subresource with ordinary RBAC and reverse-proxies the request to the provider. There is no hub-side grammar for a verb: this is the only spelling.

Pattern: /clusters/{cluster}/apis/{group}/{version}/{resource}/{name}/{verb}

A verb on one component of a multi-component object carries the component as the "component" query parameter (provider-sdk/dataplane.ComponentQuery), which this helper leaves to the caller.

func ProviderVerbURL added in v0.2.7

func ProviderVerbURL(base, cluster, group, version, resource, name, verb string) string

ProviderVerbURL is ProviderVerbPath against a hub (or kcp front door) base URL.

func SplitBaseAndCluster

func SplitBaseAndCluster(rawURL string) (base, cluster string)

SplitBaseAndCluster splits a URL that contains a /clusters/<name> path into a base URL (scheme+host only, no trailing slash) and the kcp cluster name.

Examples:

"https://hub:9443/clusters/abc123"            → ("https://hub:9443", "abc123")
"https://hub:9443/clusters/abc123/extra/path" → ("https://hub:9443", "abc123")
"https://hub:9443"                            → ("https://hub:9443", "default")
"https://hub:9443/"                           → ("https://hub:9443", "default")

Returns (trimmed url, "default") on parse error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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