package subpath
import "k8s.io/kubernetes/pkg/volume/util/subpath"
Index ¶
- type FakeMounter
- func NewFakeMounter(mps []mountutils.MountPoint) *FakeMounter
- func (f *FakeMounter) MountSensitiveWithFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error
- type FakeSubpath
- func (fs *FakeSubpath) CleanSubPaths(podDir string, volumeName string) error
- func (fs *FakeSubpath) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error)
- func (fs *FakeSubpath) SafeMakeDir(pathname string, base string, perm os.FileMode) error
- type Interface
- func New(mount.Interface) Interface
- func NewNSEnter(mounter mount.Interface, ne *nsenter.Nsenter, rootDir string) Interface
- type MountInterface
- type Mounter
- type Subpath
Types ¶
type FakeMounter ¶
type FakeMounter struct { *mountutils.FakeMounter }
FakeMounter implements MountInterface for tests.
func NewFakeMounter ¶
func NewFakeMounter(mps []mountutils.MountPoint) *FakeMounter
NewFakeMounter returns a FakeMounter struct that implements Interface and is suitable for testing purposes.
func (*FakeMounter) MountSensitiveWithFlags ¶
func (f *FakeMounter) MountSensitiveWithFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error
MountSensitiveWithFlags records the mount event and updates the in-memory mount points for FakeMounter sensitiveOptions to be passed in a separate parameter from the normal mount options and ensures the sensitiveOptions are never logged. This method should be used by callers that pass sensitive material (like passwords) as mount options.
type FakeSubpath ¶
type FakeSubpath struct{}
FakeSubpath is a subpather implementation for testing
func (*FakeSubpath) CleanSubPaths ¶
func (fs *FakeSubpath) CleanSubPaths(podDir string, volumeName string) error
CleanSubPaths is a fake implementation of CleanSubPaths. It is a noop
func (*FakeSubpath) PrepareSafeSubpath ¶
func (fs *FakeSubpath) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error)
PrepareSafeSubpath is a fake implementation of PrepareSafeSubpath. Always returns newHostPath == subPath.Path
func (*FakeSubpath) SafeMakeDir ¶
SafeMakeDir is a fake implementation of SafeMakeDir. It is a noop
type Interface ¶
type Interface interface { // CleanSubPaths removes any bind-mounts created by PrepareSafeSubpath in given // pod volume directory. CleanSubPaths(poodDir string, volumeName string) error // PrepareSafeSubpath does everything that's necessary to prepare a subPath // that's 1) inside given volumePath and 2) immutable after this call. // // newHostPath - location of prepared subPath. It should be used instead of // hostName when running the container. // cleanupAction - action to run when the container is running or it failed to start. // // CleanupAction must be called immediately after the container with given // subpath starts. On the other hand, Interface.CleanSubPaths must be called // when the pod finishes. PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) // SafeMakeDir creates subdir within given base. It makes sure that the // created directory does not escape given base directory mis-using // symlinks. Note that the function makes sure that it creates the directory // somewhere under the base, nothing else. E.g. if the directory already // exists, it may exist outside of the base due to symlinks. // This method should be used if the directory to create is inside volume // that's under user control. User must not be able to use symlinks to // escape the volume to create directories somewhere else. SafeMakeDir(subdir string, base string, perm os.FileMode) error }
Interface defines the set of methods all subpathers must implement
func New ¶
New returns a subpath.Interface for the current system.
func NewNSEnter ¶
NewNSEnter is to satisfy the compiler for having NewSubpathNSEnter exist for all OS choices. however, NSEnter is only valid on Linux
type MountInterface ¶
type MountInterface interface { mount.Interface // MountSensitiveWithFlags is the same as MountSensitive() with additional mount flags MountSensitiveWithFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error }
MountInterface defines the set of methods to allow for mount operations on a system.
func NewMounter ¶
func NewMounter(mounter mount.Interface, mounterPath string) MountInterface
NewMounter returns a MountInterface for the current system. It provides options to override the default mounter behavior. mounterPath allows using an alternative to `/bin/mount` for mounting.
type Mounter ¶
Mounter implements mount.Interface for unsupported platforms
func (*Mounter) MountSensitiveWithFlags ¶
func (mounter *Mounter) MountSensitiveWithFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error
MountSensitiveWithFlags is the same as MountSensitive() with additional mount flags
type Subpath ¶
type Subpath struct { // index of the VolumeMount for this container VolumeMountIndex int // Full path to the subpath directory on the host Path string // name of the volume that is a valid directory name. VolumeName string // Full path to the volume path VolumePath string // Path to the pod's directory, including pod UID PodDir string // Name of the container ContainerName string }
Subpath defines the attributes of a subpath
Source Files ¶
subpath.go subpath_fake_mounter.go subpath_mount.go subpath_mount_unsupported.go subpath_unsupported.go
- Version
- v1.19.15
- Published
- Sep 15, 2021
- Platform
- js/wasm
- Imports
- 4 packages
- Last checked
- 16 minutes ago –
Tools for package owners.