Skip to content

Commit 0184936

Browse files
authored
Make yaml.Unmarshal strict (#271)
* Make yaml.Unmarshal strict and fix test * Fix another test
1 parent 6c1dae1 commit 0184936

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

pkg/api/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ func TestDuration_MarshalYAML(t *testing.T) {
3737
func TestDuration_UnmarshalYAML(t *testing.T) {
3838
expectedMsg := testMessage{Elapsed: Duration{2 * time.Hour}}
3939
var actualMsg testMessage
40-
require.NoError(t, yaml.Unmarshal([]byte("elapsed: 2h\n"), &actualMsg))
40+
require.NoError(t, yaml.UnmarshalStrict([]byte("elapsed: 2h\n"), &actualMsg))
4141
require.Equal(t, expectedMsg, actualMsg)
4242
}

pkg/confgen/confgen_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ encode:
5555
prefix: flp_
5656
port: 9102
5757
visualization:
58-
type: grafana
5958
grafana:
6059
dashboards:
6160
- name: "details"
@@ -90,7 +89,6 @@ write:
9089
staticLabels:
9190
job: flowlogs-pipeline
9291
visualization:
93-
type: grafana
9492
grafana:
9593
dashboards:
9694
- name: "details"
@@ -107,7 +105,7 @@ details:
107105
test details
108106
usage:
109107
test usage
110-
labels:
108+
tags:
111109
- test
112110
- label
113111
transform:

pkg/confgen/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (cg *ConfGen) ParseConfigFile(fileName string) (*Config, error) {
6565
log.Debugf("ioutil.ReadFile err: %v ", err)
6666
return nil, err
6767
}
68-
err = yaml.Unmarshal(yamlFile, &config)
68+
err = yaml.UnmarshalStrict(yamlFile, &config)
6969
if err != nil {
7070
log.Debugf("Unmarshal err: %v ", err)
7171
return nil, err

0 commit comments

Comments
 (0)