Documentation ¶
Overview ¶
Package filepath provides filepath storage related utilities.
Index ¶
- Variables
- func NewFilepathREST(fs FS, strategy Strategy, groupResource schema.GroupResource, ...) rest.Storage
- func NewJSONFilepathStorageProvider(obj resource.Object, rootPath string, fs FS, strategy Strategy) builderrest.ResourceHandlerProvider
- type FS
- type MemoryFS
- func (fs *MemoryFS) EnsureDir(dirname string) error
- func (fs *MemoryFS) Exists(p string) bool
- func (fs *MemoryFS) Read(decoder runtime.Decoder, p string, newFunc func() runtime.Object) (runtime.Object, error)
- func (fs *MemoryFS) Remove(p string) error
- func (fs *MemoryFS) VisitDir(dirname string, newFunc func() runtime.Object, codec runtime.Decoder, ...) error
- func (fs *MemoryFS) Write(encoder runtime.Encoder, p string, obj runtime.Object) error
- type RealFS
- func (fs RealFS) EnsureDir(dirname string) error
- func (fs RealFS) Exists(filepath string) bool
- func (fs RealFS) Read(decoder runtime.Decoder, path string, newFunc func() runtime.Object) (runtime.Object, error)
- func (fs RealFS) Remove(filepath string) error
- func (fs RealFS) VisitDir(dirname string, newFunc func() runtime.Object, codec runtime.Decoder, ...) error
- func (fs RealFS) Write(encoder runtime.Encoder, filepath string, obj runtime.Object) error
- type Strategy
Constants ¶
This section is empty.
Variables ¶
var ErrFileNotExists = fmt.Errorf("file doesn't exist")
ErrFileNotExists means the file doesn't actually exist.
var ErrNamespaceNotExists = errors.New("namespace does not exist")
ErrNamespaceNotExists means the directory for the namespace doesn't actually exist.
Functions ¶
func NewFilepathREST ¶
func NewFilepathREST( fs FS, strategy Strategy, groupResource schema.GroupResource, codec runtime.Codec, rootpath string, newFunc func() runtime.Object, newListFunc func() runtime.Object, ) rest.Storage
NewFilepathREST instantiates a new REST storage.
func NewJSONFilepathStorageProvider ¶
func NewJSONFilepathStorageProvider(obj resource.Object, rootPath string, fs FS, strategy Strategy) builderrest.ResourceHandlerProvider
NewJSONFilepathStorageProvider use local host path as persistent layer storage:
For namespaced-scoped resources: the resource will be written under the root-path in the following structure:
-- (root-path) --- /namespace1/ --- resource1 | | | --- resource2 | --- /namespace2/ --- resource3
For cluster-scoped resources, there will be no mid-layer folders for namespaces:
-- (root-path) --- resource1 | --- resource2 | --- resource3
An example of storing example resource to local filepath will be:
builder.APIServer. WithResourceAndHandler(&v1alpha1.ExampleResource{}, jsonfile.NewJsonFileStorageProvider(&v1alpha1.ExampleResource{}, /*the root file-path*/ "data")). Build()
Types ¶
type FS ¶
type FS interface { Remove(filepath string) error Exists(filepath string) bool EnsureDir(dirname string) error Write(encoder runtime.Encoder, filepath string, obj runtime.Object) error Read(decoder runtime.Decoder, path string, newFunc func() runtime.Object) (runtime.Object, error) VisitDir(dirname string, newFunc func() runtime.Object, codec runtime.Decoder, visitFunc func(string, runtime.Object)) error }
A filesystem interface so we can sub out filesystem-based storage with memory-based storage.
type MemoryFS ¶
type MemoryFS struct {
// contains filtered or unexported fields
}
An in-memory structure that pretends to be a filesystem, and supports all the storage interfaces that RealFS needs.
func NewMemoryFS ¶
func NewMemoryFS() *MemoryFS
func (*MemoryFS) Read ¶
func (fs *MemoryFS) Read(decoder runtime.Decoder, p string, newFunc func() runtime.Object) (runtime.Object, error)
Read a copy of the object from our in-memory filesystem.
type Strategy ¶ added in v0.2.1
type Strategy interface { rest.RESTUpdateStrategy rest.RESTCreateStrategy rest.RESTDeleteStrategy }