abcxyz / jvs

Apache License 2.0
8 stars 0 forks source link

Refactor of config pkg #104

Closed capri-xiyue closed 2 years ago

capri-xiyue commented 2 years ago

TL;DR

There are some duplicates when loading config from env, do validation and set defaults. https://github.com/abcxyz/jvs/blob/main/pkg/config/public_key_config.go#L43 and https://github.com/abcxyz/jvs/blob/23cdda185a8fc277ba798bfaf3e34543458f1934/pkg/config/crypto_config.go#L102.

We can do refactor to avoid duplicates.

Detailed design

Create a common function which handles loading config from env with any parameter. The caller of the common function need to pass the pointer of specific config like PublicKeyConfig or CryptoConfig as the value of any parameter.

Alternatives considered

No response

Additional information

No response

yolocs commented 2 years ago

Added a lib in pkg: https://github.com/abcxyz/pkg/pull/33

yolocs commented 2 years ago

Adopt pkg/cfgloader wherever applicable