Documentation
¶
Index ¶
- func Chroot(ctx context.Context) string
- func ContextFromArgs(args ...any) context.Context
- func ContextFromEnv() context.Context
- func EnvOrDefaultChroot() string
- func EnvOrDefaultDisableTools() bool
- func EnvOrDefaultDisableWarnings() bool
- func EnvOrDefaultEnableTopology() bool
- func EnvOrDefaultLogLevel() slog.Level
- func EnvOrDefaultLogLogfmt() bool
- func LogLevel(ctx context.Context) slog.Level
- func Logger(ctx context.Context) *slog.Logger
- func PCIDB(ctx context.Context) *pcidb.PCIDB
- func PathOverrides(ctx context.Context) map[string]string
- func ToolsEnabled(ctx context.Context) bool
- func TopologyEnabled(ctx context.Context) bool
- type Key
- type Modifier
- func WithChroot(path string) Modifier
- func WithDebug() Modifier
- func WithDisableTools() Modifier
- func WithDisableTopology() Modifier
- func WithDisableWarnings() Modifier
- func WithLogLevel(level slog.Level) Modifier
- func WithLogLogfmt() Modifier
- func WithLogger(logger *slog.Logger) Modifier
- func WithPCIDB(db *pcidb.PCIDB) Modifier
- func WithPathOverrides(overrides map[string]string) Modifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextFromArgs ¶
ContextFromArgs returns a context.Context populated with any old-style options or new-style arguments.
func ContextFromEnv ¶
ContextFromEnv returns a new context.Context populated from the environs or default option values
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 ¶
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.
func EnvOrDefaultDisableWarnings ¶
func EnvOrDefaultDisableWarnings() bool
EnvOrDefaultDisableWarnings return true if ghw should not output warnings based on the GHW_DISABLE_WARNINGS environs variable.
func EnvOrDefaultEnableTopology ¶
func EnvOrDefaultEnableTopology() bool
EnvOrDefaultEnableTopology return true if ghw should detect system topology.
func EnvOrDefaultLogLevel ¶
EnvOrDefaultLogLevel return true if ghw should not output warnings based on the GHW_LOG_LEVEL environs variable.
func EnvOrDefaultLogLogfmt ¶
func EnvOrDefaultLogLogfmt() bool
EnvOrDefaultLogLogfmt return true if ghw should use logfmt standard output format based on the GHW_LOG_LOGFMT environs variable.
func PathOverrides ¶
PathOverrides returns any path overrides set in the supplied context.
func ToolsEnabled ¶
ToolsEnabled returns true if external tools have been disabled.
func TopologyEnabled ¶
TopologyEnabled returns true if the detection of system topology is enabled.
Types ¶
type Modifier ¶
Modifier sets some value on the context
func WithChroot ¶
WithChroot allows overriding the root directory ghw examines.
func WithDisableTools ¶
func WithDisableTools() Modifier
WithDisableTools prevents ghw from calling external tools to discover hardware capabilities.
func WithDisableTopology ¶
func WithDisableTopology() Modifier
WithDisableTopology disables system topology detection to reduce memory consumption. When using this option, ghw will skip scanning NUMA topology, CPU cores, memory caches, and node distances. This is useful when you only need basic PCI or GPU information and want to minimize memory overhead. The system architecture will be assumed to be SMP, and device Node fields will be nil.
func WithDisableWarnings ¶
func WithDisableWarnings() Modifier
WithDisableWarnings tells ghw not to output warning messages.
func WithLogLevel ¶
WithLogLevel allows overriding the default log level of WARN.
func WithLogLogfmt ¶
func WithLogLogfmt() Modifier
WithLogLogfmt sets the log output to the logfmt standard.
func WithLogger ¶
WithLogger allows overriding the default logger
func WithPCIDB ¶
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.
func WithPathOverrides ¶
WithPathOverrides supplies path-specific overrides for the context