Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions app/modules/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ func ExecPruneContainers(ctx *context.LedoContext) error {
containerArgs = append(containerArgs, formatArgs...)

spinnerLiveText, _ := pterm.DefaultSpinner.Start("Getting containers to prune...")
output, _ := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
output, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
if err != nil {
spinnerLiveText.Fail("Getting containers to prune... Error!")
return err
}
spinnerLiveText.Success("Getting containers to prune... Done!")

lines := strings.Split(string(output[:]), "\n")
Expand All @@ -132,15 +136,15 @@ func ExecPruneContainers(ctx *context.LedoContext) error {
rmargs = append(rmargs, "rm")
rmargs = append(rmargs, container)
rmargs = append(rmargs, "--force")
_, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
_, err = ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
if err != nil {
return err
}

progressbar.Increment()
}

_, err := progressbar.Stop()
_, err = progressbar.Stop()
if err != nil {
return err
}
Expand All @@ -159,7 +163,11 @@ func ExecPruneImages(ctx *context.LedoContext) error {
containerArgs = append(containerArgs, formatArgs...)

spinnerLiveText, _ := pterm.DefaultSpinner.Start("Getting images to prune...")
output, _ := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
output, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
if err != nil {
spinnerLiveText.Fail("Getting images to prune... Error!")
return err
}
spinnerLiveText.Success("Getting images to prune... Done!")

lines := strings.Split(string(output[:]), "\n")
Expand All @@ -174,15 +182,15 @@ func ExecPruneImages(ctx *context.LedoContext) error {
rmargs = append(rmargs, "rmi")
rmargs = append(rmargs, image)
rmargs = append(rmargs, "--force")
_, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
_, err = ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
if err != nil {
return err
}

progressbar.Increment()
}

_, err := progressbar.Stop()
_, err = progressbar.Stop()
if err != nil {
return err
}
Expand All @@ -201,7 +209,11 @@ func ExecPruneVolumes(ctx *context.LedoContext) error {
containerArgs = append(containerArgs, formatArgs...)

spinnerLiveText, _ := pterm.DefaultSpinner.Start("Getting volumes to prune...")
output, _ := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
output, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
if err != nil {
spinnerLiveText.Fail("Getting volumes to prune... Error!")
return err
}
spinnerLiveText.Success("Getting volumes to prune... Done!")

lines := strings.Split(string(output[:]), "\n")
Expand All @@ -217,15 +229,15 @@ func ExecPruneVolumes(ctx *context.LedoContext) error {
rmargs = append(rmargs, "rm")
rmargs = append(rmargs, image)
rmargs = append(rmargs, "--force")
_, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
_, err = ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
if err != nil {
return err
}

progressbar.Increment()
}

_, err := progressbar.Stop()
_, err = progressbar.Stop()
if err != nil {
return err
}
Expand All @@ -244,7 +256,11 @@ func ExecPruneNetworks(ctx *context.LedoContext) error {
containerArgs = append(containerArgs, formatArgs...)

spinnerLiveText, _ := pterm.DefaultSpinner.Start("Getting networks to prune...")
output, _ := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
output, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), containerArgs[0:])
if err != nil {
spinnerLiveText.Fail("Getting networks to prune... Error!")
return err
}
spinnerLiveText.Success("Getting networks to prune... Done!")

lines := strings.Split(string(output[:]), "\n")
Expand All @@ -259,15 +275,15 @@ func ExecPruneNetworks(ctx *context.LedoContext) error {
rmargs = append(rmargs, "network")
rmargs = append(rmargs, "rm")
rmargs = append(rmargs, network)
_, err := ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
_, err = ctx.ExecCmdOutput(ctx.GetRuntimeCommand(), rmargs[0:])
if err != nil {
return err
}

progressbar.Increment()
}

_, err := progressbar.Stop()
_, err = progressbar.Stop()
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion app/modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func (lx *LedoContext) GetRuntimeCompose() string {
}

func (lx *LedoContext) ExecCmdOutput(cmd string, cmdArgs []string) ([]byte, error) {
command, _ := exec.Command(cmd, cmdArgs...).Output()
command, err := exec.Command(cmd, cmdArgs...).Output()
if err != nil {
return nil, err
}
return command, nil
}

Expand Down