open-nomad/client/fingerprint/signal.go

33 lines
830 B
Go
Raw Normal View History

2016-10-19 22:06:23 +00:00
package fingerprint
import (
"strings"
"github.com/hashicorp/consul-template/signals"
log "github.com/hashicorp/go-hclog"
2016-10-19 22:06:23 +00:00
)
// SignalFingerprint is used to fingerprint the available signals
type SignalFingerprint struct {
StaticFingerprinter
logger log.Logger
2016-10-19 22:06:23 +00:00
}
// NewSignalFingerprint is used to create a Signal fingerprint
func NewSignalFingerprint(logger log.Logger) Fingerprint {
f := &SignalFingerprint{logger: logger.Named("signals")}
2016-10-19 22:06:23 +00:00
return f
}
func (f *SignalFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
2016-10-19 22:06:23 +00:00
// 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, ","))
2018-01-31 22:03:55 +00:00
resp.Detected = true
return nil
2016-10-19 22:06:23 +00:00
}