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) (any, error)
- func String(r Resource) string
- type Annotations
- type Any
- type Finalizer
- type Finalizers
- type ID
- type IDQuery
- type IDQueryOption
- type Kind
- type LabelOp
- type LabelQueries
- type LabelQuery
- type LabelQueryOption
- func LabelEqual(label, value string, opts ...TermOption) LabelQueryOption
- func LabelExists(label string, opts ...TermOption) LabelQueryOption
- func LabelIn(label string, set []string, opts ...TermOption) LabelQueryOption
- func LabelLT(label, value string, opts ...TermOption) LabelQueryOption
- func LabelLTE(label, value string, opts ...TermOption) LabelQueryOption
- func LabelLTENumeric(label, value string, opts ...TermOption) LabelQueryOption
- func LabelLTNumeric(label, value string, opts ...TermOption) LabelQueryOption
- func RawLabelQuery(query LabelQuery) 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() (any, 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 TermOption
- 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) Has ¶ added in v0.3.0
func (fins Finalizers) Has(fin Finalizer) bool
Has returns true if fin is present in the list of finalizers.
func (*Finalizers) Remove ¶
func (fins *Finalizers) Remove(fin Finalizer) bool
Remove a (unique) Finalizer from the set.
func (*Finalizers) Set ¶ added in v0.3.0
func (fins *Finalizers) Set(other Finalizers)
Set copies the finalizers from the other.
type IDQueryOption ¶ added in v0.3.0
type IDQueryOption func(*IDQuery)
IDQueryOption allows to build an IDQuery with functional parameters.
func IDRegexpMatch ¶ added in v0.3.0
func IDRegexpMatch(re *regexp.Regexp) IDQueryOption
IDRegexpMatch checks that the ID matches the regexp.
type LabelOp ¶
type LabelOp int
LabelOp is a match operation on labels.
const ( // Label with the key exists. LabelOpExists LabelOp = iota // Label with the key matches the value. LabelOpEqual // Label value is in the set. LabelOpIn // Label value is less. LabelOpLT // Label value is less or equal. LabelOpLTE // Label value is less than number. LabelOpLTNumeric // Label value is less or equal numeric. LabelOpLTENumeric )
LabelOp values.
type LabelQueries ¶ added in v0.3.3
type LabelQueries []LabelQuery
LabelQueries is the list of label queries.
func (LabelQueries) Matches ¶ added in v0.3.3
func (queries LabelQueries) Matches(labels Labels) bool
Matches iterates through the list of label queries and matches the labels using OR condition.
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, opts ...TermOption) LabelQueryOption
LabelEqual checks that the label is set to the specified value.
func LabelExists ¶
func LabelExists(label string, opts ...TermOption) LabelQueryOption
LabelExists checks that the label is set.
func LabelIn ¶ added in v0.3.2
func LabelIn(label string, set []string, opts ...TermOption) LabelQueryOption
LabelIn checks that the label value is in the provided set.
func LabelLT ¶ added in v0.3.2
func LabelLT(label, value string, opts ...TermOption) LabelQueryOption
LabelLT checks that the label value is less than value, peforms string comparison.
func LabelLTE ¶ added in v0.3.2
func LabelLTE(label, value string, opts ...TermOption) LabelQueryOption
LabelLTE checks that the label value is less or equal to value, peforms string comparison.
func LabelLTENumeric ¶ added in v0.3.2
func LabelLTENumeric(label, value string, opts ...TermOption) LabelQueryOption
LabelLTENumeric checks that the label value is less or equal to value, peforms numeric comparison, if possible.
func LabelLTNumeric ¶ added in v0.3.2
func LabelLTNumeric(label, value string, opts ...TermOption) LabelQueryOption
LabelLTNumeric checks that the label value is less than value, peforms numeric comparison, if possible.
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() *timestamppb.Timestamp GetUpdated() *timestamppb.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() any // 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 TermOption ¶ added in v0.3.2
type TermOption int
TermOption defines additional term options.
const ( // NotMatches the condition. NotMatches TermOption = iota )
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.
type Tombstoned ¶
type Tombstoned interface {
Tombstone()
}
Tombstoned is a marker interface for Tombstones.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
compare
Package compare implements term operation helpers.
|
Package compare implements term operation helpers. |
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 kvutils provides utilities to internal/kv package.
|
Package kvutils provides utilities to internal/kv package. |
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. |