feat: Update 3 files
This commit is contained in:
@@ -16,7 +16,8 @@ bool validate_and_fix_service_env(
|
||||
const std::string& template_service_env_path,
|
||||
const std::string& service_env_path,
|
||||
std::vector<std::string>& missing_vars,
|
||||
std::vector<std::string>& extra_vars
|
||||
std::vector<std::string>& extra_vars,
|
||||
const std::string& template_info_env_path
|
||||
) {
|
||||
missing_vars.clear();
|
||||
extra_vars.clear();
|
||||
@@ -37,6 +38,19 @@ bool validate_and_fix_service_env(
|
||||
template_var_names.insert(key);
|
||||
}
|
||||
|
||||
// Also load template_info.env if provided - these variables are allowed in service.env
|
||||
std::set<std::string> template_info_var_names;
|
||||
if (!template_info_env_path.empty() && std::filesystem::exists(template_info_env_path)) {
|
||||
envmanager template_info_env(template_info_env_path);
|
||||
if (template_info_env.load()) {
|
||||
ordered_env_vars template_info_vars;
|
||||
template_info_env.get_all_variables(template_info_vars);
|
||||
for (const auto& [key, value] : template_info_vars) {
|
||||
template_info_var_names.insert(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load service service.env
|
||||
envmanager service_env(service_env_path);
|
||||
if (!service_env.load()) {
|
||||
@@ -60,9 +74,10 @@ bool validate_and_fix_service_env(
|
||||
}
|
||||
}
|
||||
|
||||
// Find extra variables (in service but not in template)
|
||||
// Find extra variables (in service but not in template or template_info)
|
||||
for (const auto& service_var_name : service_var_names) {
|
||||
if (template_var_names.find(service_var_name) == template_var_names.end()) {
|
||||
if (template_var_names.find(service_var_name) == template_var_names.end() &&
|
||||
template_info_var_names.find(service_var_name) == template_info_var_names.end()) {
|
||||
extra_vars.push_back(service_var_name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user