filesystem

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

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

NewForMemory returns a new FileSystemPersister using an in-memory filesystem.

func NewForOS

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL