Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
      View Source
      
  
    const ( // DeviceTypeLoop is the device type for loop devices in lsblk output DeviceTypeLoop = "loop" // DeviceTypeROM is the device type for ROM devices in lsblk output DeviceTypeROM = "rom" // DeviceTypeLVM is the device type for lvm devices in lsblk output DeviceTypeLVM = "lvm" )
      View Source
      
  
const LSBLK_COLUMNS = "NAME,ROTA,TYPE,SIZE,MODEL,VENDOR,RO,STATE,KNAME,SERIAL,PARTLABEL,FSTYPE"
    Variables ¶
      View Source
      
  
var ( DefaultLosetup = "/usr/sbin/losetup" DefaultLsblk = "/usr/bin/lsblk" )
Functions ¶
func FlattenedBlockDevices ¶
func FlattenedBlockDevices(bs []BlockDevice) map[string]BlockDevice
Types ¶
type BlockDevice ¶
type BlockDevice struct {
	Name      string        `json:"name"`
	KName     string        `json:"kname"`
	Type      string        `json:"type"`
	Model     string        `json:"model,omitempty"`
	Vendor    string        `json:"vendor,omitempty"`
	State     string        `json:"state,omitempty"`
	FSType    string        `json:"fstype"`
	Size      string        `json:"size"`
	Children  []BlockDevice `json:"children,omitempty"`
	ReadOnly  bool          `json:"ro,omitempty"`
	Serial    string        `json:"serial,omitempty"`
	PartLabel string        `json:"partLabel,omitempty"`
}
    BlockDevice is the block device as output by lsblk. All the fields are lsblk columns.
func (BlockDevice) HasChildren ¶
func (b BlockDevice) HasChildren() bool
HasChildren checks if the disk has partitions
type BlockDeviceInfo ¶
type BlockDeviceInfo struct {
	IsUsableLoopDev bool
}
    type BlockDeviceInfos ¶
type BlockDeviceInfos map[string]BlockDeviceInfo
type HostLSBLK ¶
func NewDefaultHostLSBLK ¶
func NewDefaultHostLSBLK() *HostLSBLK
func (*HostLSBLK) BlockDeviceInfos ¶
func (lsblk *HostLSBLK) BlockDeviceInfos(ctx context.Context, bs []BlockDevice) (BlockDeviceInfos, error)
func (*HostLSBLK) IsUsableLoopDev ¶
IsUsableLoopDev returns true if the loop device isn't in use by Kubernetes by matching the back file path against a standard string used to mount devices from host into pods
func (*HostLSBLK) ListBlockDevices ¶
func (lsblk *HostLSBLK) ListBlockDevices(ctx context.Context) ([]BlockDevice, error)
ListBlockDevices lists the block devices using the lsblk command
type LSBLK ¶
type LSBLK interface {
	ListBlockDevices(ctx context.Context) ([]BlockDevice, error)
	IsUsableLoopDev(ctx context.Context, b BlockDevice) (bool, error)
	BlockDeviceInfos(ctx context.Context, bs []BlockDevice) (BlockDeviceInfos, error)
}
     Click to show internal directories. 
   Click to hide internal directories.