package storage
import "github.com/oslokommune/okctl/pkg/storage"
Package storage provides an API towards common storage operations
Index ¶
- type Cleaner
- type EphemeralStorage
- type Storage
- func NewFileSystemStorage(path string) *Storage
- func (s *Storage) Abs(name string) string
- func (s *Storage) Create(dir, file string, perms os.FileMode) (afero.File, error)
- func (s *Storage) Exists(name string) (bool, error)
- func (s *Storage) MkdirAll(dir string) error
- func (s *Storage) Path() string
- func (s *Storage) ReadAll(path string) ([]byte, error)
- func (s *Storage) Recreate(dir, file string, perms os.FileMode) (afero.File, error)
- func (s *Storage) RemoveAll(path string) error
- type StoreCleaner
- type Storer
- type TemporaryStorage
Types ¶
type Cleaner ¶
type Cleaner interface { Clean() error }
Cleaner provides an interface that may be implemented in order to cleanup a store
type EphemeralStorage ¶
type EphemeralStorage struct { *Storage }
EphemeralStorage wraps storage and implements the Cleaner interface
func NewEphemeralStorage ¶
func NewEphemeralStorage() *EphemeralStorage
NewEphemeralStorage will return an in memory file system
func (*EphemeralStorage) Clean ¶
func (e *EphemeralStorage) Clean() error
Clean simply instantiates a new in-memory store
type Storage ¶
Storage stores state about the filesystem
func NewFileSystemStorage ¶
NewFileSystemStorage will return a store to a base path filesystem
func (*Storage) Abs ¶
Abs will return the absolute path to a file
func (*Storage) Create ¶
Create will create all directories leading to a file and then the file itself
func (*Storage) Exists ¶
Exists will determine if a file exists
func (*Storage) MkdirAll ¶
MkdirAll creates a directory and all preceding directories if they do not exist
func (*Storage) Path ¶
Path returns the base path for the store
func (*Storage) ReadAll ¶
ReadAll returns all the content of a file
func (*Storage) Recreate ¶
Recreate will delete a file and then recreate it
func (*Storage) RemoveAll ¶
RemoveAll returns no error if it successfully remove everything under the given path
type StoreCleaner ¶
StoreCleaner provides an interface for a store that allows for common read and write operations and wiping everything afterwards
type Storer ¶
type Storer interface { Create(dir, name string, perms os.FileMode) (afero.File, error) Recreate(dir, file string, perms os.FileMode) (afero.File, error) RemoveAll(path string) error ReadAll(path string) ([]byte, error) MkdirAll(dir string) error Exists(name string) (bool, error) Abs(name string) string Path() string }
Storer provides an interface for creating and modifying files and directories
type TemporaryStorage ¶
type TemporaryStorage struct { *Storage }
TemporaryStorage wraps Storage and implements the Cleaner interface
func NewTemporaryStorage ¶
func NewTemporaryStorage() (*TemporaryStorage, error)
NewTemporaryStorage creates a new temporary storage
func (*TemporaryStorage) Clean ¶
func (s *TemporaryStorage) Clean() error
Clean removes everything at the path the filesystem was created from
Source Files ¶
- Version
- v0.0.106 (latest)
- Published
- Oct 21, 2022
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 18 hours ago –
Tools for package owners.