Documentation ¶
Overview ¶
Package diskutil provides the functionality necessary for interacting with macOS's diskutil CLI.
Index ¶
- Variables
- func Dryrun(impl DiskUtil) *readonlyWrapper
- func GrowContainer(ctx context.Context, u DiskUtil, container *types.DiskInfo) error
- type APFS
- type APFSImpl
- type Decoder
- type DiskUtil
- type DiskUtilityCmd
- func (d *DiskUtilityCmd) Info(ctx context.Context, id string) (string, error)
- func (d *DiskUtilityCmd) List(ctx context.Context, args []string) (string, error)
- func (d *DiskUtilityCmd) RepairDisk(ctx context.Context, id string) (string, error)
- func (d *DiskUtilityCmd) ResizeContainer(ctx context.Context, id string, size string) (string, error)
- type FreeSpaceError
- type PlistDecoder
- type UtilImpl
Constants ¶
This section is empty.
Variables ¶
var ErrReadOnly = errors.New("read-only mode")
ErrReadOnly identifies errors due to dry-run not being able to continue without mutating changes.
Functions ¶
func Dryrun ¶
func Dryrun(impl DiskUtil) *readonlyWrapper
Dryrun takes a DiskUtil implementation and wraps the mutating methods with dryrun alternatives.
func GrowContainer ¶
GrowContainer grows a container to its maximum size by performing the following operations:
- Verify that the given types.DiskInfo is an APFS container that can be resized.
- Fetch the types.DiskInfo for the underlying physical disk (if the container isn't a physical device).
- Repair the parent disk to force the kernel to get the latest GPT information for the disk.
- Check if there's enough free space on the disk to perform an APFS.ResizeContainer.
- Resize the container to its maximum size.
Types ¶
type APFS ¶
type APFS interface { // ResizeContainer attempts to grow the APFS container with the given device identifier // to the specified size. If the given size is 0, ResizeContainer will attempt to grow // the disk to its maximum size. ResizeContainer(ctx context.Context, id string, size string) (string, error) }
APFS outlines the functionality necessary for wrapping diskutil's "apfs" verb.
type APFSImpl ¶
type APFSImpl interface { // ResizeContainer attempts to grow the APFS container with the given device identifier // to the specified size. If the given size is 0, ResizeContainer will attempt to grow // the disk to its maximum size. ResizeContainer(ctx context.Context, id string, size string) (string, error) }
APFSImpl outlines the functionality necessary for wrapping diskutil's APFS verb.
type Decoder ¶
type Decoder interface { // DecodeSystemPartitions takes an io.ReadSeeker for the raw plist data of all disks and partition information // and decodes it into a new types.SystemPartitions struct. DecodeSystemPartitions(reader io.ReadSeeker) (*types.SystemPartitions, error) // DecodeDiskInfo takes an io.ReadSeeker for the raw plist data of disk information and decodes it into // a new types.DiskInfo struct. DecodeDiskInfo(reader io.ReadSeeker) (*types.DiskInfo, error) }
Decoder outlines the functionality necessary for decoding plist output from the macOS diskutil command.
type DiskUtil ¶
type DiskUtil interface { // APFS outlines the functionality necessary for wrapping diskutil's "apfs" verb. APFS // Info fetches raw disk information for the specified device identifier. Info(ctx context.Context, id string) (*types.DiskInfo, error) // List fetches all disk and partition information for the system. // This output will be filtered based on the args provided. List(ctx context.Context, args []string) (*types.SystemPartitions, error) // RepairDisk attempts to repair the disk for the specified device identifier. // This process requires root access. RepairDisk(ctx context.Context, id string) (string, error) }
DiskUtil outlines the functionality necessary for wrapping macOS's diskutil tool.
type DiskUtilityCmd ¶
type DiskUtilityCmd struct{}
DiskUtilityCmd is an empty struct that provides the implementation for the DiskUtility interface.
func (*DiskUtilityCmd) Info ¶
Info uses the macOS diskutil info command to get detailed information about a disk, partition, or container format by passing the -plist arg.
func (*DiskUtilityCmd) List ¶
List uses the macOS diskutil list command to list disks and partitions in a plist format by passing the -plist arg. List also appends any given args to fully support the diskutil list verb.
func (*DiskUtilityCmd) RepairDisk ¶
RepairDisk uses the macOS diskutil diskRepair command to repair the specified volume and get updated information (e.g. amount of free space).
func (*DiskUtilityCmd) ResizeContainer ¶
func (d *DiskUtilityCmd) ResizeContainer(ctx context.Context, id string, size string) (string, error)
ResizeContainer uses the macOS diskutil apfs resizeContainer command to change the size of the specific container ID.
type FreeSpaceError ¶
type FreeSpaceError struct {
// contains filtered or unexported fields
}
FreeSpaceError defines an error to distinguish when there's not enough space to grow the specified container.
func (FreeSpaceError) Error ¶
func (e FreeSpaceError) Error() string
type PlistDecoder ¶
type PlistDecoder struct{}
PlistDecoder provides the plist Decoder implementation.
func (*PlistDecoder) DecodeDiskInfo ¶
func (d *PlistDecoder) DecodeDiskInfo(reader io.ReadSeeker) (*types.DiskInfo, error)
DecodeDiskInfo assumes the io.ReadSeeker it's given contains raw plist data and attempts to decode that.
func (*PlistDecoder) DecodeSystemPartitions ¶
func (d *PlistDecoder) DecodeSystemPartitions(reader io.ReadSeeker) (*types.SystemPartitions, error)
DecodeSystemPartitions assumes the io.ReadSeeker it's given contains raw plist data and attempts to decode that.
type UtilImpl ¶
type UtilImpl interface { // APFSImpl outlines the functionality necessary for wrapping diskutil's APFS verb. APFSImpl // Info fetches raw disk information for the specified device identifier. Info(ctx context.Context, id string) (string, error) // List fetches all disk and partition information for the system. // This output will be filtered based on the args provided. List(ctx context.Context, args []string) (string, error) // RepairDisk attempts to repair the disk for the specified device identifier. // This process requires root access. RepairDisk(ctx context.Context, id string) (string, error) }
UtilImpl outlines the functionality necessary for wrapping macOS's diskutil tool. The methods are intentionally named to correspond to diskutil(8)'s subcommand names as its API.
Directories ¶
Path | Synopsis |
---|---|
Package mock_diskutil is a generated GoMock package.
|
Package mock_diskutil is a generated GoMock package. |