This commit is contained in:
Oleksandr Redko 2026-04-19 15:25:30 -05:00 committed by GitHub
commit f9c4009232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 10 deletions

View file

@ -2,7 +2,6 @@ package commands
import ( import (
"context" "context"
"fmt"
"os/exec" "os/exec"
"strings" "strings"
@ -42,7 +41,7 @@ type Container struct {
// Remove removes the container // Remove removes the container
func (c *Container) Remove(options container.RemoveOptions) error { func (c *Container) Remove(options container.RemoveOptions) error {
c.Log.Warn(fmt.Sprintf("removing container %s", c.Name)) c.Log.Warnf("removing container %s", c.Name)
if err := c.Client.ContainerRemove(context.Background(), c.ID, options); err != nil { if err := c.Client.ContainerRemove(context.Background(), c.ID, options); err != nil {
if strings.Contains(err.Error(), "Stop the container before attempting removal or force remove") { if strings.Contains(err.Error(), "Stop the container before attempting removal or force remove") {
return ComplexError{ return ComplexError{
@ -65,25 +64,25 @@ func (c *Container) Start() error {
// Stop stops the container // Stop stops the container
func (c *Container) Stop() error { func (c *Container) Stop() error {
c.Log.Warn(fmt.Sprintf("stopping container %s", c.Name)) c.Log.Warnf("stopping container %s", c.Name)
return c.Client.ContainerStop(context.Background(), c.ID, container.StopOptions{}) return c.Client.ContainerStop(context.Background(), c.ID, container.StopOptions{})
} }
// Pause pauses the container // Pause pauses the container
func (c *Container) Pause() error { func (c *Container) Pause() error {
c.Log.Warn(fmt.Sprintf("pausing container %s", c.Name)) c.Log.Warnf("pausing container %s", c.Name)
return c.Client.ContainerPause(context.Background(), c.ID) return c.Client.ContainerPause(context.Background(), c.ID)
} }
// Unpause unpauses the container // Unpause unpauses the container
func (c *Container) Unpause() error { func (c *Container) Unpause() error {
c.Log.Warn(fmt.Sprintf("unpausing container %s", c.Name)) c.Log.Warnf("unpausing container %s", c.Name)
return c.Client.ContainerUnpause(context.Background(), c.ID) return c.Client.ContainerUnpause(context.Background(), c.ID)
} }
// Restart restarts the container // Restart restarts the container
func (c *Container) Restart() error { func (c *Container) Restart() error {
c.Log.Warn(fmt.Sprintf("restarting container %s", c.Name)) c.Log.Warnf("restarting container %s", c.Name)
return c.Client.ContainerRestart(context.Background(), c.ID, container.StopOptions{}) return c.Client.ContainerRestart(context.Background(), c.ID, container.StopOptions{})
} }
@ -102,7 +101,7 @@ func (c *Container) Attach() (*exec.Cmd, error) {
return nil, errors.New(c.Tr.CannotAttachStoppedContainerError) return nil, errors.New(c.Tr.CannotAttachStoppedContainerError)
} }
c.Log.Warn(fmt.Sprintf("attaching to container %s", c.Name)) c.Log.Warnf("attaching to container %s", c.Name)
// TODO: use SDK // TODO: use SDK
cmd := c.OSCommand.NewCmd("docker", "attach", "--sig-proxy=false", c.ID) cmd := c.OSCommand.NewCmd("docker", "attach", "--sig-proxy=false", c.ID)
return cmd, nil return cmd, nil

View file

@ -60,7 +60,7 @@ func (c *OSCommand) RunCommandWithOutput(command string) (string, error) {
cmd := c.ExecutableFromString(command) cmd := c.ExecutableFromString(command)
before := time.Now() before := time.Now()
output, err := sanitisedCommandOutput(cmd.Output()) output, err := sanitisedCommandOutput(cmd.Output())
c.Log.Warn(fmt.Sprintf("'%s': %s", command, time.Since(before))) c.Log.Warnf("'%s': %s", command, time.Since(before))
return output, err return output, err
} }
@ -69,7 +69,7 @@ func (c *OSCommand) RunCommandWithOutputContext(ctx context.Context, command str
cmd := c.ExecutableFromStringContext(ctx, command) cmd := c.ExecutableFromStringContext(ctx, command)
before := time.Now() before := time.Now()
output, err := sanitisedCommandOutput(cmd.Output()) output, err := sanitisedCommandOutput(cmd.Output())
c.Log.Warn(fmt.Sprintf("'%s': %s", command, time.Since(before))) c.Log.Warnf("'%s': %s", command, time.Since(before))
return output, err return output, err
} }

View file

@ -104,7 +104,7 @@ func (gui *Gui) createPopupPanel(title, prompt string, handleConfirm, handleClos
gui.g.Update(func(g *gocui.Gui) error { gui.g.Update(func(g *gocui.Gui) error {
if gui.currentViewName() == "confirmation" { if gui.currentViewName() == "confirmation" {
if err := gui.closeConfirmationPrompt(); err != nil { if err := gui.closeConfirmationPrompt(); err != nil {
gui.Log.Error(err.Error()) gui.Log.Error(err)
} }
} }
err := gui.prepareConfirmationPanel(title, prompt) err := gui.prepareConfirmationPanel(title, prompt)