Documentation ¶
Index ¶
- func ConvertFromPersistence(data []byte) (*unstructured.Unstructured, error)
- func ConvertToPersistence(obj *unstructured.Unstructured, t persist.Transformer) ([]byte, error)
- type FileSystemPersister
- func New(fs vfs.FileSystem, cfg *config.FileSystemConfiguration, createRootPath bool) (*FileSystemPersister, error)
- func NewForMemory(cfg *config.FileSystemConfiguration) (*FileSystemPersister, error)
- func NewForOS(cfg *config.FileSystemConfiguration) (*FileSystemPersister, error)
- func TryGetInternalFileSystemPersister(p persist.Persister) (*FileSystemPersister, bool)
- func (p *FileSystemPersister) Delete(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, ...) error
- func (p *FileSystemPersister) Exists(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, ...) (bool, error)
- func (p *FileSystemPersister) Get(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, ...) (*unstructured.Unstructured, error)
- func (p *FileSystemPersister) GetResourceFilepath(name, namespace string, gvk schema.GroupVersionKind, subPath string, ...) (string, string)
- func (p *FileSystemPersister) InjectLogger(il *logging.Logger)
- func (p *FileSystemPersister) InternalPersister() persist.Persister
- func (p *FileSystemPersister) Persist(ctx context.Context, resource *unstructured.Unstructured, ...) (*unstructured.Unstructured, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertFromPersistence ¶
func ConvertFromPersistence(data []byte) (*unstructured.Unstructured, error)
ConvertFromPersistence is the counterpart of ConvertToPersistence and converts a byte array back to a resource. It basically calls yaml.Unmarshal on the given data.
func ConvertToPersistence ¶
func ConvertToPersistence(obj *unstructured.Unstructured, t persist.Transformer) ([]byte, error)
ConvertToPersistence serializes the given resource into a byte array which can be stored in a filesystem persistence. If the given Transformer is not nil, its 'Transform' method is called on the resource before, otherwise it is converted as-is. This implementation basically calls yaml.Marshal on the object.
Types ¶
type FileSystemPersister ¶
type FileSystemPersister struct { // Fs is the FileSystem used to persist the data. Fs vfs.FileSystem // NamespacePrefix is used to prefix the names for the namespace folders. NamespacePrefix string // GVKNameSeparator is uses as a separator in the filename between the resource's gvk and its name. GVKNameSeparator string // FileExtension is the extension used for the files. FileExtension string // RootPath is used as a root path. RootPath string // contains filtered or unexported fields }
FileSystemPersister persists data by writing it to a given file system.
func New ¶
func New(fs vfs.FileSystem, cfg *config.FileSystemConfiguration, createRootPath bool) (*FileSystemPersister, error)
New returns a new FileSystemPersister
func NewForMemory ¶
func NewForMemory(cfg *config.FileSystemConfiguration) (*FileSystemPersister, error)
NewForMemory returns a new FileSystemPersister using an in-memory filesystem.
func NewForOS ¶
func NewForOS(cfg *config.FileSystemConfiguration) (*FileSystemPersister, error)
NewForOS returns a new FileSystemPersister using the operating system's filesystem.
func TryGetInternalFileSystemPersister ¶
func TryGetInternalFileSystemPersister(p persist.Persister) (*FileSystemPersister, bool)
TryGetInternalFileSystemPersister tries to get the internal FileSystemPersister of the given Persister. The function traverses the internal Persisters until it reaches a Persister p_final which doesn't have an internal one. Then, p_final.(*FileSystemPersister) is returned.
func (*FileSystemPersister) Delete ¶
func (p *FileSystemPersister) Delete(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) error
func (*FileSystemPersister) Exists ¶
func (p *FileSystemPersister) Exists(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (bool, error)
func (*FileSystemPersister) Get ¶
func (p *FileSystemPersister) Get(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (*unstructured.Unstructured, error)
func (*FileSystemPersister) GetResourceFilepath ¶
func (p *FileSystemPersister) GetResourceFilepath(name, namespace string, gvk schema.GroupVersionKind, subPath string, includeRootPath bool) (string, string)
GetResourceFilepath returns the filepath under which the specified resource is stored and the namespace dir, if any. The returned namespace dir is already part of the path returned as first argument. If includeRootPath is false, the returned path is relative to the directory at p.RootPath. Otherwise, p.RootPath is contained in the returned path.
func (*FileSystemPersister) InjectLogger ¶
func (p *FileSystemPersister) InjectLogger(il *logging.Logger)
func (*FileSystemPersister) InternalPersister ¶
func (p *FileSystemPersister) InternalPersister() persist.Persister
func (*FileSystemPersister) Persist ¶
func (p *FileSystemPersister) Persist(ctx context.Context, resource *unstructured.Unstructured, t persist.Transformer, subPath string) (*unstructured.Unstructured, bool, error)