Factor out Machine::systemSupported

There's just enough logic (the `"builtin"` special case) that makes this
worthy of its own method.
This commit is contained in:
John Ericson 2024-01-23 12:52:54 -05:00
parent 870acc2892
commit 0aa85088de
3 changed files with 13 additions and 3 deletions

View File

@ -137,9 +137,8 @@ static int main_build_remote(int argc, char * * argv)
for (auto & m : machines) { for (auto & m : machines) {
debug("considering building on remote machine '%s'", m.storeUri); debug("considering building on remote machine '%s'", m.storeUri);
if (m.enabled if (m.enabled &&
&& (neededSystem == "builtin" m.systemSupported(neededSystem) &&
|| m.systemTypes.count(neededSystem) > 0) &&
m.allSupported(requiredFeatures) && m.allSupported(requiredFeatures) &&
m.mandatoryMet(requiredFeatures)) m.mandatoryMet(requiredFeatures))
{ {

View File

@ -38,6 +38,11 @@ Machine::Machine(decltype(storeUri) storeUri,
sshPublicHostKey(sshPublicHostKey) sshPublicHostKey(sshPublicHostKey)
{} {}
bool Machine::systemSupported(const std::string & system) const
{
return system == "builtin" || (systemTypes.count(system) > 0);
}
bool Machine::allSupported(const std::set<std::string> & features) const bool Machine::allSupported(const std::set<std::string> & features) const
{ {
return std::all_of(features.begin(), features.end(), return std::all_of(features.begin(), features.end(),

View File

@ -19,6 +19,12 @@ struct Machine {
const std::string sshPublicHostKey; const std::string sshPublicHostKey;
bool enabled = true; bool enabled = true;
/**
* @return Whether `system` is either `"builtin"` or in
* `systemTypes`.
*/
bool systemSupported(const std::string & system) const;
/** /**
* @return Whether `features` is a subset of the union of `supportedFeatures` and * @return Whether `features` is a subset of the union of `supportedFeatures` and
* `mandatoryFeatures` * `mandatoryFeatures`