files

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package files contains methods and data types for manipulating files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileObjReader added in v0.5.0

type FileObjReader interface {
	ReadFileObj(ctx context.Context, file bundle.File) ([]byte, error)
}

FileObjReader provides a generic file-reading interface for reading file objects

type FileReader

type FileReader interface {
	ReadFile(ctx context.Context, path string) ([]byte, error)
}

FileReader is a common command interface for reading files.

type FileReaderWriter

type FileReaderWriter interface {
	FileReader
	FileWriter
}

FileReaderWriter combines both file reading and file writing.

type FileWriter

type FileWriter interface {
	// WriteFile writes a Component or Bundle to the given file path.
	WriteFile(ctx context.Context, path string, bytes []byte, permissions os.FileMode) error
}

FileWriter is an interface for writing files. This interface is used by the export and patch commands in this package. There is a fake implementation in the testing package.

type LocalFileObjReader added in v0.5.0

type LocalFileObjReader struct {
	// WorkingDir specifies a working directory override. This is necessary
	// because paths for inlined files are specified relative to the bundle, not
	// the working directory of the user.
	//
	// TODO(kashomon): Get rid of this. Path manipulation should happen in the
	// downstream libraries.
	WorkingDir string

	// Rdr is a FileReader object.
	Rdr FileReader
}

LocalFileObjReader is File object reader that defers to another FileReader that reads based on paths.

func (*LocalFileObjReader) ReadFileObj added in v0.5.0

func (r *LocalFileObjReader) ReadFileObj(ctx context.Context, file bundle.File) ([]byte, error)

ReadFileObj reads a file object from the local filesystem by deferring to a local file reader.

type LocalFileSystemReader

type LocalFileSystemReader struct{}

LocalFileSystemReader implements the FileReader interface and reads files from the local filesystem.

func (*LocalFileSystemReader) ReadFile

func (r *LocalFileSystemReader) ReadFile(_ context.Context, path string) ([]byte, error)

ReadFile reads a file from disk.

type LocalFileSystemReaderWriter

type LocalFileSystemReaderWriter struct {
	LocalFileSystemReader
	LocalFileSystemWriter
}

LocalFileSystemReaderWriter combines both local file system file reading and writing.

type LocalFileSystemWriter

type LocalFileSystemWriter struct{}

LocalFileSystemWriter implements the ComponentWriter interface and writes apps to the local filesystem.

func (*LocalFileSystemWriter) WriteFile

func (*LocalFileSystemWriter) WriteFile(_ context.Context, path string, bytes []byte, permissions os.FileMode) error

WriteFile writes a file to disk.

type URLScheme added in v0.6.1

type URLScheme string

URLScheme indicates URL schemes supported by various parts of the

const (
	// EmptyScheme represents an unspecified URLScheme.
	EmptyScheme URLScheme = ""

	// FileScheme represents a 'File' scheme for a URL.
	FileScheme URLScheme = "file"
)

Jump to

Keyboard shortcuts

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