2020-03-27 19:26:39 +01:00
|
|
|
package nebula
|
|
|
|
|
2021-11-04 02:54:04 +01:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/slackhq/nebula/config"
|
|
|
|
)
|
2020-03-27 19:26:39 +01:00
|
|
|
|
|
|
|
type Punchy struct {
|
|
|
|
Punch bool
|
|
|
|
Respond bool
|
|
|
|
Delay time.Duration
|
|
|
|
}
|
|
|
|
|
2021-11-04 02:54:04 +01:00
|
|
|
func NewPunchyFromConfig(c *config.C) *Punchy {
|
2020-03-27 19:26:39 +01:00
|
|
|
p := &Punchy{}
|
|
|
|
|
|
|
|
if c.IsSet("punchy.punch") {
|
|
|
|
p.Punch = c.GetBool("punchy.punch", false)
|
|
|
|
} else {
|
|
|
|
// Deprecated fallback
|
|
|
|
p.Punch = c.GetBool("punchy", false)
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.IsSet("punchy.respond") {
|
|
|
|
p.Respond = c.GetBool("punchy.respond", false)
|
|
|
|
} else {
|
|
|
|
// Deprecated fallback
|
|
|
|
p.Respond = c.GetBool("punch_back", false)
|
|
|
|
}
|
|
|
|
|
|
|
|
p.Delay = c.GetDuration("punchy.delay", time.Second)
|
|
|
|
return p
|
|
|
|
}
|