Skip to content

Commit

Permalink
Make yaml.Unmarshal strict (#271)
Browse files Browse the repository at this point in the history
* Make yaml.Unmarshal strict and fix test

* Fix another test
  • Loading branch information
ronensc committed Aug 2, 2022
1 parent 6c1dae1 commit 0184936
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/api/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ func TestDuration_MarshalYAML(t *testing.T) {
func TestDuration_UnmarshalYAML(t *testing.T) {
expectedMsg := testMessage{Elapsed: Duration{2 * time.Hour}}
var actualMsg testMessage
require.NoError(t, yaml.Unmarshal([]byte("elapsed: 2h\n"), &actualMsg))
require.NoError(t, yaml.UnmarshalStrict([]byte("elapsed: 2h\n"), &actualMsg))
require.Equal(t, expectedMsg, actualMsg)
}
4 changes: 1 addition & 3 deletions pkg/confgen/confgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ encode:
prefix: flp_
port: 9102
visualization:
type: grafana
grafana:
dashboards:
- name: "details"
Expand Down Expand Up @@ -90,7 +89,6 @@ write:
staticLabels:
job: flowlogs-pipeline
visualization:
type: grafana
grafana:
dashboards:
- name: "details"
Expand All @@ -107,7 +105,7 @@ details:
test details
usage:
test usage
labels:
tags:
- test
- label
transform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/confgen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (cg *ConfGen) ParseConfigFile(fileName string) (*Config, error) {
log.Debugf("ioutil.ReadFile err: %v ", err)
return nil, err
}
err = yaml.Unmarshal(yamlFile, &config)
err = yaml.UnmarshalStrict(yamlFile, &config)
if err != nil {
log.Debugf("Unmarshal err: %v ", err)
return nil, err
Expand Down

0 comments on commit 0184936

Please sign in to comment.