Implement rpc_secret_file
#466
No reviewers
Labels
No labels
action
check-aws
action
discussion-needed
action
for-external-contributors
action
for-newcomers
action
more-info-needed
action
need-funding
action
triage-required
kind
correctness
kind
ideas
kind
improvement
kind
performance
kind
testing
kind
usability
kind
wrong-behavior
prio
critical
prio
low
scope
admin-api
scope
background-healing
scope
build
scope
documentation
scope
k8s
scope
layout
scope
metadata
scope
ops
scope
rpc
scope
s3-api
scope
security
scope
telemetry
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Deuxfleurs/garage#466
Loading…
Reference in a 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.)rpc_secret_file
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)rpc_secret
andrpc_secret_file
7b62fe3f0bfec9a53e6f
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