logicalcluster

package module
v3.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 519

README

logicalcluster

A library for logical-cluster-aware code.

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

Documentation

Index

Constants

View Source
const AnnotationKey = "kcp.io/cluster"

AnnotationKey is the name of the annotation key used to denote an object's logical cluster.

Variables

View Source
var (
	// Wildcard is the path indicating a requests that spans many logical clusters.
	Wildcard = Path{/* contains filtered or unexported fields */}

	// None represents an unset path.
	None = Path{}

	// TODO is a value created by automated refactoring tools that should be replaced by a real path.
	TODO = None
)

Functions

This section is empty.

Types

type Name

type Name string

Name holds a value that uniquely identifies a logical cluster. For instance, a logical cluster may have the name 33bab531.

A logical cluster is a partition on the storage layer served as autonomous kube-like generic API endpoint.

func From

func From(obj Object) Name

From returns the logical cluster name from the given object.

func (Name) Empty

func (n Name) Empty() bool

Empty returns true if the logical cluster name is unset. It is a convenience method for checking against an empty value.

func (Name) IsValid

func (n Name) IsValid() bool

IsValid returns true if the logical cluster name matches a defined format. A convenience method that could be used for enforcing a well-known structure of a logical cluster name.

As of today a valid value starts with a lower-case letter or digit and contains only lower-case letters, digits and hyphens.

func (Name) Path

func (n Name) Path() Path

Path creates a new Path object from the logical cluster name. A convenience method for working with methods which accept a Path type.

func (Name) String

func (n Name) String() string

String returns string representation of the logical cluster name. Satisfies the Stringer interface.

type Object

type Object interface {
	GetAnnotations() map[string]string
}

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

type Path

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

Path represents a colon separated list of words describing a path in a logical cluster hierarchy, like a file path in a file-system.

For instance, in the following hierarchy:

root/ (62208dab) ├── accounting (c8a942c5) │ └── us-west (33bab531) │ └── invoices (f5865fce) └── management (e7e08986)

└── us-west-invoices (f5865fce)

the following would all be valid paths:

  • root:accounting:us-west:invoices
  • 62208dab:accounting:us-west:invoices
  • c8a942c5:us-west:invoices
  • 33bab531:invoices
  • f5865fce
  • root:management:us-west-invoices
  • 62208dab:management:us-west-invoices
  • e7e08986:us-west-invoices

func NewPath

func NewPath(value string) Path

NewPath returns a new Path.

func NewValidatedPath

func NewValidatedPath(value string) (Path, bool)

NewValidatedPath returns a Path and whether it is valid.

func (Path) Base

func (p Path) Base() string

Base returns the last element of the path.

func (Path) Empty

func (p Path) Empty() bool

Empty returns true if the stored path is unset. It is a convenience method for checking against an empty value.

func (Path) Equal added in v3.0.1

func (p Path) Equal(other Path) bool

Equal checks if the path is the same as the other path.

func (Path) HasPrefix

func (p Path) HasPrefix(other Path) bool

HasPrefix tests whether the path begins with the other path.

func (Path) IsValid

func (p Path) IsValid() bool

IsValid returns true if the path 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 (Path) Join

func (p Path) Join(name string) Path

Join returns a new path by adding the given path segment into already existing path and separating it with a colon.

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the Marshaler interface for encoding the path into JSON.

func (Path) Name

func (p Path) Name() (Name, bool)

Name return a new Name object from the stored path and whether it can be created. A convenience method for working with methods which accept a Name type.

func (Path) Parent

func (p Path) Parent() (Path, bool)

Parent returns a new path with all but the last element of the stored path.

func (Path) RequestPath

func (p Path) RequestPath() string

RequestPath returns a URL path segment used to access API for the stored path.

func (Path) Split

func (p Path) Split() (parent Path, name string)

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

func (Path) String

func (p Path) String() string

String returns string representation of the stored value. Satisfies the Stringer interface.

func (*Path) UnmarshalJSON

func (p *Path) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the Unmarshaler interface implemented by types for decoding a JSON encoded path.

Jump to

Keyboard shortcuts

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