refactor: add String() methods to domain types, replace string() casts
This commit is contained in:
@@ -253,7 +253,7 @@ func (c *Client) StartContainer(ctx context.Context, containerID domain.Containe
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func (c *Client) StopContainer(ctx context.Context, containerID domain.Container
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -291,7 +291,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)
|
||||
}
|
||||
@@ -315,7 +315,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)
|
||||
}
|
||||
@@ -344,7 +344,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)
|
||||
}
|
||||
@@ -361,7 +361,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)
|
||||
}
|
||||
@@ -484,7 +484,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 domain.ImageID) error {
|
||||
_, err := c.docker.ImageRemove(ctx, string(imageID), image.RemoveOptions{
|
||||
_, err := c.docker.ImageRemove(ctx, imageID.String(), image.RemoveOptions{
|
||||
Force: true,
|
||||
PruneChildren: true,
|
||||
})
|
||||
@@ -610,7 +610,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)
|
||||
@@ -680,12 +680,12 @@ func (c *Client) createGitContainer(
|
||||
}
|
||||
|
||||
func (c *Client) runGitClone(ctx context.Context, containerID domain.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