Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package config |
||
2 | |||
3 | import ( |
||
4 | "github.com/vvval/go-metadata-scanner/configuration" |
||
5 | "gopkg.in/yaml.v2" |
||
6 | ) |
||
7 | |||
8 | type MSCSVSchema struct { |
||
9 | Provider string `yaml:"provider"` |
||
10 | } |
||
11 | |||
12 | func (c MSCSVConfig) Schema() configuration.Schema { |
||
13 | return MSCSVSchema{} |
||
14 | } |
||
15 | |||
16 | func (s MSCSVSchema) Parse(data []byte) (configuration.Config, error) { |
||
17 | err := yaml.Unmarshal(data, &s) |
||
18 | if err != nil { |
||
19 | return MSCSVConfig{}, err |
||
20 | } |
||
21 | |||
22 | return MSCSVConfig{provider: s.Provider}, nil |
||
23 | } |
||
24 | |||
25 | func (c MSCSVConfig) MergeDefault(conf configuration.Config) configuration.Config { |
||
26 | if len(c.provider) == 0 { |
||
27 | c.provider = conf.(MSCSVConfig).provider |
||
28 | } |
||
29 | |||
30 | return c |
||
31 | } |
||
32 | |||
33 | type MSCSVConfig struct { |
||
34 | provider string |
||
35 | } |
||
36 | |||
37 | func (c MSCSVConfig) Provider() string { |
||
38 | return c.provider |
||
39 | } |
||
40 |