Skip to content

Commit

Permalink
Check for bounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdappollonio committed Nov 12, 2024
1 parent d8e8529 commit 021f562
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func (c *Client) RemoveColonyK3sContainer(ctx context.Context) error {
return fmt.Errorf("error getting %q container: %w", constants.ColonyK3sContainerName, err)
}

c.log.Infof("found container name %q with ID %q", strings.TrimPrefix(k3scontainer.Names[0], "/"), k3scontainer.ID[:constants.DefaultDockerIDLength])
if len(k3scontainer.Names) > 0 && len(k3scontainer.ID) > constants.DefaultDockerIDLength {
c.log.Infof("found container name %q with ID %q", strings.TrimPrefix(k3scontainer.Names[0], "/"), k3scontainer.ID[:constants.DefaultDockerIDLength])
} else {
c.log.Warnf("found container with ID %q -- unable to parse a name or an ID out of it", k3scontainer.ID)
}

err = c.cli.ContainerStop(ctx, k3scontainer.ID, containerTypes.StopOptions{})
if err != nil {
Expand Down

0 comments on commit 021f562

Please sign in to comment.