open-nomad/client/fingerprint/signal.go
Chelsea Holland Komlo 7b53474a6e add applicable boolean to fingerprint response
public fields and remove getter functions
2018-01-31 13:21:45 -05:00

34 lines
859 B
Go

package fingerprint
import (
"log"
"strings"
"github.com/hashicorp/consul-template/signals"
cstructs "github.com/hashicorp/nomad/client/structs"
)
// 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}
return f
}
func (f *SignalFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.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.Applicable = true
return nil
}