-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstop.go
More file actions
32 lines (28 loc) · 843 Bytes
/
stop.go
File metadata and controls
32 lines (28 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package container
import (
"context"
"fmt"
"github.com/localstack/lstk/internal/config"
"github.com/localstack/lstk/internal/output"
"github.com/localstack/lstk/internal/runtime"
)
func Stop(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers []config.ContainerConfig) error {
for _, c := range containers {
name := c.Name()
running, err := rt.IsRunning(ctx, name)
if err != nil {
return fmt.Errorf("checking %s running: %w", name, err)
}
if !running {
return fmt.Errorf("LocalStack is not running")
}
output.EmitSpinnerStart(sink, "Stopping LocalStack...")
if err := rt.Stop(ctx, name); err != nil {
output.EmitSpinnerStop(sink)
return fmt.Errorf("failed to stop LocalStack: %w", err)
}
output.EmitSpinnerStop(sink)
output.EmitSuccess(sink, "LocalStack stopped")
}
return nil
}