Documentation
¶
Overview ¶
NOTE(jaypipes): This entire package is deprecated and will be removed in the 1.0 release of ghw. Please use the aliased definitions of WithXXX functions in the main `ghw` package.
Index ¶
Constants ¶
const (
DefaultChroot = "/"
)
Variables ¶
var (
NullAlerter = log.New(io.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 EnvOrDefaultDisableTools ¶ added in v0.21.3
func EnvOrDefaultDisableTools() bool
EnvOrDefaultDisableTools return true if ghw should use external tools to augment the data collected from sysfs. Most users want to do this most of time, so this is enabled by default. Users consuming snapshots may want to opt out, thus they can set the GHW_DISABLE_TOOLS environs variable to any value to make ghw skip calling external tools even if they are available.
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 func(opts *Options)
func WithAlerter ¶
WithAlerter sets alerting options for ghw
DEPRECATED. Use `pkg/context.WithDisableWarnings`
func WithChroot ¶
WithChroot allows to override the root directory ghw uses.
func WithDisableTools ¶
func WithDisableTools() Option
WithDisableTools revents ghw from calling external tools to discover hardware capabilities.
DEPRECATED. Use `pkg/context.WithDisableTools`
func WithNullAlerter ¶
func WithNullAlerter() Option
WithNullAlerter sets No-op alerting options for ghw
DEPRECATED. Use `pkg/context.WithDisableWarnings`
func WithPCIDB ¶ added in v0.0.18
WithPCIDB allows you to provide a custom instance of the PCI database (pcidb.PCIDB) to ghw. This is useful if you want to use a preloaded or specially configured PCI database, such as one created with custom pcidb.WithOption settings, instead of letting ghw load the PCI database automatically.
DEPRECATED. Use `pkg/context.WithPCIDB`
func WithPathOverrides ¶
func WithPathOverrides(overrides PathOverrides) Option
WithPathOverrides supplies path-specific overrides for the context
DEPRECATED. Use `pkg/context.WithPathOverrides`
type Options ¶ added in v0.21.3
type Options 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 variable 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
// Alerter contains the target for ghw warnings
Alerter Alerter
// DisableTools optionally request ghw to not call any external program to learn
// about the hardware. The default is to use such tools if available.
DisableTools bool
// PathOverrides optionally allows to override the default paths ghw uses
// internally to learn about the system resources.
PathOverrides PathOverrides
// PCIDB allows users to provide a custom instance of the PCI database
// (pcidb.PCIDB) to be used by ghw. This can be useful for testing,
// supplying a preloaded database, or providing an instance created with
// custom pcidb.WithOption settings, instead of letting ghw load the PCI
// database automatically.
PCIDB *pcidb.PCIDB
}
Options 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.
type PathOverrides ¶
PathOverrides is a map, keyed by the string name of a mount path, of override paths