Minor refactoring.

This commit is contained in:
Michael Lipp 2025-01-14 10:22:56 +01:00
parent db7fbe2b7c
commit 15ac0721a6
3 changed files with 19 additions and 24 deletions

View file

@ -268,6 +268,21 @@ public class VmDefinition {
this.status = status;
}
/**
* Return a condition's status.
*
* @param name the condition's name
* @return the status, if the condition is defined
*/
public Optional<Boolean> conditionStatus(String name) {
return this.<List<Map<String, Object>>> fromStatus("conditions")
.orElse(Collections.emptyList()).stream()
.filter(cond -> DataPath.get(cond, "type")
.map(name::equals).orElse(false))
.findFirst().map(cond -> DataPath.get(cond, "status")
.map("True"::equals).orElse(false));
}
/**
* Set extra data (locally used, unknown to kubernetes).
*