Documentation ¶
Index ¶
- func GetScriptArgs() []string
- func MassagePathError(basePath string, err error) error
- func ResolvePath(base, path, op string) (string, error)
- func SetScriptArgs(args []string)
- func WithOS(ctx context.Context, osObj OS) context.Context
- type DirEntry
- type DirEntryWrapper
- type ExitHandler
- type FS
- type File
- type FileInfo
- type FileMode
- type GenericDirEntry
- type GenericDirEntryOpts
- type GenericFileInfo
- type GenericFileInfoOpts
- type InMemoryFile
- func (f *InMemoryFile) Bytes() []byte
- func (f *InMemoryFile) Close() error
- func (f *InMemoryFile) Read(p []byte) (n int, err error)
- func (f *InMemoryFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *InMemoryFile) Seek(offset int64, whence int) (int64, error)
- func (f *InMemoryFile) Stat() (FileInfo, error)
- func (f *InMemoryFile) Write(p []byte) (n int, err error)
- type Mount
- type NilFile
- func (f *NilFile) Close() error
- func (f *NilFile) Read(p []byte) (n int, err error)
- func (f *NilFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *NilFile) Seek(offset int64, whence int) (int64, error)
- func (f *NilFile) Stat() (FileInfo, error)
- func (f *NilFile) Write(p []byte) (n int, err error)
- type OS
- type Option
- func WithArgs(args []string) Option
- func WithCwd(cwd string) Option
- func WithEnvironment(env map[string]string) Option
- func WithExitHandler(exitHandler ExitHandler) Option
- func WithHostname(hostname string) Option
- func WithMounts(mounts map[string]*Mount) Option
- func WithPid(pid int) Option
- func WithStdin(stdin File) Option
- func WithStdout(stdout File) Option
- func WithTmp(tmp string) Option
- func WithUid(uid int) Option
- func WithUserCacheDir(dir string) Option
- func WithUserConfigDir(dir string) Option
- func WithUserHomeDir(dir string) Option
- type ReadDirFile
- type SimpleOS
- func (osObj *SimpleOS) Args() []string
- func (osObj *SimpleOS) Chdir(dir string) error
- func (osObj *SimpleOS) Create(name string) (File, error)
- func (osObj *SimpleOS) Environ() []string
- func (osObj *SimpleOS) Exit(code int)
- func (osObj *SimpleOS) Getenv(key string) string
- func (osObj *SimpleOS) Getpid() int
- func (osObj *SimpleOS) Getuid() int
- func (osObj *SimpleOS) Getwd() (string, error)
- func (osObj *SimpleOS) Hostname() (string, error)
- func (osObj *SimpleOS) LookupEnv(key string) (string, bool)
- func (osObj *SimpleOS) Mkdir(name string, perm FileMode) error
- func (osObj *SimpleOS) MkdirAll(path string, perm FileMode) error
- func (osObj *SimpleOS) MkdirTemp(dir, pattern string) (string, error)
- func (osObj *SimpleOS) Open(name string) (File, error)
- func (osObj *SimpleOS) ReadDir(name string) ([]DirEntry, error)
- func (osObj *SimpleOS) ReadFile(name string) ([]byte, error)
- func (osObj *SimpleOS) Remove(name string) error
- func (osObj *SimpleOS) RemoveAll(path string) error
- func (osObj *SimpleOS) Rename(oldpath, newpath string) error
- func (osObj *SimpleOS) Setenv(key, value string) error
- func (osObj *SimpleOS) Stat(name string) (os.FileInfo, error)
- func (osObj *SimpleOS) Stdin() File
- func (osObj *SimpleOS) Stdout() File
- func (osObj *SimpleOS) Symlink(oldname, newname string) error
- func (osObj *SimpleOS) TempDir() string
- func (osObj *SimpleOS) Unsetenv(key string) error
- func (osObj *SimpleOS) UserCacheDir() (string, error)
- func (osObj *SimpleOS) UserConfigDir() (string, error)
- func (osObj *SimpleOS) UserHomeDir() (string, error)
- func (osObj *SimpleOS) WalkDir(root string, fn WalkDirFunc) error
- func (osObj *SimpleOS) WriteFile(name string, data []byte, perm FileMode) error
- type VirtualOS
- func (osObj *VirtualOS) Args() []string
- func (osObj *VirtualOS) Chdir(dir string) error
- func (osObj *VirtualOS) Create(name string) (File, error)
- func (osObj *VirtualOS) Environ() []string
- func (osObj *VirtualOS) Exit(code int)
- func (osObj *VirtualOS) Getenv(key string) string
- func (osObj *VirtualOS) Getpid() int
- func (osObj *VirtualOS) Getuid() int
- func (osObj *VirtualOS) Getwd() (string, error)
- func (osObj *VirtualOS) Hostname() (string, error)
- func (osObj *VirtualOS) LookupEnv(key string) (string, bool)
- func (osObj *VirtualOS) Mkdir(name string, perm FileMode) error
- func (osObj *VirtualOS) MkdirAll(path string, perm FileMode) error
- func (osObj *VirtualOS) MkdirTemp(dir, pattern string) (string, error)
- func (osObj *VirtualOS) Open(name string) (File, error)
- func (osObj *VirtualOS) ReadDir(name string) ([]DirEntry, error)
- func (osObj *VirtualOS) ReadFile(name string) ([]byte, error)
- func (osObj *VirtualOS) Remove(name string) error
- func (osObj *VirtualOS) RemoveAll(path string) error
- func (osObj *VirtualOS) Rename(oldpath, newpath string) error
- func (osObj *VirtualOS) SetArgs(args []string)
- func (osObj *VirtualOS) Setenv(key, value string) error
- func (osObj *VirtualOS) Stat(name string) (os.FileInfo, error)
- func (osObj *VirtualOS) Stdin() File
- func (osObj *VirtualOS) Stdout() File
- func (osObj *VirtualOS) Symlink(oldname, newname string) error
- func (osObj *VirtualOS) TempDir() string
- func (osObj *VirtualOS) Unsetenv(key string) error
- func (osObj *VirtualOS) UserCacheDir() (string, error)
- func (osObj *VirtualOS) UserConfigDir() (string, error)
- func (osObj *VirtualOS) UserHomeDir() (string, error)
- func (osObj *VirtualOS) WalkDir(root string, fn WalkDirFunc) error
- func (osObj *VirtualOS) WriteFile(name string, data []byte, perm FileMode) error
- type WalkDirFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetScriptArgs ¶ added in v1.1.0
func GetScriptArgs() []string
if risor is started from the comand line and args are passed in, this is is how the to get them
func MassagePathError ¶
MassagePathError transforms a fs.PathError into a new one with the base path removed from the Path field.
func ResolvePath ¶
ResolvePath resolves a path relative to a base path. An error is returned if the path is invalid.
func SetScriptArgs ¶ added in v1.1.0
func SetScriptArgs(args []string)
if risor is started from the comand line and args are passed in, this is is how the to tell the os package about them
Types ¶
type DirEntryWrapper ¶
func (*DirEntryWrapper) HasInfo ¶
func (de *DirEntryWrapper) HasInfo() bool
type ExitHandler ¶
type ExitHandler func(int)
type FS ¶
type FS interface { Create(name string) (File, error) Mkdir(name string, perm FileMode) error MkdirAll(path string, perm FileMode) error Open(name string) (File, error) ReadFile(name string) ([]byte, error) Remove(name string) error RemoveAll(path string) error Rename(oldpath, newpath string) error Stat(name string) (FileInfo, error) Symlink(oldname, newname string) error WriteFile(name string, data []byte, perm FileMode) error ReadDir(name string) ([]DirEntry, error) WalkDir(root string, fn WalkDirFunc) error }
type GenericDirEntry ¶
type GenericDirEntry struct {
// contains filtered or unexported fields
}
func NewDirEntry ¶
func NewDirEntry(opts GenericDirEntryOpts) *GenericDirEntry
func (*GenericDirEntry) HasInfo ¶
func (de *GenericDirEntry) HasInfo() bool
func (*GenericDirEntry) Info ¶
func (de *GenericDirEntry) Info() (FileInfo, error)
func (*GenericDirEntry) IsDir ¶
func (de *GenericDirEntry) IsDir() bool
func (*GenericDirEntry) Name ¶
func (de *GenericDirEntry) Name() string
func (*GenericDirEntry) Type ¶
func (de *GenericDirEntry) Type() FileMode
type GenericDirEntryOpts ¶
type GenericDirEntryOpts struct { Name string Mode FileMode Info *GenericFileInfo }
type GenericFileInfo ¶
type GenericFileInfo struct {
// contains filtered or unexported fields
}
func NewFileInfo ¶
func NewFileInfo(opts GenericFileInfoOpts) *GenericFileInfo
func (*GenericFileInfo) IsDir ¶
func (fi *GenericFileInfo) IsDir() bool
func (*GenericFileInfo) ModTime ¶
func (fi *GenericFileInfo) ModTime() time.Time
func (*GenericFileInfo) Mode ¶
func (fi *GenericFileInfo) Mode() FileMode
func (*GenericFileInfo) Name ¶
func (fi *GenericFileInfo) Name() string
func (*GenericFileInfo) Size ¶
func (fi *GenericFileInfo) Size() int64
func (*GenericFileInfo) Sys ¶
func (fi *GenericFileInfo) Sys() interface{}
type GenericFileInfoOpts ¶
type InMemoryFile ¶ added in v0.10.0
type InMemoryFile struct {
// contains filtered or unexported fields
}
func NewInMemoryFile ¶ added in v0.10.0
func NewInMemoryFile(data []byte) *InMemoryFile
func (*InMemoryFile) Bytes ¶ added in v0.10.0
func (f *InMemoryFile) Bytes() []byte
func (*InMemoryFile) Close ¶ added in v0.10.0
func (f *InMemoryFile) Close() error
func (*InMemoryFile) Read ¶ added in v0.10.0
func (f *InMemoryFile) Read(p []byte) (n int, err error)
func (*InMemoryFile) ReadAt ¶ added in v0.10.0
func (f *InMemoryFile) ReadAt(p []byte, off int64) (n int, err error)
func (*InMemoryFile) Seek ¶ added in v0.10.0
func (f *InMemoryFile) Seek(offset int64, whence int) (int64, error)
func (*InMemoryFile) Stat ¶ added in v0.10.0
func (f *InMemoryFile) Stat() (FileInfo, error)
type NilFile ¶ added in v0.10.0
type NilFile struct{}
type OS ¶
type OS interface { FS Args() []string Chdir(dir string) error Environ() []string Exit(code int) Getenv(key string) string Getpid() int Getuid() int Getwd() (dir string, err error) Hostname() (name string, err error) LookupEnv(key string) (string, bool) MkdirTemp(dir, pattern string) (string, error) Setenv(key, value string) error TempDir() string Unsetenv(key string) error UserCacheDir() (string, error) UserConfigDir() (string, error) UserHomeDir() (string, error) Stdin() File Stdout() File }
func GetDefaultOS ¶ added in v0.10.0
GetDefaultOS returns the OS from the context, if it exists. Otherwise, it returns a new SimpleOS.
type Option ¶
type Option func(*VirtualOS)
Option is a configuration function for a Virtual Machine.
func WithEnvironment ¶
WithEnvironment sets the user home directory.
func WithExitHandler ¶
func WithExitHandler(exitHandler ExitHandler) Option
WithExitHandler sets the exit handler.
func WithUserCacheDir ¶
WithUserCacheDir sets the user cache directory.
func WithUserConfigDir ¶
WithUserConfigDir sets the user config directory.
func WithUserHomeDir ¶
WithUserHomeDir sets the user home directory.
type ReadDirFile ¶
type ReadDirFile = fs.ReadDirFile
type SimpleOS ¶
type SimpleOS struct {
// contains filtered or unexported fields
}
func NewSimpleOS ¶
func (*SimpleOS) UserCacheDir ¶
func (*SimpleOS) UserConfigDir ¶
func (*SimpleOS) UserHomeDir ¶
type VirtualOS ¶
type VirtualOS struct {
// contains filtered or unexported fields
}
func NewVirtualOS ¶
NewVirtualOS creates a new VirtualOS configured with the given options.
func (*VirtualOS) SetArgs ¶ added in v1.1.0
a way to override or set the args passed to the os package would typically be used when risor is employed in an embedded manner
func (*VirtualOS) UserCacheDir ¶
func (*VirtualOS) UserConfigDir ¶
func (*VirtualOS) UserHomeDir ¶
type WalkDirFunc ¶ added in v1.2.0
type WalkDirFunc = fs.WalkDirFunc