-
Notifications
You must be signed in to change notification settings - Fork 2k
/
signal.go
35 lines (28 loc) · 901 Bytes
/
signal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
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
}