Documentation ¶
Index ¶
- func ClearFolders(fileMgr ClearFoldersOSFileManager, paths []string) (removedFiles []string, e error)
- type ClearFoldersOSFileManager
- type File
- type Manager
- type ManagerImpl
- type OSFileManager
- type StdLibOSFileManager
- func (s *StdLibOSFileManager) Chmod(file *os.File, mode os.FileMode) error
- func (s *StdLibOSFileManager) Create(name string) (*os.File, error)
- func (s *StdLibOSFileManager) ReadDir(dirname string) ([]fs.DirEntry, error)
- func (s *StdLibOSFileManager) Remove(name string) error
- func (s *StdLibOSFileManager) Write(file *os.File, contents []byte) error
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearFolders ¶
func ClearFolders(fileMgr ClearFoldersOSFileManager, paths []string) (removedFiles []string, e error)
ClearFolders removes all files in the given folders and returns the removed files' full paths.
Types ¶
type ClearFoldersOSFileManager ¶
type ClearFoldersOSFileManager interface { // ReadDir returns the directory entries for the directory. ReadDir(dirname string) ([]os.DirEntry, error) // Remove removes the file with given name. Remove(name string) error }
ClearFoldersOSFileManager is an interface that exposes File I/O operations for ClearFolders. Used for unit testing.
type Manager ¶
type Manager interface { // ReplaceFiles replaces the files on the file system with the given files removing any previous files. ReplaceFiles(files []File) error }
Manager manages NGINX configuration files.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl is an implementation of Manager. Note: It is not thread safe.
func NewManagerImpl ¶
func NewManagerImpl(logger logr.Logger, osFileManager OSFileManager) *ManagerImpl
NewManagerImpl creates a new NewManagerImpl.
func (*ManagerImpl) ReplaceFiles ¶
func (m *ManagerImpl) ReplaceFiles(files []File) error
ReplaceFiles replaces the files on the file system with the given files removing any previous files. It panics if a file type is unknown.
type OSFileManager ¶
type OSFileManager interface { // ReadDir returns the directory entries for the directory. ReadDir(dirname string) ([]fs.DirEntry, error) // Remove file with given name. Remove(name string) error // Create file at the provided filepath. Create(name string) (*os.File, error) // Chmod sets the mode of the file. Chmod(file *os.File, mode os.FileMode) error // Write writes contents to the file. Write(file *os.File, contents []byte) error }
OSFileManager is an interface that exposes File I/O operations for ManagerImpl. Used for unit testing.
type StdLibOSFileManager ¶
type StdLibOSFileManager struct{}
StdLibOSFileManager wraps the standard library's file operations. Clients can define an interface with all or a subset StdLibOSFileManager methods and use it in their types or functions, so that they can be unit tested. It is expected that clients generate fakes.
func NewStdLibOSFileManager ¶
func NewStdLibOSFileManager() *StdLibOSFileManager
func (*StdLibOSFileManager) Create ¶
func (s *StdLibOSFileManager) Create(name string) (*os.File, error)
Create wraps os.Create.
func (*StdLibOSFileManager) ReadDir ¶
func (s *StdLibOSFileManager) ReadDir(dirname string) ([]fs.DirEntry, error)
ReadDir wraps os.ReadDir.
func (*StdLibOSFileManager) Remove ¶
func (s *StdLibOSFileManager) Remove(name string) error
Remove wraps os.Remove.