| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_CENTRAL_CONFIG_CONFIG_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_CENTRAL_CONFIG_CONFIG_H_ |
| |
| #include <string> |
| |
| #include "central_config.pb.h" |
| |
| namespace milotic_tlbmc { |
| |
| namespace internal { |
| // Merges the general config with the platform overrides. |
| TlbmcConfig MergeConfig(const TlbmcConfig& general_config, |
| const TlbmcConfig& platform_config); |
| // Parses the config from the given path to a `TlbmcConfigBundle` textproto or |
| // the rofs config bundle file if the given path is invalid. |
| // Then return the merged config for this platform. |
| TlbmcConfig GetConfigFromPathOrFallbackToDefault( |
| const std::string& config_bundle_path, |
| const std::string& release_file_path); |
| // Returns the platform name from the given release file path. If the release |
| // file path is invalid, returns an empty string. |
| std::string GetPlatformName(const std::string& release_file_path); |
| } // namespace internal |
| |
| // TlbmcConfig controls the behavior of tlbmc. |
| // Typical usage: |
| // In the main function: |
| // InitializeTlbmcConfig(*, *); |
| // |
| // In the code: |
| // if (GetTlbmcConfig().fru_collector_module().enabled()) { |
| // // Handle dangling FRUs. |
| // } |
| // |
| // In unit tests: |
| // GetMutableTlbmcConfigForTest().mutable_fru_collector_module() |
| // ->set_allow_dangling_frus(true) |
| // // Test code. |
| // GetMutableTlbmcConfigForTest().mutable_fru_collector_module() |
| // ->set_allow_dangling_frus(false) |
| // // Restore the original config. |
| TlbmcConfig& InitializeTlbmcConfig(const std::string& config_bundle_path, |
| const std::string& release_file_path); |
| |
| // Returns the TlbmcConfig for this platform. |
| const TlbmcConfig& GetTlbmcConfig(); |
| |
| TlbmcConfig& GetMutableTlbmcConfigForTest(); |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_CENTRAL_CONFIG_CONFIG_H_ |