Skip to content

Commit 3606c1c

Browse files
author
Corey Daley
committed
code updates for dependency bump
1 parent 239f74d commit 3606c1c

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

pkg/docker/docker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ type Docker interface {
122122
type Client interface {
123123
ContainerAttach(ctx context.Context, container string, options dockertypes.ContainerAttachOptions) (dockertypes.HijackedResponse, error)
124124
ContainerCommit(ctx context.Context, container string, options dockertypes.ContainerCommitOptions) (dockertypes.IDResponse, error)
125-
ContainerCreate(ctx context.Context, config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, networkingConfig *dockernetwork.NetworkingConfig, platform *v1.Platform, containerName string) (dockercontainer.ContainerCreateCreatedBody, error)
125+
ContainerCreate(ctx context.Context, config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, networkingConfig *dockernetwork.NetworkingConfig, platform *v1.Platform, containerName string) (dockercontainer.CreateResponse, error)
126126
ContainerInspect(ctx context.Context, container string) (dockertypes.ContainerJSON, error)
127127
ContainerRemove(ctx context.Context, container string, options dockertypes.ContainerRemoveOptions) error
128128
ContainerStart(ctx context.Context, container string, options dockertypes.ContainerStartOptions) error
129129
ContainerKill(ctx context.Context, container, signal string) error
130-
ContainerWait(ctx context.Context, container string, condition dockercontainer.WaitCondition) (<-chan dockercontainer.ContainerWaitOKBody, <-chan error)
130+
ContainerWait(ctx context.Context, container string, condition dockercontainer.WaitCondition) (<-chan dockercontainer.WaitResponse, <-chan error)
131131
CopyToContainer(ctx context.Context, container, path string, content io.Reader, opts dockertypes.CopyToContainerOptions) error
132132
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, dockertypes.ContainerPathStat, error)
133133
ImageBuild(ctx context.Context, buildContext io.Reader, options dockertypes.ImageBuildOptions) (dockertypes.ImageBuildResponse, error)
@@ -809,7 +809,7 @@ func determineCommandBaseDir(opts RunContainerOptions, imageMetadata *api.Image,
809809
}
810810

811811
// dumpContainerInfo dumps information about a running container (port/IP/etc).
812-
func dumpContainerInfo(container dockercontainer.ContainerCreateCreatedBody, d *stiDocker, image string) {
812+
func dumpContainerInfo(container dockercontainer.CreateResponse, d *stiDocker, image string) {
813813
ctx, cancel := getDefaultContext()
814814
defer cancel()
815815

pkg/docker/test/client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ func (d *FakeDockerClient) CopyFromContainer(ctx context.Context, container, src
130130
}
131131

132132
// ContainerWait pauses execution until a container exits.
133-
func (d *FakeDockerClient) ContainerWait(ctx context.Context, containerID string, condition dockercontainer.WaitCondition) (<-chan dockercontainer.ContainerWaitOKBody, <-chan error) {
133+
func (d *FakeDockerClient) ContainerWait(ctx context.Context, containerID string, condition dockercontainer.WaitCondition) (<-chan dockercontainer.WaitResponse, <-chan error) {
134134
d.WaitContainerID = containerID
135-
resultC := make(chan dockercontainer.ContainerWaitOKBody)
135+
resultC := make(chan dockercontainer.WaitResponse)
136136
errC := make(chan error, 1)
137137

138138
go func() {
@@ -141,7 +141,7 @@ func (d *FakeDockerClient) ContainerWait(ctx context.Context, containerID string
141141
return
142142
}
143143

144-
resultC <- dockercontainer.ContainerWaitOKBody{StatusCode: int64(d.WaitContainerResult)}
144+
resultC <- dockercontainer.WaitResponse{StatusCode: int64(d.WaitContainerResult)}
145145
}()
146146

147147
return resultC, errC
@@ -169,11 +169,11 @@ func (d *FakeDockerClient) ImageBuild(ctx context.Context, buildContext io.Reade
169169
}
170170

171171
// ContainerCreate creates a new container based in the given configuration.
172-
func (d *FakeDockerClient) ContainerCreate(ctx context.Context, config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, networkingConfig *dockernetwork.NetworkingConfig, platform *v1.Platform, containerName string) (dockercontainer.ContainerCreateCreatedBody, error) {
172+
func (d *FakeDockerClient) ContainerCreate(ctx context.Context, config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, networkingConfig *dockernetwork.NetworkingConfig, platform *v1.Platform, containerName string) (dockercontainer.CreateResponse, error) {
173173
d.Calls = append(d.Calls, "create")
174174

175175
d.Containers[containerName] = *config
176-
return dockercontainer.ContainerCreateCreatedBody{}, nil
176+
return dockercontainer.CreateResponse{}, nil
177177
}
178178

179179
// ContainerInspect returns the container information.

pkg/docker/util.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"strings"
1515

1616
"github.com/docker/distribution/reference"
17-
cliconfig "github.com/docker/docker/cli/config"
1817
"github.com/docker/docker/client"
18+
"github.com/docker/docker/pkg/homedir"
1919

2020
"github.com/openshift/source-to-image/pkg/api"
2121
"github.com/openshift/source-to-image/pkg/api/constants"
@@ -39,6 +39,18 @@ type AuthConfigurations struct {
3939
Configs map[string]api.AuthConfig
4040
}
4141

42+
// Dir returns the path to the configuration directory as specified by the DOCKER_CONFIG environment variable.
43+
// If DOCKER_CONFIG is unset, Dir returns ~/.docker .
44+
// Dir ignores XDG_CONFIG_HOME (same as the docker client).
45+
// TODO: this was copied from github.com/docker/docker/cli/[email protected]
46+
func Dir() string {
47+
configDir := os.Getenv("DOCKER_CONFIG")
48+
if len(configDir) == 0 {
49+
configDir = filepath.Join(homedir.Get(), ".docker")
50+
}
51+
return configDir
52+
}
53+
4254
type dockerConfig struct {
4355
Auth string `json:"auth"`
4456
Email string `json:"email"`
@@ -427,7 +439,7 @@ func GetDefaultDockerConfig() *api.DockerConfig {
427439

428440
certPath := os.Getenv("DOCKER_CERT_PATH")
429441
if certPath == "" {
430-
certPath = cliconfig.Dir()
442+
certPath = Dir()
431443
}
432444

433445
cfg.CertFile = filepath.Join(certPath, "cert.pem")

pkg/docker/util_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"os"
55
"testing"
66

7-
cliconfig "github.com/docker/docker/cli/config"
8-
97
"github.com/openshift/source-to-image/pkg/api"
108
"github.com/openshift/source-to-image/pkg/api/constants"
119
"github.com/openshift/source-to-image/pkg/util/user"
@@ -229,7 +227,7 @@ func TestGetDefaultDockerConfig(t *testing.T) {
229227
envTLS: "",
230228

231229
expectedHost: "unix:///var/run/docker.sock",
232-
expectedCertFile: cliconfig.Dir() + "/cert.pem",
230+
expectedCertFile: Dir() + "/cert.pem",
233231
expectedTLSVerify: false,
234232
expectedTLS: false,
235233
},

0 commit comments

Comments
 (0)