osutils

package
v0.0.0-...-eec02a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Centos = "centos"
	RHEL   = "rhel"
	Ubuntu = "ubuntu"
	Debian = "debian"
)

Variables

View Source
var ChrootPathPrefix string

Functions

func GetTargetFilePath

func GetTargetFilePath(ctx context.Context, resourcePath, arg string) string

GetTargetFilePath method returns the path of target file based on OS.

func SMBActiveOnHost

func SMBActiveOnHost(ctx context.Context) (bool, error)

SMBActiveOnHost will always return false on non-windows platform

func SetChrootPathPrefix

func SetChrootPathPrefix(prefix string)

Types

type NetLink interface {
	LinkList() ([]netlink.Link, error)
	AddrList(link netlink.Link, family int) ([]netlink.Addr, error)
	RouteListFiltered(family int, filter *netlink.Route, filterMask uint64) ([]netlink.Route, error)
	LinkByIndex(index int) (netlink.Link, error)
}

type NetLinkClient

type NetLinkClient struct{}

func NewNetLinkClient

func NewNetLinkClient() *NetLinkClient

func (*NetLinkClient) AddrList

func (n *NetLinkClient) AddrList(link netlink.Link, family int) ([]netlink.Addr, error)

func (*NetLinkClient) LinkByIndex

func (n *NetLinkClient) LinkByIndex(index int) (netlink.Link, error)
func (n *NetLinkClient) LinkList() ([]netlink.Link, error)

func (*NetLinkClient) RouteListFiltered

func (n *NetLinkClient) RouteListFiltered(family int, filter *netlink.Route, filterMask uint64) ([]netlink.Route, error)

type OSUtils

type OSUtils struct {
	// contains filtered or unexported fields
}

func New

func New() *OSUtils

func NewDetailed

func NewDetailed(command exec.Command, osFs afero.Fs) *OSUtils

func (*OSUtils) DeleteResourceAtPath

func (o *OSUtils) DeleteResourceAtPath(ctx context.Context, resource string) error

DeleteResourceAtPath makes sure that given named file or (empty) directory is removed

func (*OSUtils) EnsureDirExists

func (o *OSUtils) EnsureDirExists(ctx context.Context, path string) error

EnsureDirExists makes sure that given directory structure exists

func (*OSUtils) EnsureFileExists

func (o *OSUtils) EnsureFileExists(ctx context.Context, path string) error

EnsureFileExists makes sure that file of given name exists

func (o *OSUtils) EvalSymlinks(path string) (string, error)

func (*OSUtils) GetHostSystemInfo

func (o *OSUtils) GetHostSystemInfo(ctx context.Context) (*models.HostSystem, error)

GetHostSystemInfo returns information about the host system

func (*OSUtils) GetIPAddresses

func (o *OSUtils) GetIPAddresses(ctx context.Context) ([]string, error)

GetIPAddresses returns the sorted list of Global Unicast IP addresses available to Trident

func (*OSUtils) IsLikelyDir

func (o *OSUtils) IsLikelyDir(mountpoint string) (bool, error)

IsLikelyDir determines if mountpoint is a directory

func (*OSUtils) NFSActiveOnHost

func (o *OSUtils) NFSActiveOnHost(ctx context.Context) (bool, error)

NFSActiveOnHost will return if the rpc-statd daemon is active on the given host

func (*OSUtils) PathExists

func (o *OSUtils) PathExists(path string) (bool, error)

PathExists returns if path exists. This should only be used if the call will not block if the path or volume is inaccessible.

func (*OSUtils) PathExistsWithTimeout

func (o *OSUtils) PathExistsWithTimeout(ctx context.Context, path string, timeout time.Duration) (bool, error)

PathExistsWithTimeout returns if path exists, and can return a timeout error on linux; windows ignores the timeout. Context timeouts may be ignored and are handled by the underlying implementation. This should be used instead of PathExists if there is a chance the call will block if the path or volume is inaccessible, such as on an NFS mount.

func (*OSUtils) ServiceActiveOnHost

func (o *OSUtils) ServiceActiveOnHost(ctx context.Context, service string) (bool, error)

ServiceActiveOnHost checks if the service is currently running

func (*OSUtils) WaitForResourceDeletionAtPath

func (o *OSUtils) WaitForResourceDeletionAtPath(ctx context.Context, resource string, maxDuration time.Duration) error

WaitForResourceDeletionAtPath accepts a resource name and waits until it is deleted and returns error if it times out

type Utils

type Utils interface {
	NFSActiveOnHost(ctx context.Context) (bool, error)
	ServiceActiveOnHost(ctx context.Context, service string) (bool, error)
	GetHostSystemInfo(ctx context.Context) (*models.HostSystem, error)
	GetIPAddresses(ctx context.Context) ([]string, error)
	PathExists(path string) (bool, error)
	PathExistsWithTimeout(ctx context.Context, path string, timeout time.Duration) (bool, error)
	IsLikelyDir(mountpoint string) (bool, error)
	DeleteResourceAtPath(ctx context.Context, resource string) error
	WaitForResourceDeletionAtPath(ctx context.Context, resource string, maxDuration time.Duration) error
	EnsureFileExists(ctx context.Context, path string) error
	EnsureDirExists(ctx context.Context, path string) error
	EvalSymlinks(path string) (string, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL