summaryrefslogtreecommitdiff
path: root/crates/tor-config/src/path.rs
Commit message (Collapse)AuthorAgeFilesLines
* Resolve some clippy warnings about empty rustdoc.Nick Mathewson2024-05-051-1/+1
| | | | | (In most cases, by writing the documentation; in tests, by permitting the documentation to be missing.)
* Switch to figment 1.0.18 and extract_lossyNick Mathewson2024-04-221-1/+1
| | | | | | | The new (dubiously named) `Figment::extract_lossy` method can treat decode numbers from strings, and booleans from numbers or strings. This makes the behavior compatible with config-rs, and should (I hope) finally allow us to migrate.
* Convert tor-config to use figment.Nick Mathewson2024-04-221-1/+1
| | | | | There are probably ways to make this a bit more elegant, but at least the tests still pass.
* Merge branch 'encapsulate_config_rs' into 'main'Nick Mathewson2024-03-131-6/+8
|\ | | | | | | | | Encapsulate usage of config-rs inside tor-config. See merge request tpo/core/arti!2040
| * tor-config: Put config::Config inside a wrapper type.Nick Mathewson2024-03-131-1/+1
| | | | | | | | This will let us replace Config with something better.
| * Use ConfigurationSource::Verbatim in our tests.Nick Mathewson2024-03-131-5/+7
| |
* | Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|/
* Fix typos in doc commentsTobias Stoeckmann2024-03-061-1/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* tor-config: Expand NoProjectDirs error messageIan Jackson2023-08-081-1/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* tor-config: Apply deferred rustfmt churnIan Jackson2023-03-211-4/+4
|
* tor-config: Do minimal $ and ~ handling even without expand-pathsIan Jackson2023-03-211-2/+54
| | | | Fixes #790
* tor-config: Make CfgPathError PartialEq but only when testingIan Jackson2023-03-211-0/+1
| | | | So, this is not a semver addition.
* tor-config: Fix build when expand-paths is disabledIan Jackson2023-03-211-2/+5
|
* tor-config: paths, unexpanded: use infallible conversionIan Jackson2023-03-211-2/+1
| | | | str can always be made into a PathBuf.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* tor-config: Update to shellexpand 3.xIan Jackson2022-12-061-1/+5
| | | | | | | | | | | | | | | | | | | | | This is the new upstream version (published by me, recently). It has the same MSRV and one breaking change: The caller who specifies a home dir function for substituting into strings, must now supply a string, not Path. Previously shellexpand would allow the caller to supply non-unicode data, and then simply not substitute it. That was an infelicity in the shellexpand API. Now this infelicity is pushed into our code. The overall behaviour of Arti hasn't changed as a result. And it seems reasonable to me. shellexpand 3.x also has a module for expanding Paths instead, in response to requests for this filed as upstream tickets. We *could* use that but I am not sanguine about that approach: the Pathness would spread throughout much of our config and file handling code. I think we should at the very least postpone trying to work with invalid-unicode-paths as long as we can.
* tor-config: home dir handling: fmt pre-patchIan Jackson2022-12-061-1/+3
|
* Allow "clippy::single_char_pattern" in tests.Ian Jackson2022-10-121-0/+1
| | | | | | | This lint exists for perf reasons, and this is rarely relevant in tests. Using double quoted str is generally cognitively less burdensome.
* tor-config: CfgPath: Fix two typos "expaneded"Ian Jackson2022-10-111-2/+2
|
* CfgPath: Add support for ${PROGRAM_DIR}.Nick Mathewson2022-10-071-2/+42
| | | | | | | | | | | `${PROGRAM_DIR}` expands to the equivalent of `std::env::current_exe().parent()`, with appropriate unwrapping and conversions. It is expected to be useful for finding the locations of pluggable transports in some kinds of bundles. Closes #586.
* clippy: Consolidate many lints in maint/add_warningIan Jackson2022-06-241-0/+9
| | | | | | Found these by disabling the nightly dbg macro special case. Now, we have a mechanism for globally adding suppressions to tests, we can use that instead.
* tor-config: style fixes on CfgPathError.Nick Mathewson2022-06-221-6/+6
|
* Revert "Remove dbg!()s in tor-config"Ian Jackson2022-05-271-0/+5
| | | | | | | | | This was done because Nightly Rust complained about these, despite them all being in tests. That is now fixed upstream: https://github.com/rust-lang/rust-clippy/issues/8758 https://github.com/rust-lang/rust-clippy/pull/8838 This reverts commit 9d26a91886990b08dc5b6033c290d417489c61fc.
* Remove dbg!()s in tor-configNick Mathewson2022-05-201-5/+0
| | | | This should satisfy our CI and turn it green again.
* CfgPath: Test serialisation round-trip with a binary formatIan Jackson2022-05-031-0/+8
| | | | | | Use MessagePack. Signed-off-by: Ian Jackson <[email protected]>
* CfgPath: Make it SerializeIan Jackson2022-05-031-5/+69
| | | | | | And provide round-trip tests. As per https://gitlab.torproject.org/tpo/core/arti/-/issues/371
* CfgPath: Overhaul APIIan Jackson2022-05-031-6/+86
| | | | | | | | | | | | | | | | | | | | | | Document that this can contain either a string for expansion, or a literal PathBuf not for expansion. Rename the `from_path` method to `new_literal`: a very important difference is whether it gets expanded - less important than the Rust type. Also, now it takes `Into<PathBuf>`, which avoids a needless clone. (We don't change the API in `arti-client` because `&tempfile::Tempdir()` doesn't implement `Into<PathBuf>`, so `arti-client` has to have some new `as_ref` calls.) Provide accessors `as_unexpanded_str` and `as_literal_path`. The deserialisation already makes this part of the stable API,l so not pvoding accessors seems just obstructive. They are useful for tests, too. Add tests for the new entrypoints, and for deserialisation of both variants from TOML (via config, or directly) and JSON.
* CfgPath: Change deserialisaation of Literal variantIan Jackson2022-05-031-5/+17
| | | | | | | | We introduce LiteralPath struct, so that a literal path deserialises from some_path = { literal: "actual path string" } This makes the deserialisation unambiguous.
* Test shell variable expansion on windowsMichael2022-03-051-2/+24
|
* tor-config: Add HasKind support.Nick Mathewson2022-02-091-0/+22
| | | | This required a few new ErrorKinds.
* Fix invalid path character on windowsMichael2022-01-311-0/+4
|
* Explain that CfgPath can look at the environment.Nick Mathewson2022-01-121-1/+2
| | | | Closes #246.
* Change sane_defaults() and with_directories()Nick Mathewson2021-11-291-3/+1
| | | | | | | | The sane_defaults() call is now the same as you get from a default builder: by convention, we just call that method Default::default(). The with_directories() constructor makes more sense as a constructor for the TorClientConfigBuilder than for TorClientConfig.
* More tests for tor-config.Nick Mathewson2021-11-241-2/+17
|
* Make every Config type implement Eq.Nick Mathewson2021-11-211-2/+2
| | | | | Doing this is necessary for reconfiguration support, and will help a lot with testing, too.
* Rename .gitignore APP_FOO to ARTI_FOO.Nick Mathewson2021-11-211-12/+12
| | | | | | | | Since these shell-variables are hardwired to use org.torproject.Arti as the program name, it isn't appropriate to call them "app-specific". If we someday reinstate APP_FOO, it should be based on a user-provided application name.
* Give CfgPath an alternative inner representation.Nick Mathewson2021-11-211-24/+41
| | | | | | | | In order to handle explicitly specified path buffers directly, we now let CfgPath be either a string (that gets expanded) or a PathBuf (that doesn't). This simplifies TorClientConfig::with_directories()
* Make arti-client config object match arti config better.Nick Mathewson2021-11-211-0/+13
| | | | | | | | Now every section that the two configuration objects share has the same type and name. This should help us in documenting our configuration in a way that doesn't confuse people. There is still lots of API work to go.
* Move top-level configuration downwards from `arti` to `arti-config`.Nick Mathewson2021-11-181-16/+29
| | | | | | | | To do this at all neatly, I had to split out `tor-config` from `arti-config` again, and putting the lower level stuff (paths, builder errors) into tor-config. I also changed our use of derive_builder to always use a common error type, to avoid error type proliferation.
* Remove dependency from arti-client to tor-config.Nick Mathewson2021-11-161-0/+2
| | | | | I'm about to make tor-config a higher-level module, so it can't be a dependency for tor-config.
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-0/+1
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+159
This will cause some pain for now, but now is really the best time to do this kind of thing.