Documentation ¶
Overview ¶
Package fs provides wrappers for os/fs dependent operations.
Index ¶
- type FileInfo
- type Fs
- func (fs *Fs) Chmod(name string, perm os.FileMode) error
- func (fs *Fs) Create(name string) (*os.File, error)
- func (fs *Fs) ExecCommand(name string, args ...string) ([]byte, error)
- func (fs *Fs) ExecCommandOutput(name string, args ...string) ([]byte, error)
- func (fs *Fs) GetUtil() UtilInterface
- func (fs *Fs) IsDeviceOrResourceBusy(err error) bool
- func (fs *Fs) IsNotExist(err error) bool
- func (fs *Fs) MkFileIdempotent(path string) (bool, error)
- func (fs *Fs) Mkdir(name string, perm os.FileMode) error
- func (fs *Fs) MkdirAll(name string, perm os.FileMode) error
- func (fs *Fs) NetDial(endpoint string) (net.Conn, error)
- func (fs *Fs) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (fs *Fs) ParseProcMounts(ctx context.Context, content io.Reader) ([]gofsutil.Info, error)
- func (fs *Fs) ReadFile(name string) ([]byte, error)
- func (fs *Fs) Remove(name string) error
- func (fs *Fs) RemoveAll(name string) error
- func (fs *Fs) Stat(name string) (FileInfo, error)
- func (fs *Fs) WriteFile(filename string, data []byte, perm os.FileMode) error
- func (fs *Fs) WriteString(file *os.File, string string) (int, error)
- type Interface
- type UtilInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶
type FileInfo interface { Name() string // base name of the file Size() int64 // length in bytes for regular files; system-dependent for others Mode() os.FileMode // file mode bits ModTime() time.Time // modification time IsDir() bool // abbreviation for Mode().IsDir() Sys() interface{} // underlying data source (can return nil) }
A FileInfo describes a file and is returned by Stat and Lstat.
type Fs ¶
Fs implementation of FsInterface that uses default os/file calls
func (*Fs) ExecCommand ¶
ExecCommand is a wrapper of exec.Command that returns CombinedOutput
func (*Fs) ExecCommandOutput ¶
ExecCommandOutput is a wrapper of exec.Command that returns default Output
func (*Fs) GetUtil ¶
func (fs *Fs) GetUtil() UtilInterface
GetUtil returns gofsutil.fs wrapper -- UtilInterface.
func (*Fs) IsDeviceOrResourceBusy ¶
IsDeviceOrResourceBusy checks for device or resource busy error
func (*Fs) IsNotExist ¶
IsNotExist is a wrapper of os.IsNotExist
func (*Fs) MkFileIdempotent ¶
MkFileIdempotent creates file if there is none
func (*Fs) ParseProcMounts ¶
ParseProcMounts is wrapper of gofsutil.ReadProcMountsFrom global function
type Interface ¶
type Interface interface { OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) Stat(name string) (FileInfo, error) Create(name string) (*os.File, error) ReadFile(name string) ([]byte, error) WriteFile(filename string, data []byte, perm os.FileMode) error IsNotExist(err error) bool IsDeviceOrResourceBusy(err error) bool Mkdir(name string, perm os.FileMode) error MkdirAll(name string, perm os.FileMode) error Chmod(name string, perm os.FileMode) error Remove(name string) error RemoveAll(name string) error WriteString(file *os.File, str string) (int, error) ExecCommand(name string, args ...string) ([]byte, error) ExecCommandOutput(name string, args ...string) ([]byte, error) GetUtil() UtilInterface // wrapper ParseProcMounts(ctx context.Context, content io.Reader) ([]gofsutil.Info, error) MkFileIdempotent(path string) (bool, error) // Network NetDial(endpoint string) (net.Conn, error) }
Interface wraps usual os and fs related calls so they can be mocked. Also Interface provides access to the gofsutil wrapper UtilInterface with GetUtil() method.
type UtilInterface ¶
type UtilInterface interface { GetDiskFormat(ctx context.Context, disk string) (string, error) Format(ctx context.Context, source, target, fsType string, options ...string) error FormatAndMount(ctx context.Context, source, target, fsType string, options ...string) error Mount(ctx context.Context, source, target, fsType string, options ...string) error BindMount(ctx context.Context, source, target string, options ...string) error Unmount(ctx context.Context, target string) error GetMounts(ctx context.Context) ([]gofsutil.Info, error) GetDevMounts(ctx context.Context, dev string) ([]gofsutil.Info, error) ValidateDevice(ctx context.Context, source string) (string, error) WWNToDevicePath(ctx context.Context, wwn string) (string, string, error) RescanSCSIHost(ctx context.Context, targets []string, lun string) error RemoveBlockDevice(ctx context.Context, blockDevicePath string) error TargetIPLUNToDevicePath(ctx context.Context, targetIP string, lunID int) (map[string]string, error) MultipathCommand(ctx context.Context, timeout time.Duration, chroot string, arguments ...string) ([]byte, error) GetFCHostPortWWNs(ctx context.Context) ([]string, error) IssueLIPToAllFCHosts(ctx context.Context) error GetSysBlockDevicesForVolumeWWN(ctx context.Context, volumeWWN string) ([]string, error) DeviceRescan(ctx context.Context, devicePath string) error ResizeFS(ctx context.Context, volumePath, devicePath, ppathDevice, mpathDevice, fsType string) error GetMountInfoFromDevice(ctx context.Context, devID string) (*gofsutil.DeviceMountInfo, error) ResizeMultipath(ctx context.Context, deviceName string) error FindFSType(ctx context.Context, mountpoint string) (fsType string, err error) GetMpathNameFromDevice(ctx context.Context, device string) (string, error) }
UtilInterface is a wrapper of gofsutil.fs functions so they can be mocked