logicalcluster

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

README

logicalcluster

A library for logical-cluster-aware code.

For contributions, issues, or general discussion, please see the kcp repository.

Documentation

Index

Constants

View Source
const ClusterHeader = "X-Kubernetes-Cluster"

ClusterHeader set to "<lcluster>" on a request is an alternative to accessing the cluster via /clusters/<lcluster>. With that the <lcluster> can be access via normal kube-like /api and /apis endpoints.

Variables

View Source
var (
	// Wildcard is the name indicating cross-workspace requests.
	Wildcard = New("*")
)

Functions

func WithCluster added in v1.1.1

func WithCluster(ctx context.Context, cluster Name) context.Context

WithCluster injects a cluster name into a context

Types

type Name

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

Name is the name of a logical cluster. A logical cluster is

  1. a (part of) etcd prefix to store objects in that cluster
  2. a (part of) a http path which serves a Kubernetes-cluster-like API with discovery, OpenAPI and the actual API groups.
  3. a value in metadata.clusterName in objects from cross-workspace list/watches, which is used to identify the logical cluster.

A logical cluster is a colon separated list of words. In other words, it is like a path, but with colons instead of slashes.

func ClusterFromContext added in v1.1.1

func ClusterFromContext(ctx context.Context) (Name, bool)

ClusterFromContext extracts a cluster name from the context

func From

func From(obj Object) Name

From returns the logical cluster name for obj.

func New

func New(value string) Name

New returns a Name from a string.

func NewValidated added in v1.1.0

func NewValidated(value string) (Name, bool)

NewValidated returns a Name from a string and whether it is a valid logical cluster. A valid logical cluster returns true on IsValid().

func (Name) Base

func (n Name) Base() string

Base returns the last component of the logical cluster name.

func (Name) Empty

func (n Name) Empty() bool

Empty returns true if the logical cluster value is unset.

func (Name) HasPrefix

func (n Name) HasPrefix(other Name) bool

func (Name) IsValid added in v1.1.0

func (n Name) IsValid() bool

IsValid returns true if the name is a Wildcard or a colon separated list of words where each word starts with a lower-case letter and contains only lower-case letters, digits and hyphens.

func (Name) Join

func (n Name) Join(name string) Name

Join joins a parent logical cluster name and a name component.

func (Name) MarshalJSON

func (n Name) MarshalJSON() ([]byte, error)

func (Name) Parent

func (n Name) Parent() (Name, bool)

Parent returns the parent logical cluster name of the given logical cluster name.

func (Name) Path

func (n Name) Path() string

Path returns a path segment for the logical cluster to access its API.

func (Name) Split

func (n Name) Split() (parent Name, name string)

Split splits logical cluster immediately following the final colon, separating it into a parent logical cluster and name component. If there is no colon in path, Split returns an empty logical cluster name and name set to path.

func (Name) String

func (n Name) String() string

String returns the string representation of the logical cluster name.

func (*Name) UnmarshalJSON

func (n *Name) UnmarshalJSON(data []byte) error

type Object

type Object interface {
	GetClusterName() string
}

Object is a local interface representation of the Kubernetes metav1.Object, to avoid dependencies on k8s.io/apimachinery.

Jump to

Keyboard shortcuts

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