-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
39 lines (32 loc) · 711 Bytes
/
config.go
File metadata and controls
39 lines (32 loc) · 711 Bytes
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
package main
import (
"os"
"gopkg.in/yaml.v3"
)
type FileInputConfig struct {
File string
Follow *bool
FromLineNumber *int `yaml:"from_line_number"`
Patterns []string
Tags map[string]string
}
type Config struct {
SentryDsn string `yaml:"sentry_dsn"`
PatternFiles []string `yaml:"pattern_files"`
Inputs []FileInputConfig
}
func ReadConfigFromFile(filename string) (*Config, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
config := Config{}
decoder := yaml.NewDecoder(file)
decoder.KnownFields(true)
err = decoder.Decode(&config)
if err != nil {
return &config, err
}
return &config, nil
}