From 6472cb57fe196b5e19bc7a5eceeb994843dfa095 Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Wed, 7 Apr 2021 15:19:06 +0200 Subject: Refactor TEdge config (#155) - Refactor TEdgeConfig - Move configuration into `tedge_config` crate. - Add `ConfigSetting` trait. Each "thing" that we want to make configurable will have it's own struct-type. For example `struct DeviceIdSetting` or `C8yUrlSetting`. - The `ConfigSetting` trait does not provide any means of how to read/write/unset a configuration setting. It only provides the key, description and the value type of the setting, but no implementation. - Use trait `ConfigSettingAccessor` to implemenent `query`, `update` and `unset` methods. - `TEdgeConfigRepository` implements functionality to read/write a `TEdgeConfig`. The `TEdgeConfig` struct itself just holds data. - Add `TEdgeConfigLocation` which holds all data that we need to resolve the defaults in TEdgeConfig, including the name of the config file (TODO: we might want to split these two apart). The defaults differ depending on the location of the `tedge.toml`, whether it's located in `/etc` or a users `$HOME/.tedge` (or in tests). - Only add the `tedge_config` crate. `tedge` is currently not modified to use the new API. - Remove remaining `unwrap`s, also from tests - No longer create intermediate directories upon saving configuration # FOLLOW-UP TASKS - Refactor the `tedge` crate to use `tedge_config`. - Compute the `device.id` from the certificate stored in `device.cert.path`, if any. - Ensure that the config is updated only by `tedge config set/unset`. - Extend tedge_config_location to also manage the paths to the bridge configuration files. - Update `ConfigRepository::store()` to properly set file ownership. --- tedge/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'tedge/Cargo.toml') diff --git a/tedge/Cargo.toml b/tedge/Cargo.toml index fa06d9de..af568516 100644 --- a/tedge/Cargo.toml +++ b/tedge/Cargo.toml @@ -30,6 +30,7 @@ which = "4.0" x509-parser = "0.9" zeroize = "1.2" sha-1 = "0.9" +tedge_config = { path = "../tedge_config" } [target.'cfg(unix)'.dependencies] users = "0.11.0" -- cgit v1.2.3