feat: implement Stringer on custom string types
Add String() methods to ImageID, ContainerID, and UnparsedURL. Replace all string() casts with .String() method calls throughout the codebase for cleaner interface compliance.
This commit is contained in:
@@ -252,7 +252,7 @@ func (c *Client) StartContainer(ctx context.Context, containerID ContainerID) er
|
||||
|
||||
c.log.Info("starting container", "id", containerID)
|
||||
|
||||
err := c.docker.ContainerStart(ctx, string(containerID), container.StartOptions{})
|
||||
err := c.docker.ContainerStart(ctx, containerID.String(), container.StartOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start container: %w", err)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func (c *Client) StopContainer(ctx context.Context, containerID ContainerID) err
|
||||
|
||||
timeout := stopTimeoutSeconds
|
||||
|
||||
err := c.docker.ContainerStop(ctx, string(containerID), container.StopOptions{Timeout: &timeout})
|
||||
err := c.docker.ContainerStop(ctx, containerID.String(), container.StopOptions{Timeout: &timeout})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to stop container: %w", err)
|
||||
}
|
||||
@@ -290,7 +290,7 @@ func (c *Client) RemoveContainer(
|
||||
|
||||
c.log.Info("removing container", "id", containerID, "force", force)
|
||||
|
||||
err := c.docker.ContainerRemove(ctx, string(containerID), container.RemoveOptions{Force: force})
|
||||
err := c.docker.ContainerRemove(ctx, containerID.String(), container.RemoveOptions{Force: force})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to remove container: %w", err)
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func (c *Client) ContainerLogs(
|
||||
Tail: tail,
|
||||
}
|
||||
|
||||
reader, err := c.docker.ContainerLogs(ctx, string(containerID), opts)
|
||||
reader, err := c.docker.ContainerLogs(ctx, containerID.String(), opts)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get container logs: %w", err)
|
||||
}
|
||||
@@ -343,7 +343,7 @@ func (c *Client) IsContainerRunning(
|
||||
return false, ErrNotConnected
|
||||
}
|
||||
|
||||
inspect, err := c.docker.ContainerInspect(ctx, string(containerID))
|
||||
inspect, err := c.docker.ContainerInspect(ctx, containerID.String())
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to inspect container: %w", err)
|
||||
}
|
||||
@@ -360,7 +360,7 @@ func (c *Client) IsContainerHealthy(
|
||||
return false, ErrNotConnected
|
||||
}
|
||||
|
||||
inspect, err := c.docker.ContainerInspect(ctx, string(containerID))
|
||||
inspect, err := c.docker.ContainerInspect(ctx, containerID.String())
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to inspect container: %w", err)
|
||||
}
|
||||
@@ -483,7 +483,7 @@ func (c *Client) CloneRepo(
|
||||
// RemoveImage removes a Docker image by ID or tag.
|
||||
// It returns nil if the image was successfully removed or does not exist.
|
||||
func (c *Client) RemoveImage(ctx context.Context, imageID ImageID) error {
|
||||
_, err := c.docker.ImageRemove(ctx, string(imageID), image.RemoveOptions{
|
||||
_, err := c.docker.ImageRemove(ctx, imageID.String(), image.RemoveOptions{
|
||||
Force: true,
|
||||
PruneChildren: true,
|
||||
})
|
||||
@@ -609,7 +609,7 @@ func (c *Client) performClone(ctx context.Context, cfg *cloneConfig) (*CloneResu
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_ = c.docker.ContainerRemove(ctx, string(gitContainerID), container.RemoveOptions{Force: true})
|
||||
_ = c.docker.ContainerRemove(ctx, gitContainerID.String(), container.RemoveOptions{Force: true})
|
||||
}()
|
||||
|
||||
return c.runGitClone(ctx, gitContainerID)
|
||||
@@ -679,12 +679,12 @@ func (c *Client) createGitContainer(
|
||||
}
|
||||
|
||||
func (c *Client) runGitClone(ctx context.Context, containerID ContainerID) (*CloneResult, error) {
|
||||
err := c.docker.ContainerStart(ctx, string(containerID), container.StartOptions{})
|
||||
err := c.docker.ContainerStart(ctx, containerID.String(), container.StartOptions{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to start git container: %w", err)
|
||||
}
|
||||
|
||||
statusCh, errCh := c.docker.ContainerWait(ctx, string(containerID), container.WaitConditionNotRunning)
|
||||
statusCh, errCh := c.docker.ContainerWait(ctx, containerID.String(), container.WaitConditionNotRunning)
|
||||
|
||||
select {
|
||||
case err := <-errCh:
|
||||
|
||||
Reference in New Issue
Block a user