You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anyone have any luck decoding oneof protobuf structs using Viper and mapstructure?
Have a struct generated from a protobuf like this.
// KeybaseConfig is the configuration for the Keybase. It is modular and can be configured to use either the File Keybase or the Hashicorp Vault Keybase.messageKeybaseConfig {
oneofconfig {
KeybaseFileConfigfile=1;
KeybaseVaultConfigvault=2;
}
}
// KeybaseFileConfig is the configuration for the File KeybasemessageKeybaseFileConfig {
// Path to the keybase filestringpath=1;
}
// KeybaseVaultConfig is the configuration for the Hashicorp Vault KeybasemessageKeybaseVaultConfig {
// Vault addressstringaddr=1;
// Vault tokenstringtoken=2;
// Vault mount pathstringmount_path=3;
}
Then, have a top-level Config struct that includes the generated go files.
typeConfigstruct {
// ... other stuffKeybase*KeybaseConfig`json:"keybase"`
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Anyone have any luck decoding
oneof
protobuf structs using Viper and mapstructure?Have a struct generated from a protobuf like this.
Then, have a top-level Config struct that includes the generated go files.
Using a config file looks like this so far.
Keybase with a vault
Keybase using local file
Full code example https://github.com/pokt-network/pocket/compare/0xbigboss/fix-626-modularize-keybase-config
Beta Was this translation helpful? Give feedback.
All reactions