config.MSCSVConfig.Schema   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 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