Implement rpc_secret_file
#466
No reviewers
Labels
No Label
AdminAPI
Bug
Check AWS
CI
Correctness
Critical
Documentation
Ideas
Improvement
Low priority
Newcomer
Performance
S3 Compatibility
Testing
Usability
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Deuxfleurs/garage#466
Loading…
Reference in New Issue
No description provided.
Delete Branch "felix.scheinost/garage:feature/implement-rpc-secret-file"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR implements reading of
rpc_secret
from a file using the new optionrpc_secret_file
.When both
rpc_secret
andrpc_secret_file
are set,rpc_secret
is preferred.Otherwise
read_config
tries to read the file and setrpc_secret
.The current implementation is not ideal because before
pub rpc_secret: String
wasn't optional, now it is. Ideally reading the file would be handled during serde deserialization and an error would be returned if no property would be set or if the file could not be read. This wayrpc_secret
would already be either a valid string fromrpc_secret
TOML or the contents ofrpc_secret_file
. The downstream code would not need to handle theOption<String>
.I also added a
.direnv
file and adevShell
toflake.nix
. I tried gettingshell.nix
to work on my machine (aarch64-darwin
) but addingdevShell
toflake.nix
was quicker and should also be the more future-proof situtation.With this setup I could properly do development with VS Code + Rust plugin + direnv plugin without even having Rust or Cargo installed globally, on macOS.
I formatted
flake.nix
usingnixfmt
, I hope that's okay. I don't like manually formatting code :-) (Actually I have undone the changes to the first line, nixfmt would insert a linebreak there. I personally wouldn't mind the linebreak though.)Otherwise LGTM
@ -180,1 +183,3 @@
Ok(toml::from_str(&config)?)
let mut parsed_config: Config = toml::from_str(&config)?;
match (&parsed_config.rpc_secret, &parsed_config.rpc_secret_file) {
I think in case we have both
rpc_secret
andrpc_secret_file
, we should at least warn the user that something is wrong (probably just throw an Err)fec9a53e6f
tod6ea0cbefa
I added throwing an error when both
rpc_secret
andrpc_secret_file
are set and I added some tests.Thank you for your contribution