forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
46 lines (38 loc) · 936 Bytes
/
config.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
36
37
38
39
40
41
42
43
44
45
46
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package ottl // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
import (
"fmt"
"strings"
)
type ErrorMode string
const (
IgnoreError ErrorMode = "ignore"
PropagateError ErrorMode = "propagate"
SilentError ErrorMode = "silent"
)
func (e *ErrorMode) UnmarshalText(text []byte) error {
str := ErrorMode(strings.ToLower(string(text)))
switch str {
case IgnoreError, PropagateError, SilentError:
*e = str
return nil
default:
return fmt.Errorf("unknown error mode %v", str)
}
}
type LogicOperation string
const (
And LogicOperation = "and"
Or LogicOperation = "or"
)
func (l *LogicOperation) UnmarshalText(text []byte) error {
str := LogicOperation(strings.ToLower(string(text)))
switch str {
case And, Or:
*l = str
return nil
default:
return fmt.Errorf("unknown LogicOperation %v", str)
}
}