open-nomad/client/fingerprint/signal.go
Danielle Tomlinson 66c521ca17 client: Move fingerprint structs to pkg
This removes a cyclical dependency when importing client/structs from
dependencies of the plugin_loader, specifically, drivers. Due to
client/config also depending on the plugin_loader.

It also better reflects the ownership of fingerprint structs, as they
are fairly internal to the fingerprint manager.
2018-12-01 17:10:39 +01:00

33 lines
830 B
Go

package fingerprint
import (
"strings"
"github.com/hashicorp/consul-template/signals"
log "github.com/hashicorp/go-hclog"
)
// SignalFingerprint is used to fingerprint the available signals
type SignalFingerprint struct {
StaticFingerprinter
logger log.Logger
}
// NewSignalFingerprint is used to create a Signal fingerprint
func NewSignalFingerprint(logger log.Logger) Fingerprint {
f := &SignalFingerprint{logger: logger.Named("signals")}
return f
}
func (f *SignalFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
// Build the list of available signals
sigs := make([]string, 0, len(signals.SignalLookup))
for signal := range signals.SignalLookup {
sigs = append(sigs, signal)
}
resp.AddAttribute("os.signals", strings.Join(sigs, ","))
resp.Detected = true
return nil
}