Documentation ¶
Overview ¶
Package resource provides core resource definition.
Index ¶
- Variables
- func Equal(r1, r2 Resource) bool
- func IsTombstone(res Resource) bool
- func MarshalYAML(r Resource) (interface{}, error)
- func String(r Resource) string
- type Annotations
- type Any
- type Finalizer
- type Finalizers
- type ID
- type Kind
- type LabelOp
- type LabelQuery
- type LabelQueryOption
- type LabelTerm
- type Labels
- type List
- type Metadata
- func (md *Metadata) Annotations() *Annotations
- func (md Metadata) Copy() Metadata
- func (md Metadata) Created() time.Time
- func (md Metadata) Equal(other Metadata) bool
- func (md *Metadata) Finalizers() *Finalizers
- func (md Metadata) ID() ID
- func (md *Metadata) Labels() *Labels
- func (md *Metadata) MarshalYAML() (interface{}, error)
- func (md Metadata) Namespace() Namespace
- func (md Metadata) Owner() Owner
- func (md Metadata) Phase() Phase
- func (md *Metadata) SetCreated(t time.Time)
- func (md *Metadata) SetOwner(owner Owner) error
- func (md *Metadata) SetPhase(newPhase Phase)
- func (md *Metadata) SetUpdated(t time.Time)
- func (md *Metadata) SetVersion(newVersion Version)
- func (md Metadata) String() string
- func (md Metadata) Type() Type
- func (md *Metadata) UnmarshalYAML(value *yaml.Node) (err error)
- func (md Metadata) Updated() time.Time
- func (md Metadata) Version() Version
- type MetadataProto
- type Namespace
- type Owner
- type Phase
- type Pointer
- type Reference
- type Resource
- type SpecProto
- type Tombstone
- type Tombstoned
- type Type
- type Version
Constants ¶
This section is empty.
Variables ¶
var (
VersionUndefined = Version{}
)
Special version constants.
Functions ¶
func IsTombstone ¶
IsTombstone checks if resource is represented by the Tombstone.
func MarshalYAML ¶
MarshalYAML marshals resource to YAML definition.
Types ¶
type Annotations ¶ added in v0.2.0
Annotations is a set free-form of key-value pairs.
Order of keys is not guaranteed.
Annotations support copy-on-write semantics, so metadata copies share common Annotations as long as possible.
func (Annotations) Equal ¶ added in v0.2.0
func (annotations Annotations) Equal(other Annotations) bool
Equal checks Annotations for equality.
type Any ¶
type Any struct {
// contains filtered or unexported fields
}
Any can hold data from any resource type.
func NewAnyFromProto ¶
func NewAnyFromProto(protoMd MetadataProto, protoSpec SpecProto) (*Any, error)
NewAnyFromProto unmarshals Any from protobuf interface.
type Finalizer ¶
type Finalizer = string
Finalizer is a free-form string which blocks resource destruction.
Resource can't be destroyed until all the finalizers are cleared.
type Finalizers ¶
type Finalizers []Finalizer
Finalizers is a set of Finalizer's with methods to add/remove items.
func (*Finalizers) Add ¶
func (fins *Finalizers) Add(fin Finalizer) bool
Add a (unique) Finalizer to the set.
func (Finalizers) Empty ¶
func (fins Finalizers) Empty() bool
Empty returns true if list of finalizers is empty.
func (*Finalizers) Remove ¶
func (fins *Finalizers) Remove(fin Finalizer) bool
Remove a (unique) Finalizer from the set.
type LabelQuery ¶
type LabelQuery struct {
Terms []LabelTerm
}
LabelQuery is a set of LabelTerms applied with AND semantics.
func (LabelQuery) Matches ¶
func (query LabelQuery) Matches(labels Labels) bool
Matches if the metadata labels matches the label query.
type LabelQueryOption ¶
type LabelQueryOption func(*LabelQuery)
LabelQueryOption allows to build a LabelQuery with functional parameters.
func LabelEqual ¶
func LabelEqual(label, value string) LabelQueryOption
LabelEqual checks that the label is set to the specified value.
func LabelExists ¶
func LabelExists(label string) LabelQueryOption
LabelExists checks that the label is set.
func LabelNotExists ¶
func LabelNotExists(label string) LabelQueryOption
LabelNotExists checks that the label isn't set.
func RawLabelQuery ¶
func RawLabelQuery(query LabelQuery) LabelQueryOption
RawLabelQuery sets the label query to the verbatim value.
type Labels ¶
Labels is a set free-form of key-value pairs.
Order of keys is not guaranteed.
Labels support copy-on-write semantics, so metadata copies share common labels as long as possible. Labels support querying with LabelTerm.
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata implements resource meta.
func NewMetadata ¶
NewMetadata builds new metadata.
func NewMetadataFromProto ¶
func NewMetadataFromProto(proto MetadataProto) (Metadata, error)
NewMetadataFromProto builds Metadata object from ProtoMetadata interface data.
func (*Metadata) Annotations ¶ added in v0.2.0
func (md *Metadata) Annotations() *Annotations
Annotations returns a reference to the annotations.
func (*Metadata) Finalizers ¶
func (md *Metadata) Finalizers() *Finalizers
Finalizers returns a reference to the finalizers.
func (*Metadata) MarshalYAML ¶
MarshalYAML implements yaml.Marshaller interface.
func (*Metadata) SetCreated ¶ added in v0.2.0
SetCreated sets the resource create timestamp.
func (*Metadata) SetUpdated ¶ added in v0.2.0
SetUpdated sets the resource update timestamp.
func (*Metadata) SetVersion ¶
SetVersion updates resource version.
func (*Metadata) UnmarshalYAML ¶ added in v0.2.0
UnmarshalYAML implements yaml.Unmarshaler interface.
type MetadataProto ¶
type MetadataProto interface { GetNamespace() string GetType() string GetId() string GetVersion() string GetPhase() string GetOwner() string GetFinalizers() []string GetCreated() *timestamp.Timestamp GetUpdated() *timestamp.Timestamp GetAnnotations() map[string]string GetLabels() map[string]string }
MetadataProto is an interface for protobuf serialization of Metadata.
type Phase ¶
type Phase int
Phase represents state of the resource.
Resource might be either Running or TearingDown (waiting for the finalizers to be removed).
type Resource ¶
type Resource interface { // Metadata for the resource. // // Metadata.Version should change each time Spec changes. Metadata() *Metadata // Opaque data resource contains. Spec() interface{} // Deep copy of the resource. DeepCopy() Resource }
Resource is an abstract resource managed by the state.
Resource is uniquely identified by the tuple (Namespace, Type, ID). Resource might have additional opaque data in Spec(). When resource is updated, Version should change with each update.
type SpecProto ¶
type SpecProto interface {
GetYaml() []byte
}
SpecProto is a protobuf interface of resource spec.
type Tombstone ¶
type Tombstone struct {
// contains filtered or unexported fields
}
Tombstone is a resource without a Spec.
Tombstones are used to present state of a deleted resource.
func NewTombstone ¶
NewTombstone builds a tombstone from resource reference.
func (*Tombstone) Metadata ¶
Metadata for the resource.
Metadata.Version should change each time Spec changes.
type Tombstoned ¶
type Tombstoned interface {
Tombstone()
}
Tombstoned is a marker interface for Tombstones.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
kv
Package kv implements core key-value type as a base for labels and annotations.
|
Package kv implements core key-value type as a base for labels and annotations. |
Package meta provides definition of core metadata resources.
|
Package meta provides definition of core metadata resources. |
spec
Package spec contains resource specs for the meta resources.
|
Package spec contains resource specs for the meta resources. |
Package protobuf provides a bridge between resources and protobuf interface.
|
Package protobuf provides a bridge between resources and protobuf interface. |
Package rtestutils provides utilities for testing with resource API.
|
Package rtestutils provides utilities for testing with resource API. |
Package typed generic based resource definition.
|
Package typed generic based resource definition. |