Documentation
¶
Index ¶
- Constants
- type ErrEncodeLease
- type ErrMalformedUUID
- type Lease
- type Map
- func (m *Map) CreateLease(u uuid.UUID, l *Lease) bool
- func (m *Map) DeleteLease(u uuid.UUID) bool
- func (m Map) LeaseByClusterName(clusterName string) (*Lease, bool)
- func (m Map) LeaseForUUID(u uuid.UUID) (*Lease, bool)
- func (m *Map) ToAnnotations() (map[string]string, error)
- func (m Map) UUIDs() ([]uuid.UUID, error)
- type UUIDAndLease
Constants ¶
const ( // TimeFormat is the standard format that all lease expiration times are stored as in k8s // annotations TimeFormat = time.RFC3339 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrEncodeLease ¶
type ErrEncodeLease struct {
// contains filtered or unexported fields
}
ErrEncodeLease is an error implementation that's returned whenever a func failed to encode a lease into json
func (ErrEncodeLease) Error ¶
func (e ErrEncodeLease) Error() string
Error is the error interface implementation
type ErrMalformedUUID ¶
type ErrMalformedUUID struct {
// contains filtered or unexported fields
}
ErrMalformedUUID is an error implementation that's returned whenever a func failed to parse a UUID from plain text
func (ErrMalformedUUID) Error ¶
func (m ErrMalformedUUID) Error() string
Error is the error interface implementation
type Lease ¶
type Lease struct { ClusterName string `json:"cluster_name"` LeaseExpirationTime string `json:"lease_expiration_time"` }
Lease is the json-encodable struct that represents what's in the value of one lease annotation in k8s
func ParseLease ¶
ParseLease decodes leaseStr from json into a Lease structure. Returns nil and any decoding error if there was one, and a valid lease and nil otherwise
func (Lease) ExpirationTime ¶
ExpirationTime returns the expiration time of this lease, if l.LeaseExpirationTime was a well formed time string, returns the time and nil. Otherwise returns the zero value of time (i.e. t.IsZero() will return true) and a non-nil error
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map holds an in-memory representation of the set of leases written to k8s annotations. It can look up leases by lease token (which is a UUID) or cluster name
func ParseMapFromAnnotations ¶
ParseMapFromAnnotations parses a map of Kubernetes annotations into a lease map. Returns nil and an appropriate error if the parsing failed, non-nil and no error otherwise
func (*Map) CreateLease ¶
CreateLease attempts to set the given lease under the given uuid. If u already existed or l.ClusterName otherwise already has a lease associated with it, does nothing and returns false. Otherwise adds the lease to the map and returns true
func (*Map) DeleteLease ¶
DeleteLease attempts to delete the lease under the given uuid. If there is no such lease, does nothing and returns false. Otherwise, completes the delete operation and returns true
func (Map) LeaseByClusterName ¶
LeaseByClusterName finds a lease in m by the given cluster name. returns nil and false if no lease exists for the given cluster name, non-nil and true otherwise
func (Map) LeaseForUUID ¶
LeaseForUUID looks up a lease for the given UUID. Returns nil and false if none was found, non-nil and true otherwise
func (*Map) ToAnnotations ¶
ToAnnotations returns a raw map[string]string of lease tokens and json-encoded leases. This map is suitable for use in Kubernetes annotations, and will be parseable by ParseMapFromAnnotations
type UUIDAndLease ¶
UUIDAndLease is a simple struct to encapsulate the token (which is a UUID) for a lease and the corresponding lease itself. This structure is represented as a key/value pair in a k8s annotations map
func NewUUIDAndLease ¶
func NewUUIDAndLease(u uuid.UUID, l *Lease) *UUIDAndLease
NewUUIDAndLease creates a new UUIDAndLease struct populated with u and l for its UUID and Lease fields, respectively