files

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 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 FilePBReader

type FilePBReader interface {
	ReadFilePB(ctx context.Context, file *bpb.File) ([]byte, error)
}

FilePBReader provides a generic file-reading interface for reading file protos.

func NewLocalFilePBReader

func NewLocalFilePBReader(dirOverride string) FilePBReader

NewLocalFilePBReader creates a local-filesystem based file reader.

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 ClusterComponent 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 LocalFilePBReader

type LocalFilePBReader 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
}

LocalFilePBReader is File proto reader that defers to another FileReader that reads based on paths.

func (*LocalFilePBReader) ReadFilePB

func (r *LocalFilePBReader) ReadFilePB(ctx context.Context, fpb *bpb.File) ([]byte, error)

ReadFilePB reads a file proto 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)

type LocalFileSystemReaderWriter

type LocalFileSystemReaderWriter struct {
	LocalFileSystemReader
	LocalFileSystemWriter
}

RealFileReaderWriter 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

Jump to

Keyboard shortcuts

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