filesystem

package
v0.0.0-...-b2eb650 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filesystem implements the operation of the local file system.

Index

Constants

View Source
const (
	// FileMode0777 represents the file mode 0755
	FileMode0777 = 0777
	// FileMode0755 represents the file mode 0755
	FileMode0755 = 0755
	// FileMode0644 represents the file mode 0644
	FileMode0644 = 0644
	// FileMode0664 represents the file mode 0664
	FileMode0664 = 0664
)
View Source
const (
	// DefaultLocalTmpDir represents the CAPKK default local tmp directory
	DefaultLocalTmpDir = "/var/lib/kubekey"
)

Variables

This section is empty.

Functions

func ToChmodPerm

func ToChmodPerm(m os.FileMode) (perm uint32)

ToChmodPerm converts Go permission bits to POSIX permission bits.

This differs from fromFileMode in that we preserve the POSIX versions of setuid, setgid and sticky in m, because we've historically supported those bits, and we mask off any non-permission bits.

Types

type FileSystem

type FileSystem struct {
}

FileSystem is a filesystem implementation

func (FileSystem) MD5Sum

func (f FileSystem) MD5Sum(localPath string) string

MD5Sum returns the file MD5 sum for the given local path.

func (FileSystem) MkLocalTmpDir

func (f FileSystem) MkLocalTmpDir() (string, error)

MkLocalTmpDir creates a temporary directory and returns the path

func (FileSystem) MkLocalTmpFile

func (f FileSystem) MkLocalTmpFile(dir, pattern string) (string, error)

MkLocalTmpFile creates a temporary file and returns the path.

func (FileSystem) MkdirAll

func (f FileSystem) MkdirAll(path string) error

MkdirAll the same as os.MkdirAll().

func (FileSystem) RemoveAll

func (f FileSystem) RemoveAll(path ...string) error

RemoveAll the same as os.RemoveAll().

func (FileSystem) SHA256Sum

func (f FileSystem) SHA256Sum(localPath string) string

SHA256Sum returns the file SHA256 sum for the given local path.

func (FileSystem) Stat

func (f FileSystem) Stat(name string) (os.FileInfo, error)

Stat returns the FileInfo for the given path

type Interface

type Interface interface {
	// Stat returns the FileInfo structure describing the named file.
	Stat(name string) (os.FileInfo, error)
	// MkdirAll the same as os.MkdirAll().
	MkdirAll(path string) error
	// MD5Sum returns the file MD5 sum for the given local path.
	MD5Sum(localPath string) string
	// SHA256Sum returns the file SHA256 sum for the given local path.
	SHA256Sum(localPath string) string
	// MkLocalTmpDir creates a temporary directory and returns the path.
	MkLocalTmpDir() (string, error)
	// MkLocalTmpFile creates a temporary file and returns the path.
	MkLocalTmpFile(dir, pattern string) (string, error)
	// RemoveAll the same as os.RemoveAll().
	RemoveAll(path ...string) error
}

Interface is an interface for filesystem operations

func NewFileSystem

func NewFileSystem() Interface

NewFileSystem returns a new CAPKK local filesystem implementation

Jump to

Keyboard shortcuts

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