package os

import "github.com/containerd/containerd/pkg/os"

Index

Types

type OS

type OS interface {
	MkdirAll(path string, perm os.FileMode) error
	RemoveAll(path string) error
	Stat(name string) (os.FileInfo, error)
	ResolveSymbolicLink(name string) (string, error)
	FollowSymlinkInScope(path, scope string) (string, error)
	CopyFile(src, dest string, perm os.FileMode) error
	WriteFile(filename string, data []byte, perm os.FileMode) error
	Hostname() (string, error)
	Mount(source string, target string, fstype string, flags uintptr, data string) error
	Unmount(target string) error
	LookupMount(path string) (mount.Info, error)
}

OS collects system level operations that need to be mocked out during tests.

type RealOS

type RealOS struct{}

RealOS is used to dispatch the real system level operations.

func (RealOS) CopyFile

func (RealOS) CopyFile(src, dest string, perm os.FileMode) error

CopyFile will copy src file to dest file

func (RealOS) FollowSymlinkInScope

func (RealOS) FollowSymlinkInScope(path, scope string) (string, error)

FollowSymlinkInScope will call symlink.FollowSymlinkInScope.

func (RealOS) Hostname

func (RealOS) Hostname() (string, error)

Hostname will call os.Hostname to get the hostname of the host.

func (RealOS) LookupMount

func (RealOS) LookupMount(path string) (mount.Info, error)

LookupMount is an empty stub on Windows.

func (RealOS) MkdirAll

func (RealOS) MkdirAll(path string, perm os.FileMode) error

MkdirAll will call os.MkdirAll to create a directory.

func (RealOS) Mount

func (RealOS) Mount(source string, target string, fstype string, flags uintptr, data string) error

Mount is an empty stub on Windows.

func (RealOS) RemoveAll

func (RealOS) RemoveAll(path string) error

RemoveAll will call os.RemoveAll to remove the path and its children.

func (RealOS) ResolveSymbolicLink(path string) (string, error)

ResolveSymbolicLink will follow any symbolic links

func (RealOS) Stat

func (RealOS) Stat(name string) (os.FileInfo, error)

Stat will call os.Stat to get the status of the given file.

func (RealOS) Unmount

func (RealOS) Unmount(target string) error

Unmount is an empty stub on Windows.

func (RealOS) WriteFile

func (RealOS) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile will call os.WriteFile to write data into a file.

Source Files

mount_windows.go os.go os_windows.go

Directories

PathSynopsis
pkg/os/testing
Version
v1.7.0
Published
Mar 10, 2023
Platform
windows/amd64
Imports
9 packages
Last checked
1 minute ago

Tools for package owners.