Skip to content

Commit

Permalink
Merge pull request #445 from glazychev-art/fix_config
Browse files Browse the repository at this point in the history
Ability to parse the configuration without additional parameters
  • Loading branch information
denis-tingaikin authored May 4, 2023
2 parents 5caf324 + b636cc8 commit e70bc39
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 e70bc39

Please sign in to comment.