-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config split #302
Config split #302
Conversation
…lockchain overwrite
wrap BuildConfig into NewConfig being responsible to cfg validation making Config Unmarshalling testing easier
…rning info into another variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! It overall looks good to me. @cam-schultz should also take a look at this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together! Overall the changes look great. I have a couple of minor change requests.
var configFile string | ||
|
||
func TestBuildConfig(t *testing.T) { | ||
v := viper.New() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of test_files/config.json
and re-use the top-level sample-relayer-config.json
for this test. The following changes are necessary:
- Read in
"../sample-relayer-config.json
usingos.ReadFile
.go:embed
does not support..
.
cfgBytes, err := os.ReadFile("../sample-relayer-config.json")
configFile := string(cfgBytes)
- Modify the expected
DestinationBlockchain
AccountPrivateKey
to match the partial key provided insample-relayer-config.json
- Remote
test_files/config.json
Co-authored-by: cam-schultz <[email protected]> Signed-off-by: nathan haim <[email protected]>
func TestBuildConfig(t *testing.T) { | ||
v := viper.New() | ||
cfgBytes, err := os.ReadFile("../sample-relayer-config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check the error here. This is also the cause of the failing lint job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my mind was elsewhere. It should be ok now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! Thanks for the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much appreciated 🙏
Why this should be merged
It is related to #251
This splits the config go file into multiple ones easier to read.
It shorten the BuildConfig function
It provides more informations about the config overwritten options.
How this works
Split does not change logic.
About
BuildConfig()
changes:viper.UnmarshalKey()
, a uniqueviper.Unmarshal()
is done.NewConfig()
wrapsBuildConfig()
+config Validation
. This makes the test of viper unmarshaling easier mechanism fromBuildConfig()
.Information details about overwritten options are now embedded in a Config private field. It can be accessed from new methods
HasOverwrittenOptions()
&GetOverwrittenOptions()
How this was tested
Modified unmarshal mechanism is tested in
viper_test.go
How is this documented