Documentation ¶
Index ¶
- Variables
- type AnyKey
- type Format
- type GenericMappedRawStorage
- func (r *GenericMappedRawStorage) AddMapping(key Key, path string)
- func (r *GenericMappedRawStorage) Checksum(key Key) (s string, err error)
- func (r *GenericMappedRawStorage) Delete(key Key) (err error)
- func (r *GenericMappedRawStorage) Exists(key Key) bool
- func (r *GenericMappedRawStorage) Format(key Key) (f Format)
- func (r *GenericMappedRawStorage) GetKey(path string) (Key, error)
- func (r *GenericMappedRawStorage) List(kind KindKey) ([]Key, error)
- func (r *GenericMappedRawStorage) Read(key Key) ([]byte, error)
- func (r *GenericMappedRawStorage) RemoveMapping(key Key)
- func (r *GenericMappedRawStorage) WatchDir() string
- func (r *GenericMappedRawStorage) Write(key Key, content []byte) error
- type GenericRawStorage
- func (r *GenericRawStorage) Checksum(key Key) (s string, err error)
- func (r *GenericRawStorage) Delete(key Key) error
- func (r *GenericRawStorage) Exists(key Key) bool
- func (r *GenericRawStorage) Format(key Key) Format
- func (r *GenericRawStorage) GetKey(p string) (key Key, err error)
- func (r *GenericRawStorage) List(key KindKey) ([]Key, error)
- func (r *GenericRawStorage) Read(key Key) ([]byte, error)
- func (r *GenericRawStorage) WatchDir() string
- func (r *GenericRawStorage) Write(key Key, content []byte) error
- type GenericStorage
- func (s *GenericStorage) Checksum(gvk schema.GroupVersionKind, uid runtime.UID) (string, error)
- func (s *GenericStorage) Close() error
- func (s *GenericStorage) Count(gvk schema.GroupVersionKind) (uint64, error)
- func (s *GenericStorage) Delete(gvk schema.GroupVersionKind, uid runtime.UID) error
- func (s *GenericStorage) Get(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error)
- func (s *GenericStorage) GetMeta(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error)
- func (s *GenericStorage) List(gvk schema.GroupVersionKind) (result []runtime.Object, walkerr error)
- func (s *GenericStorage) ListMeta(gvk schema.GroupVersionKind) (result []runtime.Object, walkerr error)
- func (s *GenericStorage) New(gvk schema.GroupVersionKind) (runtime.Object, error)
- func (s *GenericStorage) Patch(gvk schema.GroupVersionKind, uid runtime.UID, patch []byte) error
- func (s *GenericStorage) RawStorage() RawStorage
- func (s *GenericStorage) Serializer() serializer.Serializer
- func (s *GenericStorage) Set(gvk schema.GroupVersionKind, obj runtime.Object) error
- type Key
- type KindKey
- type MappedRawStorage
- type RawStorage
- type Storage
Constants ¶
This section is empty.
Variables ¶
var Formats = map[string]Format{ ".json": FormatJSON, ".yaml": FormatYAML, ".yml": FormatYAML, }
Formats describes the connection between file extensions and a encoding formats.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format uint8
Format is an enum describing the format of data in a file. This is used by Storages to determine the encoding format for a file.
type GenericMappedRawStorage ¶
type GenericMappedRawStorage struct {
// contains filtered or unexported fields
}
GenericMappedRawStorage is the default implementation of a MappedRawStorage, it stores files in the given directory via a path translation map.
func (*GenericMappedRawStorage) AddMapping ¶
func (r *GenericMappedRawStorage) AddMapping(key Key, path string)
func (*GenericMappedRawStorage) Checksum ¶
func (r *GenericMappedRawStorage) Checksum(key Key) (s string, err error)
This returns the modification time as a UnixNano string If the file doesn't exist, return blank
func (*GenericMappedRawStorage) Delete ¶
func (r *GenericMappedRawStorage) Delete(key Key) (err error)
func (*GenericMappedRawStorage) Exists ¶
func (r *GenericMappedRawStorage) Exists(key Key) bool
func (*GenericMappedRawStorage) Format ¶
func (r *GenericMappedRawStorage) Format(key Key) (f Format)
func (*GenericMappedRawStorage) GetKey ¶
func (r *GenericMappedRawStorage) GetKey(path string) (Key, error)
func (*GenericMappedRawStorage) List ¶
func (r *GenericMappedRawStorage) List(kind KindKey) ([]Key, error)
func (*GenericMappedRawStorage) Read ¶
func (r *GenericMappedRawStorage) Read(key Key) ([]byte, error)
func (*GenericMappedRawStorage) RemoveMapping ¶
func (r *GenericMappedRawStorage) RemoveMapping(key Key)
func (*GenericMappedRawStorage) WatchDir ¶
func (r *GenericMappedRawStorage) WatchDir() string
type GenericRawStorage ¶
type GenericRawStorage struct {
// contains filtered or unexported fields
}
func (*GenericRawStorage) Checksum ¶
func (r *GenericRawStorage) Checksum(key Key) (s string, err error)
This returns the modification time as a UnixNano string If the file doesn't exist, return blank
func (*GenericRawStorage) Delete ¶
func (r *GenericRawStorage) Delete(key Key) error
func (*GenericRawStorage) Exists ¶
func (r *GenericRawStorage) Exists(key Key) bool
func (*GenericRawStorage) Format ¶
func (r *GenericRawStorage) Format(key Key) Format
func (*GenericRawStorage) GetKey ¶
func (r *GenericRawStorage) GetKey(p string) (key Key, err error)
func (*GenericRawStorage) WatchDir ¶
func (r *GenericRawStorage) WatchDir() string
type GenericStorage ¶
type GenericStorage struct {
// contains filtered or unexported fields
}
GenericStorage implements the Storage interface
func (*GenericStorage) Checksum ¶
func (s *GenericStorage) Checksum(gvk schema.GroupVersionKind, uid runtime.UID) (string, error)
Checksum returns a string representing the state of an Object on disk
func (*GenericStorage) Close ¶
func (s *GenericStorage) Close() error
Close closes all underlying resources (e.g. goroutines) used; before the application exits
func (*GenericStorage) Count ¶
func (s *GenericStorage) Count(gvk schema.GroupVersionKind) (uint64, error)
Count counts the Objects for the specific kind
func (*GenericStorage) Delete ¶
func (s *GenericStorage) Delete(gvk schema.GroupVersionKind, uid runtime.UID) error
Delete removes an Object from the storage
func (*GenericStorage) Get ¶
func (s *GenericStorage) Get(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error)
Get returns a new Object for the resource at the specified kind/uid path, based on the file content
func (*GenericStorage) GetMeta ¶
func (s *GenericStorage) GetMeta(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error)
TODO: Verify this works GetMeta returns a new Object's APIType representation for the resource at the specified kind/uid path
func (*GenericStorage) List ¶
func (s *GenericStorage) List(gvk schema.GroupVersionKind) (result []runtime.Object, walkerr error)
List lists Objects for the specific kind
func (*GenericStorage) ListMeta ¶
func (s *GenericStorage) ListMeta(gvk schema.GroupVersionKind) (result []runtime.Object, walkerr error)
ListMeta lists all Objects' APIType representation. In other words, only metadata about each Object is unmarshalled (uid/name/kind/apiVersion). This allows for faster runs (no need to unmarshal "the world"), and less resource usage, when only metadata is unmarshalled into memory
func (*GenericStorage) New ¶
func (s *GenericStorage) New(gvk schema.GroupVersionKind) (runtime.Object, error)
New creates a new Object for the specified kind TODO: Create better error handling if the GVK specified is not recognized
func (*GenericStorage) Patch ¶
func (s *GenericStorage) Patch(gvk schema.GroupVersionKind, uid runtime.UID, patch []byte) error
Patch performs a strategic merge patch on the object with the given UID, using the byte-encoded patch given
func (*GenericStorage) RawStorage ¶
func (s *GenericStorage) RawStorage() RawStorage
RawStorage returns the RawStorage instance backing this Storage
func (*GenericStorage) Serializer ¶
func (s *GenericStorage) Serializer() serializer.Serializer
func (*GenericStorage) Set ¶
func (s *GenericStorage) Set(gvk schema.GroupVersionKind, obj runtime.Object) error
Set saves the Object to disk
type Key ¶
Key represents the internal format of Object virtual paths
type KindKey ¶
KindKey represents the internal format of Kind virtual paths
func KeyForKind ¶
func KeyForKind(gvk schema.GroupVersionKind) KindKey
func NewKindKey ¶
NewKindKey generates a new virtual path Key for a Kind
type MappedRawStorage ¶
type MappedRawStorage interface { RawStorage // AddMapping binds a Key's virtual path to a physical file path AddMapping(key Key, path string) // RemoveMapping removes the physical file // path mapping matching the given Key RemoveMapping(key Key) }
MappedRawStorage is an interface for RawStorages which store their data in a flat/unordered directory format like manifest directories.
func NewGenericMappedRawStorage ¶
func NewGenericMappedRawStorage(dir string) MappedRawStorage
type RawStorage ¶
type RawStorage interface { // Read returns a resource's content based on key Read(key Key) ([]byte, error) // Exists checks if the resource indicated by key exists Exists(key Key) bool // Write writes the given content to the resource indicated by key Write(key Key, content []byte) error // Delete deletes the resource indicated by key Delete(key Key) error // List returns all matching resource Keys based on the given KindKey List(key KindKey) ([]Key, error) // Checksum returns a string checksum for the resource indicated by key Checksum(key Key) (string, error) // Format returns the format of the contents of the resource indicated by key Format(key Key) Format // WatchDir returns the path for Watchers to watch changes in WatchDir() string // GetKey retrieves the Key containing the virtual path based // on the given physical file path returned by a Watcher GetKey(path string) (Key, error) }
RawStorage is a Key-indexed low-level interface to store byte-encoded Objects (resources) in non-volatile memory.
func NewGenericRawStorage ¶
func NewGenericRawStorage(dir string) RawStorage
type Storage ¶
type Storage interface { // New creates a new Object for the specified kind New(gvk schema.GroupVersionKind) (runtime.Object, error) // Get returns a new Object for the resource at the specified kind/uid path, based on the file content Get(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error) // GetMeta returns a new Object's APIType representation for the resource at the specified kind/uid path GetMeta(gvk schema.GroupVersionKind, uid runtime.UID) (runtime.Object, error) // Set saves the Object to disk. If the Object does not exist, the // ObjectMeta.Created field is set automatically Set(gvk schema.GroupVersionKind, obj runtime.Object) error // Patch performs a strategic merge patch on the Object with the given UID, using the byte-encoded patch given Patch(gvk schema.GroupVersionKind, uid runtime.UID, patch []byte) error // Delete removes an Object from the storage Delete(gvk schema.GroupVersionKind, uid runtime.UID) error // List lists Objects for the specific kind List(gvk schema.GroupVersionKind) ([]runtime.Object, error) // ListMeta lists all Objects' APIType representation. In other words, // only metadata about each Object is unmarshalled (uid/name/kind/apiVersion). // This allows for faster runs (no need to unmarshal "the world"), and less // resource usage, when only metadata is unmarshalled into memory ListMeta(gvk schema.GroupVersionKind) ([]runtime.Object, error) // Count returns the amount of available Objects of a specific kind // This is used by Caches to check if all Objects are cached to perform a List Count(gvk schema.GroupVersionKind) (uint64, error) // Checksum returns a string representing the state of an Object on disk // The checksum should change if any modifications have been made to the // Object on disk, it can be e.g. the Object's modification timestamp or // calculated checksum Checksum(gvk schema.GroupVersionKind, uid runtime.UID) (string, error) // RawStorage returns the RawStorage instance backing this Storage RawStorage() RawStorage // Serializer returns the serializer Serializer() serializer.Serializer // Close closes all underlying resources (e.g. goroutines) used; before the application exits Close() error }
Storage is an interface for persisting and retrieving API objects to/from a backend One Storage instance handles all different Kinds of Objects
func NewGenericStorage ¶
func NewGenericStorage(rawStorage RawStorage, serializer serializer.Serializer) Storage
NewGenericStorage constructs a new Storage