fs

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 9 Imported by: 765

Documentation

Overview

Package fs provides a file system abstraction layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeFS

type FakeFS struct {
	// contains filtered or unexported fields
}

FakeFS implements FileSystem using a fake in-memory filesystem.

func MakeFakeFS

func MakeFakeFS() *FakeFS

MakeFakeFS returns an instance of FakeFS with no files in it.

func (*FakeFS) Create

func (fs *FakeFS) Create(name string) (File, error)

Create assures a fake file appears in the in-memory file system.

func (*FakeFS) Exists added in v1.0.5

func (fs *FakeFS) Exists(name string) bool

Exists returns true if file is known.

func (*FakeFS) Glob added in v1.0.6

func (fs *FakeFS) Glob(pattern string) ([]string, error)

Glob returns the list of matching files

func (*FakeFS) IsDir added in v1.0.5

func (fs *FakeFS) IsDir(name string) bool

IsDir returns true if the file exists and is a directory.

func (*FakeFS) Mkdir

func (fs *FakeFS) Mkdir(name string) error

Mkdir assures a fake directory appears in the in-memory file system.

func (*FakeFS) MkdirAll added in v1.0.9

func (fs *FakeFS) MkdirAll(name string) error

MkdirAll delegates to Mkdir

func (*FakeFS) Open

func (fs *FakeFS) Open(name string) (File, error)

Open returns a fake file in the open state.

func (*FakeFS) ReadFile

func (fs *FakeFS) ReadFile(name string) ([]byte, error)

ReadFile always returns an empty bytes and error depending on content of m.

func (*FakeFS) ReadTestKustomization added in v1.0.9

func (fs *FakeFS) ReadTestKustomization() ([]byte, error)

func (*FakeFS) WriteFile

func (fs *FakeFS) WriteFile(name string, c []byte) error

WriteFile always succeeds and does nothing.

func (*FakeFS) WriteTestKustomization added in v1.0.9

func (fs *FakeFS) WriteTestKustomization()

WriteTestKustomization writes a standard test file.

func (*FakeFS) WriteTestKustomizationWith added in v1.0.9

func (fs *FakeFS) WriteTestKustomizationWith(bytes []byte)

WriteTestKustomizationWith writes a standard test file.

type FakeFile

type FakeFile struct {
	// contains filtered or unexported fields
}

FakeFile implements File in-memory for tests.

func (*FakeFile) Close

func (f *FakeFile) Close() error

Close marks the fake file closed.

func (*FakeFile) ContentMatches

func (f *FakeFile) ContentMatches(v []byte) bool

ContentMatches returns true if v matches fake file's content.

func (*FakeFile) GetContent

func (f *FakeFile) GetContent() []byte

GetContent the content of a fake file.

func (*FakeFile) Read

func (f *FakeFile) Read(p []byte) (n int, err error)

Read never fails, and doesn't mutate p.

func (*FakeFile) Stat

func (f *FakeFile) Stat() (os.FileInfo, error)

Stat returns nil.

func (*FakeFile) Write

func (f *FakeFile) Write(p []byte) (n int, err error)

Write saves the contents of the argument to memory.

type Fakefileinfo

type Fakefileinfo struct {
	*FakeFile
}

Fakefileinfo implements Fakefileinfo using a fake in-memory filesystem.

func (*Fakefileinfo) IsDir

func (fi *Fakefileinfo) IsDir() bool

IsDir returns if it is a directory

func (*Fakefileinfo) ModTime

func (fi *Fakefileinfo) ModTime() time.Time

ModTime returns the modification time

func (*Fakefileinfo) Mode

func (fi *Fakefileinfo) Mode() os.FileMode

Mode returns the file mode

func (*Fakefileinfo) Name

func (fi *Fakefileinfo) Name() string

Name returns the name of the file

func (*Fakefileinfo) Size

func (fi *Fakefileinfo) Size() int64

Size returns the size of the file

func (*Fakefileinfo) Sys

func (fi *Fakefileinfo) Sys() interface{}

Sys should return underlying data source, but it now returns nil

type File

type File interface {
	io.ReadWriteCloser
	Stat() (os.FileInfo, error)
}

File groups the basic os.File methods.

type FileSystem

type FileSystem interface {
	Create(name string) (File, error)
	Mkdir(name string) error
	MkdirAll(name string) error
	Open(name string) (File, error)
	IsDir(name string) bool
	Exists(name string) bool
	Glob(pattern string) ([]string, error)
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte) error
}

FileSystem groups basic os filesystem methods.

func MakeRealFS

func MakeRealFS() FileSystem

MakeRealFS makes an instance of realFS.

Jump to

Keyboard shortcuts

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