Skip to content

Commit 1ca5c87

Browse files
authored
Merge pull request #293 from ulyssessouza/export-docker-client-options
Export "BuildDockerClientOptions"
2 parents ce42d4a + 5e7dd4d commit 1ca5c87

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

driver/docker/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ func GetDockerClient() (*command.DockerCli, error) {
2929
if err != nil {
3030
return nil, fmt.Errorf("could not create new docker client: %w", err)
3131
}
32-
opts := buildDockerClientOptions()
32+
opts := BuildDockerClientOptions()
3333
if err = cli.Initialize(opts); err != nil {
3434
return nil, fmt.Errorf("error initializing docker client: %w", err)
3535
}
3636
return cli, nil
3737
}
3838

39-
// manually handle DOCKER_TLS_VERIFY and DOCKER_CERT_PATH because the docker cli
39+
// BuildDockerClientOptions manually handles DOCKER_TLS_VERIFY and DOCKER_CERT_PATH because the docker cli
4040
// library only binds these values when initializing its cli flags. There isn't
4141
// other parts of the library that we can take advantage of to get these values
4242
// for "free".
4343
//
4444
// DOCKER_HOST however is retrieved dynamically later so that doesn't
4545
// require additional configuration.
46-
func buildDockerClientOptions() *cliflags.ClientOptions {
46+
func BuildDockerClientOptions() *cliflags.ClientOptions {
4747
cliOpts := cliflags.NewClientOptions()
4848
cliOpts.ConfigDir = cliconfig.Dir()
4949

driver/docker/client_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Test_buildDockerClientOptions(t *testing.T) {
2727

2828
t.Run("tls disabled", func(t *testing.T) {
2929
os.Unsetenv(DockerTLSVerifyEnvVar)
30-
opts := buildDockerClientOptions()
30+
opts := BuildDockerClientOptions()
3131
assert.False(t, opts.Common.TLS, "expected TLS to be disabled")
3232
assert.False(t, opts.Common.TLSVerify, "expected TLSVerify to be disabled")
3333
assert.Nil(t, opts.Common.TLSOptions, "expected TLSOptions to be unset")
@@ -40,7 +40,7 @@ func Test_buildDockerClientOptions(t *testing.T) {
4040
os.Unsetenv(DockerTLSVerifyEnvVar)
4141
}()
4242

43-
opts := buildDockerClientOptions()
43+
opts := BuildDockerClientOptions()
4444
assert.True(t, opts.Common.TLS, "expected TLS to be enabled")
4545
assert.True(t, opts.Common.TLSVerify, "expected the certs to be verified")
4646
assert.Equal(t, defaultTLSOptions, opts.Common.TLSOptions, "expected TLSOptions to be initialized to the default TLS settings")
@@ -54,7 +54,7 @@ func Test_buildDockerClientOptions(t *testing.T) {
5454
os.Unsetenv(DockerCertPathEnvVar)
5555
}()
5656

57-
opts := buildDockerClientOptions()
57+
opts := BuildDockerClientOptions()
5858
assert.True(t, opts.Common.TLS, "expected TLS to be enabled")
5959
assert.True(t, opts.Common.TLSVerify, "expected the certs to be verified")
6060
assert.Equal(t, customTLSOptions, opts.Common.TLSOptions, "expected TLSOptions to use the custom DOCKER_CERT_PATH set")
@@ -68,7 +68,7 @@ func Test_buildDockerClientOptions(t *testing.T) {
6868
os.Unsetenv(DockerCertPathEnvVar)
6969
}()
7070

71-
opts := buildDockerClientOptions()
71+
opts := BuildDockerClientOptions()
7272
assert.True(t, opts.Common.TLS, "expected TLS to be enabled")
7373
assert.False(t, opts.Common.TLSVerify, "expected TLSVerify to be false")
7474
assert.Equal(t, customTLSOptions, opts.Common.TLSOptions, "expected TLSOptions to use the custom DOCKER_CERT_PATH set")

0 commit comments

Comments
 (0)