Skip to content

Commit c828d1e

Browse files
committed
fix docker api package breaking change
1 parent 8a03aa6 commit c828d1e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

container_provisioner/containers/helper.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99

1010
"github.com/algo7/TripAdvisor-Review-Scraper/container_provisioner/database"
1111
"github.com/algo7/TripAdvisor-Review-Scraper/container_provisioner/utils"
12-
13-
"github.com/docker/docker/api/types"
1412
"github.com/docker/docker/api/types/container"
13+
"github.com/docker/docker/api/types/image"
1514
"github.com/docker/docker/api/types/network"
1615
"github.com/docker/docker/client"
1716
)
@@ -29,12 +28,12 @@ func initializeDockerClient() *client.Client {
2928
}
3029

3130
// PullImage pulls the given image from a registry
32-
func PullImage(image string) {
31+
func PullImage(imageName string) {
3332
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
3433
utils.ErrorHandler(err)
3534
defer cli.Close()
3635

37-
reader, err := cli.ImagePull(context.Background(), image, types.ImagePullOptions{})
36+
reader, err := cli.ImagePull(context.Background(), imageName, image.PullOptions{})
3837
utils.ErrorHandler(err)
3938
defer reader.Close()
4039

@@ -50,7 +49,7 @@ func RemoveContainer(containerID string) {
5049
defer cli.Close()
5150

5251
// Remove the container
53-
err = cli.ContainerRemove(context.Background(), containerID, types.ContainerRemoveOptions{
52+
err = cli.ContainerRemove(context.Background(), containerID, container.RemoveOptions{
5453
RemoveVolumes: true,
5554
Force: true,
5655
})
@@ -116,7 +115,7 @@ func TailLog(containerID string) io.Reader {
116115
defer cli.Close()
117116

118117
// Print the logs of the container
119-
out, err := cli.ContainerLogs(context.Background(), containerID, types.ContainerLogsOptions{
118+
out, err := cli.ContainerLogs(context.Background(), containerID, container.LogsOptions{
120119
ShowStdout: true,
121120
Details: true,
122121
ShowStderr: false,
@@ -160,7 +159,7 @@ func ListContainersByType(containerType string) []Container {
160159
defer cli.Close()
161160

162161
// List all containers
163-
containersInfo, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: false})
162+
containersInfo, err := cli.ContainerList(context.Background(), container.ListOptions{All: false})
164163
utils.ErrorHandler(err)
165164

166165
// Create a slice of Container structs

container_provisioner/containers/provisioner.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/algo7/TripAdvisor-Review-Scraper/container_provisioner/utils"
77

8-
"github.com/docker/docker/api/types"
98
"github.com/docker/docker/api/types/container"
109
"github.com/docker/docker/client"
1110
)
@@ -18,7 +17,7 @@ func Scrape(uploadIdentifier string, targetName string, containerID string) {
1817
defer cli.Close()
1918

2019
// Start the container
21-
err = cli.ContainerStart(context.Background(), containerID, types.ContainerStartOptions{})
20+
err = cli.ContainerStart(context.Background(), containerID, container.StartOptions{})
2221
utils.ErrorHandler(err)
2322

2423
// Wait for the container to exit

0 commit comments

Comments
 (0)