barrel/Running: Handle error case betters
This commit is contained in:
parent
aacde06636
commit
e968f0a5b9
1 changed files with 7 additions and 0 deletions
|
|
@ -5,12 +5,19 @@ import (
|
||||||
|
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||||
|
"github.com/compose-spec/compose-go/errdefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Running checks if this WissKI is currently running.
|
// Running checks if this WissKI is currently running.
|
||||||
func (barrel *Barrel) Running(ctx context.Context) (bool, error) {
|
func (barrel *Barrel) Running(ctx context.Context) (bool, error) {
|
||||||
containers, err := barrel.Docker.Containers(ctx, barrel.Stack().Dir)
|
containers, err := barrel.Docker.Containers(ctx, barrel.Stack().Dir)
|
||||||
if err != nil {
|
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 false, err
|
||||||
}
|
}
|
||||||
return len(containers) > 0, nil
|
return len(containers) > 0, nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue