* Normalize event configuration This updates event configuration stanzas to more closely match behavior for listeners and kmses: * Singular "sink" instead of "sinks" (probably not the most correct option, but a consistent option, and one that makes sense for HCL) * Allows sinks to have the type defined at the start of the block * Moves type-specific configuration to a specific named block Co-authored-by: Jim <jlambert@hashicorp.com>
26 lines
972 B
Go
26 lines
972 B
Go
package event
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// EventerConfig supplies all the configuration needed to create/config an Eventer.
|
|
type EventerConfig struct {
|
|
AuditEnabled bool `hcl:"audit_enabled"` // AuditEnabled specifies if audit events should be emitted.
|
|
ObservationsEnabled bool `hcl:"observations_enabled"` // ObservationsEnabled specifies if observation events should be emitted.
|
|
SysEventsEnabled bool `hcl:"sysevents_enabled"` // SysEventsEnabled specifies if sysevents should be emitted.
|
|
Sinks []SinkConfig `hcl:"-"` // Sinks are all the configured sinks
|
|
}
|
|
|
|
// Validate will Validate the config. A config isn't required to have any
|
|
// sinks to be valid.
|
|
func (c *EventerConfig) Validate() error {
|
|
const op = "event.(EventerConfig).Validate"
|
|
for i, s := range c.Sinks {
|
|
if err := s.Validate(); err != nil {
|
|
return fmt.Errorf("%s: sink %d is invalid: %w", op, i, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|