Skip to content

Commit

Permalink
Ability to parse the configuration without additional parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <[email protected]>
  • Loading branch information
glazychev-art committed May 4, 2023
1 parent 5caf324 commit b636cc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *ServiceConfig) UnmarshalBinary(bytes []byte) (err error) {

split = strings.Split(text, "{")
if len(split) < 2 {
return errors.Errorf("invalid format: %s", text)
return s.validate()
}

split = strings.Split(split[1], "}")
Expand Down
8 changes: 8 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ func TestServiceConfig_UnmarshalBinary(t *testing.T) {
Name: "pingpong",
VLANTag: 1111,
}, cfg)

cfg = new(config.ServiceConfig)
err = cfg.UnmarshalBinary([]byte("pingpong"))
require.NoError(t, err)

require.Equal(t, &config.ServiceConfig{
Name: "pingpong",
}, cfg)
}

0 comments on commit b636cc8

Please sign in to comment.