Debian Codegraph @

cmd/mdatagen/internal/event.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package internal // import "go.opentelemetry.io/collector/cmd/mdatagen/internal"
5
6 import (
7 "errors"
8
9 "go.opentelemetry.io/collector/confmap"
10 )
11
12 type (
13 EventName string
14 )
15
16 func (ln EventName) Render() (string, error) {
17 return FormatIdentifier(string(ln), true)
18 }
19
20 func (ln EventName) RenderUnexported() (string, error) {
21 return FormatIdentifier(string(ln), false)
22 }
23
24 type Event struct {
25 Signal `mapstructure:",squash"`
26 }
27
28 func (l *Event) validate() error {
29 var errs error
30 if l.Description == "" {
31 errs = errors.Join(errs, errors.New(`missing event description`))
32 }
33 return errs
34 }
35
36 func (l *Event) Unmarshal(parser *confmap.Conf) error {
37 if !parser.IsSet("enabled") {
38 return errors.New("missing required field: `enabled`")
39 }
40 return parser.Unmarshal(l)
41 }