Skip to content

Commit

Permalink
fix docker api package breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
algo7 committed May 20, 2024
1 parent 8a03aa6 commit c828d1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions container_provisioner/containers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (

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

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
)
Expand All @@ -29,12 +28,12 @@ func initializeDockerClient() *client.Client {
}

// PullImage pulls the given image from a registry
func PullImage(image string) {
func PullImage(imageName string) {
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
utils.ErrorHandler(err)
defer cli.Close()

reader, err := cli.ImagePull(context.Background(), image, types.ImagePullOptions{})
reader, err := cli.ImagePull(context.Background(), imageName, image.PullOptions{})
utils.ErrorHandler(err)
defer reader.Close()

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

// Remove the container
err = cli.ContainerRemove(context.Background(), containerID, types.ContainerRemoveOptions{
err = cli.ContainerRemove(context.Background(), containerID, container.RemoveOptions{
RemoveVolumes: true,
Force: true,
})
Expand Down Expand Up @@ -116,7 +115,7 @@ func TailLog(containerID string) io.Reader {
defer cli.Close()

// Print the logs of the container
out, err := cli.ContainerLogs(context.Background(), containerID, types.ContainerLogsOptions{
out, err := cli.ContainerLogs(context.Background(), containerID, container.LogsOptions{
ShowStdout: true,
Details: true,
ShowStderr: false,
Expand Down Expand Up @@ -160,7 +159,7 @@ func ListContainersByType(containerType string) []Container {
defer cli.Close()

// List all containers
containersInfo, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: false})
containersInfo, err := cli.ContainerList(context.Background(), container.ListOptions{All: false})
utils.ErrorHandler(err)

// Create a slice of Container structs
Expand Down
3 changes: 1 addition & 2 deletions container_provisioner/containers/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

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

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)
Expand All @@ -18,7 +17,7 @@ func Scrape(uploadIdentifier string, targetName string, containerID string) {
defer cli.Close()

// Start the container
err = cli.ContainerStart(context.Background(), containerID, types.ContainerStartOptions{})
err = cli.ContainerStart(context.Background(), containerID, container.StartOptions{})
utils.ErrorHandler(err)

// Wait for the container to exit
Expand Down

0 comments on commit c828d1e

Please sign in to comment.