Documentation
¶
Index ¶
- Constants
- Variables
- func WithCluster(ctx context.Context, cluster Name) context.Context
- type Name
- type Object
- type Path
- func (p Path) Base() string
- func (p Path) Empty() bool
- func (p Path) Equal(other Path) bool
- func (p Path) HasPrefix(other Path) bool
- func (p Path) IsValid() bool
- func (p Path) Join(name string) Path
- func (p Path) MarshalJSON() ([]byte, error)
- func (p Path) Name() (Name, bool)
- func (p Path) Parent() (Path, bool)
- func (p Path) RequestPath() string
- func (p Path) Split() (parent Path, name string)
- func (p Path) String() string
- func (p *Path) UnmarshalJSON(data []byte) error
Constants ¶
const AnnotationKey = "kcp.io/cluster"
AnnotationKey is the name of the annotation key used to denote an object's logical cluster.
Variables ¶
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 ¶
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 ClusterFromContext ¶
ClusterFromContext extracts a cluster name from the context
func (Name) Empty ¶
Empty returns true if the logical cluster name is unset. It is a convenience method for checking against an empty value.
func (Name) IsValid ¶
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.
type Object ¶
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 NewValidatedPath ¶
NewValidatedPath returns a Path and whether it is valid.
func (Path) Empty ¶
Empty returns true if the stored path is unset. It is a convenience method for checking against an empty value.
func (Path) IsValid ¶
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 ¶
Join returns a new path by adding the given path segment into already existing path and separating it with a colon.
func (Path) MarshalJSON ¶
MarshalJSON satisfies the Marshaler interface for encoding the path into JSON.
func (Path) Name ¶
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) RequestPath ¶
RequestPath returns a URL path segment used to access API for the stored path.
func (Path) Split ¶
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 ¶
String returns string representation of the stored value. Satisfies the Stringer interface.
func (*Path) UnmarshalJSON ¶
UnmarshalJSON satisfies the Unmarshaler interface implemented by types for decoding a JSON encoded path.