Simplify doRestart and doPurge actions

The actions now work by passing an intermediate state to the state
engine.

- doPurge first removes the user app from the target state and passes
  that to the state engine for purging. Since intermediate state doesn't
  remove images, this will have the effect of basically re-installing
  the app.

- doRestart modifies the target state by first removing only the
  services from the current state but keeping volumes and networks. This
  has the same effect as before where services were stopped one by one

Change-type: patch
This commit is contained in:
Felipe Lalanne
2023-04-07 11:45:09 -04:00
parent 43630e5267
commit 3d43f7e3b3
4 changed files with 55 additions and 49 deletions

View File

@ -123,6 +123,7 @@ export async function getRequiredSteps(
currentApps: InstancedAppState,
targetApps: InstancedAppState,
keepImages?: boolean,
keepVolumes?: boolean,
): Promise<CompositionStep[]> {
// get some required data
const [downloading, availableImages, { localMode, delta }] =
@ -139,11 +140,15 @@ export async function getRequiredSteps(
keepImages = localMode;
}
if (keepVolumes == null) {
keepVolumes = localMode;
}
return await inferNextSteps(currentApps, targetApps, {
// Images are not removed while in local mode to avoid removing the user app images
keepImages,
// Volumes are not removed when stopping an app when going to local mode
keepVolumes: localMode,
keepVolumes,
delta,
downloading,
availableImages,