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 };
13 std::ostream& operator<<(std::ostream& os, StorageType stype);
16 StorageType type{StorageType::kSqlite};
17 boost::filesystem::path path{
"/var/sota"};
20 BasedPath uptane_metadata_path{
"metadata"};
21 BasedPath uptane_private_key_path{
"ecukey.der"};
22 BasedPath uptane_public_key_path{
"ecukey.pub"};
25 BasedPath tls_clientcert_path{
"client.pem"};
30 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
31 void writeToStream(std::ostream& out_stream)
const;
35 boost::filesystem::path base_path{
"/var/sota/import"};
42 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
43 void writeToStream(std::ostream& out_stream)
const;
47 inline void CopyFromConfig(StorageType& dest,
const std::string& option_name,
const boost::property_tree::ptree& pt) {
48 boost::optional<std::string> value = pt.get_optional<std::string>(option_name);
49 if (value.is_initialized()) {
50 std::string storage_type{StripQuotesFromStrings(value.get())};
51 if (storage_type ==
"sqlite") {
52 dest = StorageType::kSqlite;
54 dest = StorageType::kFileSystem;
59 #endif // STORAGE_CONFIG_H