Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
NullAlerter = log.New(ioutil.Discard, "", 0)
)
Functions ¶
func EnvOrDefaultChroot ¶
func EnvOrDefaultChroot() string
EnvOrDefaultChroot returns the value of the GHW_CHROOT environs variable or the default value of "/" if not set
func EnvOrDefaultSnapshotExclusive ¶
func EnvOrDefaultSnapshotExclusive() bool
EnvOrDefaultSnapshotExclusive returns the value of the GHW_SNAPSHOT_EXCLUSIVE environs variable or the default value of false if not set
func EnvOrDefaultSnapshotPath ¶
func EnvOrDefaultSnapshotPath() string
EnvOrDefaultSnapshotPath returns the value of the GHW_SNAPSHOT_PATH environs variable or the default value of "" (disable snapshot consumption) if not set
func EnvOrDefaultSnapshotPreserve ¶
func EnvOrDefaultSnapshotPreserve() bool
EnvOrDefaultSnapshotPreserve returns the value of the GHW_SNAPSHOT_PRESERVE environs variable or the default value of false if not set
func EnvOrDefaultSnapshotRoot ¶
func EnvOrDefaultSnapshotRoot() string
EnvOrDefaultSnapshotRoot returns the value of the the GHW_SNAPSHOT_ROOT environs variable or the default value of "" (self-manage the snapshot unpack directory, if relevant) if not set
Types ¶
type Alerter ¶
type Alerter interface {
Printf(format string, v ...interface{})
}
Alerter emits warnings about undesirable but recoverable errors. We use a subset of a logger interface only to emit warnings, and `Warninger` sounded ugly.
func EnvOrDefaultAlerter ¶
func EnvOrDefaultAlerter() Alerter
EnvOrDefaultAlerter returns the default instance ghw will use to emit its warnings. ghw will emit warnings to stderr by default unless the environs variable GHW_DISABLE_WARNINGS is specified; in the latter case all warning will be suppressed.
type Option ¶
type Option struct {
// To facilitate querying of sysfs filesystems that are bind-mounted to a
// non-default root mountpoint, we allow users to set the GHW_CHROOT environ
// vairable to an alternate mountpoint. For instance, assume that the user of
// ghw is a Golang binary being executed from an application container that has
// certain host filesystems bind-mounted into the container at /host. The user
// would ensure the GHW_CHROOT environ variable is set to "/host" and ghw will
// build its paths from that location instead of /
Chroot *string
// Snapshot contains options for handling ghw snapshots
Snapshot *SnapshotOptions
// Alerter contains the target for ghw warnings
Alerter Alerter
}
Option is used to represent optionally-configured settings. Each field is a pointer to some concrete value so that we can tell when something has been set or left unset.
func WithAlerter ¶
WithAlerter sets alerting options for ghw
func WithChroot ¶
func WithNullAlerter ¶
func WithNullAlerter() *Option
WithNullAlerter sets No-op alerting options for ghw
func WithSnapshot ¶
func WithSnapshot(opts SnapshotOptions) *Option
WithSnapshot sets snapshot-processing options for a ghw run
type SnapshotOptions ¶
type SnapshotOptions struct {
// Path allows users to specify a snapshot (captured using ghw-snapshot) to be
// automatically consumed. Users need to supply the path of the snapshot, and
// ghw will take care of unpacking it on a temporary directory.
// Set the environment variable "GHW_SNAPSHOT_PRESERVE" to make ghw skip the cleanup
// stage and keep the unpacked snapshot in the temporary directory.
Path string
// Root is the directory on which the snapshot must be unpacked. This allows
// the users to manage their snapshot directory instead of ghw doing that on
// their behalf. Relevant only if SnapshotPath is given.
Root *string
// Exclusive tells ghw if the given directory should be considered of exclusive
// usage of ghw or not If the user provides a Root. If the flag is set, ghw will
// unpack the snapshot in the given SnapshotRoot iff the directory is empty; otherwise
// any existing content will be left untouched and the unpack stage will exit silently.
// As additional side effect, give both this option and SnapshotRoot to make each
// context try to unpack the snapshot only once.
Exclusive bool
}
SnapshotOptions contains options for handling of ghw snapshots