barrel/Running: Handle error case betters

This commit is contained in:
Tom Wiesing 2023-11-15 11:02:59 +01:00
parent aacde06636
commit e968f0a5b9
No known key found for this signature in database

View file

@ -5,12 +5,19 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
"github.com/compose-spec/compose-go/errdefs"
)
// Running checks if this WissKI is currently running.
func (barrel *Barrel) Running(ctx context.Context) (bool, error) {
containers, err := barrel.Docker.Containers(ctx, barrel.Stack().Dir)
if err != nil {
// The compose file is gone => the stack doesn't exist.
// Probably means some purging got interrupted.
if errdefs.IsNotFoundError(err) {
return false, nil
}
return false, err
}
return len(containers) > 0, nil