Skip to content

Commit

Permalink
Merge pull request #95 from CSCfi/dependabot/go_modules/github.com/do…
Browse files Browse the repository at this point in the history
…cker/docker-26.0.0incompatible

Bump github.com/docker/docker from 25.0.5+incompatible to 26.0.0+incompatible
  • Loading branch information
blankdots authored Mar 25, 2024
2 parents 6dc4891 + 875834a commit 632b6d5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
13 changes: 6 additions & 7 deletions environments/docker/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"math/big"
mathrand "math/rand"
"net"
Expand Down Expand Up @@ -352,7 +351,7 @@ func (dc *Cluster) setupCA(opts *ClusterOptions) error {
dc.CACertPEM = pem.EncodeToMemory(CACertPEMBlock)

dc.CACertPEMFile = filepath.Join(dc.tmpDir, "ca", "ca.pem")
err = ioutil.WriteFile(dc.CACertPEMFile, dc.CACertPEM, 0o755)
err = os.WriteFile(dc.CACertPEMFile, dc.CACertPEM, 0o755)
if err != nil {
return err
}
Expand Down Expand Up @@ -418,13 +417,13 @@ func (n *dockerClusterNode) setupCert() error {
})

n.ServerCertPEMFile = filepath.Join(n.WorkDir, "cert.pem")
err = ioutil.WriteFile(n.ServerCertPEMFile, n.ServerCertPEM, 0o755)
err = os.WriteFile(n.ServerCertPEMFile, n.ServerCertPEM, 0o755)
if err != nil {
return err
}

n.ServerKeyPEMFile = filepath.Join(n.WorkDir, "key.pem")
err = ioutil.WriteFile(n.ServerKeyPEMFile, n.ServerKeyPEM, 0o755)
err = os.WriteFile(n.ServerKeyPEMFile, n.ServerKeyPEM, 0o755)
if err != nil {
return err
}
Expand Down Expand Up @@ -579,7 +578,7 @@ func (n *dockerClusterNode) start(cli *docker.Client, caDir, netName string, net
return err
}

err = ioutil.WriteFile(filepath.Join(n.WorkDir, "local.json"), cfgJSON, 0o644)
err = os.WriteFile(filepath.Join(n.WorkDir, "local.json"), cfgJSON, 0o644)
if err != nil {
return err
}
Expand Down Expand Up @@ -710,7 +709,7 @@ func (dc *Cluster) setupDockerCluster(opts *ClusterOptions) error {
}
dc.tmpDir = opts.tmpDir
} else {
tempDir, err := ioutil.TempDir("", "vault-test-cluster-")
tempDir, err := os.MkdirTemp("", "vault-test-cluster-")
if err != nil {
return err
}
Expand Down Expand Up @@ -826,7 +825,7 @@ func (dc *Cluster) Setup() error {
}

// tmpDir gets cleaned up when the cluster is cleaned up
tmpDir, err := ioutil.TempDir("", "vault-bin-")
tmpDir, err := os.MkdirTemp("", "vault-bin-")
if err != nil {
return err
}
Expand Down
21 changes: 11 additions & 10 deletions environments/docker/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package docker
import (
"context"
"fmt"
"io/ioutil"
"io"

"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/api/types/strslice"
docker "github.com/docker/docker/client"
Expand Down Expand Up @@ -56,41 +57,41 @@ func (d *Runner) Start(ctx context.Context) (*types.ContainerJSON, error) {
// Docker library, or if not found pull the matching image from docker hub. If
// not found on docker hub, returns an error. The response must be read in
// order for the local image to be used.
resp, err := d.dockerAPI.ImageCreate(ctx, d.ContainerConfig.Image, types.ImageCreateOptions{})
resp, err := d.dockerAPI.ImageCreate(ctx, d.ContainerConfig.Image, image.CreateOptions{})
if err != nil {
return nil, err
}
if resp != nil {
_, _ = ioutil.ReadAll(resp)
_, _ = io.ReadAll(resp)
}

cfg := *d.ContainerConfig
hostConfig.CapAdd = strslice.StrSlice{"IPC_LOCK", "NET_ADMIN"}
cfg.Hostname = d.ContainerName
fullName := d.ContainerName
container, err := d.dockerAPI.ContainerCreate(ctx, &cfg, hostConfig, networkingConfig, nil, fullName)
dockerContainer, err := d.dockerAPI.ContainerCreate(ctx, &cfg, hostConfig, networkingConfig, nil, fullName)
if err != nil {
return nil, fmt.Errorf("container create failed: %v", err)
}

// copies the plugin binary into the Docker file system. This copy is only
// allowed before the container is started
for from, to := range d.CopyFromTo {
if err := copyToContainer(ctx, d.dockerAPI, container.ID, from, to); err != nil {
_ = d.dockerAPI.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{})
if err := copyToContainer(ctx, d.dockerAPI, dockerContainer.ID, from, to); err != nil {
_ = d.dockerAPI.ContainerRemove(ctx, dockerContainer.ID, container.RemoveOptions{})
return nil, err
}
}

err = d.dockerAPI.ContainerStart(ctx, container.ID, types.ContainerStartOptions{})
err = d.dockerAPI.ContainerStart(ctx, dockerContainer.ID, container.StartOptions{})
if err != nil {
_ = d.dockerAPI.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{})
_ = d.dockerAPI.ContainerRemove(ctx, dockerContainer.ID, container.RemoveOptions{})
return nil, fmt.Errorf("container start failed: %v", err)
}

inspect, err := d.dockerAPI.ContainerInspect(ctx, container.ID)
inspect, err := d.dockerAPI.ContainerInspect(ctx, dockerContainer.ID)
if err != nil {
_ = d.dockerAPI.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{})
_ = d.dockerAPI.ContainerRemove(ctx, dockerContainer.ID, container.RemoveOptions{})
return nil, err
}
return &inspect, nil
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CSCfi/vault-testing-stepwise
go 1.20

require (
github.com/docker/docker v25.0.5+incompatible
github.com/docker/docker v26.0.0+incompatible
github.com/docker/go-connections v0.5.0
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-hclog v1.6.2
Expand Down Expand Up @@ -41,6 +41,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v26.0.0+incompatible h1:Ng2qi+gdKADUa/VM+6b6YaY2nlZhk/lVJiKR/2bMudU=
github.com/docker/docker v26.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand Down Expand Up @@ -107,6 +107,8 @@ github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUb
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo=
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
Expand Down

0 comments on commit 632b6d5

Please sign in to comment.