1 #ifndef STORAGE_CONFIG_H 2 #define STORAGE_CONFIG_H 7 #include <boost/filesystem.hpp> 8 #include <boost/property_tree/ptree_fwd.hpp> 10 #include "utilities/config_utils.h" 12 enum class StorageType { kFileSystem = 0, kSqlite };
15 StorageType type{StorageType::kSqlite};
16 boost::filesystem::path path{
"/var/sota"};
19 BasedPath uptane_metadata_path{
"metadata"};
20 BasedPath uptane_private_key_path{
"ecukey.der"};
21 BasedPath uptane_public_key_path{
"ecukey.pub"};
24 BasedPath tls_clientcert_path{
"client.pem"};
29 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
30 void writeToStream(std::ostream& out_stream)
const;
34 boost::filesystem::path base_path{
"/var/sota/import"};
41 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
42 void writeToStream(std::ostream& out_stream)
const;
46 inline void CopyFromConfig(StorageType& dest,
const std::string& option_name,
const boost::property_tree::ptree& pt) {
47 boost::optional<std::string> value = pt.get_optional<std::string>(option_name);
48 if (value.is_initialized()) {
49 std::string storage_type{StripQuotesFromStrings(value.get())};
50 if (storage_type ==
"sqlite") {
51 dest = StorageType::kSqlite;
53 dest = StorageType::kFileSystem;
58 #endif // STORAGE_CONFIG_H