8#include <unordered_map>
18 const std::vector<WarningObject>& warnings);
49 void emit(
const std::string&
warning_key, std::unordered_map<std::string, std::string> fields = {});
68 struct CollectedWarning {
70 std::unordered_map<std::string, std::string> fields;
74 std::unordered_map<std::string, WarningAction> policy_;
75 std::vector<CollectedWarning> warnings_;
76 std::unordered_map<std::string, WarningAction> overrides_;
78 WarningAction get_effective_action(
const std::string& key)
const;
90 const std::string& source_path) {
91 return {{
"missing",
var_name}, {
"source_path", source_path}};
97 const std::string& source_kind,
99 return {{
"target",
target}, {
"source_kind", source_kind}, {
"source_ref",
source_ref}};
104 const std::string&
target,
105 const std::string&
reason,
106 const std::string& source_kind,
109 {
"source_kind", source_kind}, {
"source_ref",
source_ref}};
126 const std::string& operation) {
127 return {{
"operation", operation}};
132 const std::string& value,
133 const std::string& source_path) {
134 return {{
"value", value}, {
"source_path", source_path}};
139 const std::string&
reason,
140 const std::string& source_path,
141 const std::string& fields =
"") {
142 std::unordered_map<std::string, std::string>
result = {
143 {
"reason",
reason}, {
"source_path", source_path}
145 if (!fields.empty()) {
146 result[
"fields"] = fields;
153 const std::string& source_path) {
154 return {{
"source_path", source_path}};
Result type for fallible operations.
void emit(Warning warning)
WarningCollector(const std::unordered_map< std::string, WarningAction > &policy)
bool has_effective_warnings() const
void apply_override(const std::string &warning_key, WarningAction action)
void set_profile(const HostProfile *profile)
std::vector< WarningObject > get_warnings() const
WarningCollector(const HostProfile *profile)
void emit(const std::string &warning_key, std::unordered_map< std::string, std::string > fields={})
void emit(Warning warning, const std::unordered_map< std::string, std::string > &fields)
WarningCollector()=default
void emit_with_context(Warning warning, const std::string &context)
std::unordered_map< std::string, std::string > create_warning_fields(const std::vector< WarningObject > &warnings)