config: Check configuration file version

We don't know what the future versions of the configuration file will
look like.  The current code can process only version 1; let's check
that the read configuration is of this version.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Milan Zamazal
2025-09-12 16:29:14 +02:00
committed by Laurent Pinchart
parent 79a75b9088
commit d03a4fbfcd

View File

@@ -72,6 +72,15 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)
return true;
}
const std::optional<int> version = (*configuration)["version"].get<int>();
if (version != 1) {
LOG(Configuration, Error)
<< "Failed to load configuration file due to unsupported version "
<< (version ? std::to_string(version.value()) : "\"unspecified\"")
<< ", expected version 1";
return true;
}
yamlConfiguration_ = std::move(configuration);
return true;
}