Documentation
¶
Overview ¶
Package machineid resolves and stores a single machine identifier shared by every Snyk product on the same machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
func Resolve(opts ...ResolveOption) configuration.DefaultValueFunction
Resolve returns a configuration.DefaultValueFunction for configuration.MACHINE_ID. A valid value supplied on MACHINE_ID itself (trailing whitespace trimmed) is returned. Otherwise the first lookup takes the first of: the shared file, the Snyk Studio device-id file, or a newly generated id, and later lookups through the same resolver return that id, together with an error for each file that exists but could not be read. If no id was found, it returns runtimeinfo.ErrNoMachineID joined with those errors and an error describing why a generated id could not be stored; the configuration caching does not hold it, so the next lookup tries the disk again.
Types ¶
type ResolveOption ¶
type ResolveOption func(*resolveOptions)
ResolveOption configures optional behavior of Resolve.
func WithLogger ¶
func WithLogger(logger *zerolog.Logger) ResolveOption
WithLogger sets the logger used to trace resolution decisions at Debug level, including errors that resolution otherwise swallows so a run can still produce a value. If unset, Resolve uses a no-op logger.
func WithRuntimeInfo ¶
func WithRuntimeInfo(get func() runtimeinfo.RuntimeInfo) ResolveOption
WithRuntimeInfo identifies the consumer resolving the machine id, recorded as the writer field in the shared machine-id file so a machine carrying values written by several different products or versions is identifiable. get is called when the file is written rather than when Resolve is called, so runtime info set on the engine after it was created is still used. If unset, or if get returns nil, a generic framework identifier is recorded.