Files
threshold/internal/event/sink_format.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
1002 B
Go
Raw Normal View History

2021-06-06 07:57:24 -04:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
2023-02-02 17:15:17 -08:00
2021-06-06 07:57:24 -04:00
package event
import (
"fmt"
)
const (
JSONSinkFormat SinkFormat = "cloudevents-json" // JSONSinkFormat means the event is formatted as JSON
TextSinkFormat SinkFormat = "cloudevents-text" // TextSinkFormat means the event is formmatted as text
TextHclogSinkFormat SinkFormat = "hclog-text" // TextHclogSinkFormat means the event is formatted as an hclog text entry
JSONHclogSinkFormat SinkFormat = "hclog-json" // JSONHclogSinkFormat means the event is formated as an hclog json entry
2021-06-06 07:57:24 -04:00
)
type SinkFormat string // SinkFormat defines the formatting for a sink in a config file stanza (json)
2021-07-08 15:50:25 -04:00
func (f SinkFormat) Validate() error {
const op = "event.(SinkFormat).Validate"
2021-06-06 07:57:24 -04:00
switch f {
case JSONSinkFormat, TextSinkFormat:
2021-06-06 07:57:24 -04:00
return nil
case TextHclogSinkFormat, JSONHclogSinkFormat:
return nil
2021-06-06 07:57:24 -04:00
default:
2021-06-22 16:23:27 -05:00
return fmt.Errorf("%s: '%s' is not a valid sink format: %w", op, f, ErrInvalidParameter)
2021-06-06 07:57:24 -04:00
}
}