fsys

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPathNoDirectory = errors.New("invalid path, path needs a specific directory")

Functions

func EnsureDir

func EnsureDir(ctx context.Context, elems ...string) error

func FileExists added in v0.0.3

func FileExists(path string) bool

fileExists returns true if a file at path already exists; false otherwise.

func GetFileName added in v0.0.3

func GetFileName(rn *yaml.RNode) (string, error)

func IsDir added in v0.0.3

func IsDir(path string) bool

IsDir returns true if path represents a directory in the fileSystem otherwise false is returned

func NormalizeDir added in v0.0.3

func NormalizeDir(dirPath string) (string, error)

NormalizeDir returns full absolute directory path of the passed directory or an error. This function cleans up paths such as current directory (.), relative directories (..), or multiple separators.

Types

type Directory added in v0.0.3

type Directory struct {
	Path string
}

Directory creates a new temp directory, in which files get created.

func CreateTempDirectory added in v0.0.3

func CreateTempDirectory(prefix string) (*Directory, error)

CreateDirectory does create the actual disk directory, and return a new representation of it.

func (*Directory) Delete added in v0.0.3

func (r *Directory) Delete() error

Delete removes the directory recursively.

func (*Directory) Name added in v0.0.3

func (r *Directory) Name() string

Delete removes the directory recursively.

func (*Directory) NewFile added in v0.0.3

func (r *Directory) NewFile(name string) (*os.File, error)

NewFile creates a new file in the directory.

func (*Directory) Print added in v0.0.3

func (r *Directory) Print(fileName string, obj runtime.Object) error

Print prints the object using the printer into a new file in the directory.

type FS

type FS interface {
	Open(path string) (fs.File, error)

	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)

	Create(path string) (*os.File, error)

	// Readfile returns the content of a given file
	ReadFile(path string) ([]byte, error)

	// WriteFile writes the data to a file at the given path,
	// it overwrites existing content
	WriteFile(path string, data []byte, perm fs.FileMode) error

	// Calculate a sha256 cheksum on the file
	Sha256(path string) (string, error)

	// Walk walks the file system with the given WalkDirFunc.
	Walk(path string, walkFn fs.WalkDirFunc) error

	// Exists is true if the path exists in the file system.
	Exists(path string) bool

	// Stat returns a FileInfo describing the named file from the file system.
	Stat(path string) (fs.FileInfo, error)

	// Glob returns the list of matching files,
	// emulating https://golang.org/pkg/path/filepath/#Glob
	Glob(pattern string) ([]string, error)

	// MkDir makes a directory.
	Mkdir(path string) error

	// MkDirAll makes a directory path, creating intervening directories.
	MkdirAll(path string) error

	// RemoveAll removes path and any children it contains.
	RemoveAll(path string) error

	// RemoveAll removes path and any children it contains.
	Remove(path string) error
}

func NewDiskFS

func NewDiskFS(path string) FS

func NewMemFS

func NewMemFS(rootpath string, fs fstest.MapFS) FS

type Printer added in v0.0.3

type Printer struct{}

Printer is used to print an object.

func (*Printer) Print added in v0.0.3

func (p *Printer) Print(w io.Writer, obj runtime.Object) error

Print the object inside the writer w.

Jump to

Keyboard shortcuts

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