|
@@ -5,7 +5,7 @@ import (
|
|
|
|
|
|
"github.com/docker/docker/daemon/config"
|
|
|
"github.com/docker/docker/pkg/testutil"
|
|
|
- "github.com/docker/docker/pkg/testutil/tempfile"
|
|
|
+ "github.com/gotestyourself/gotestyourself/fs"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
"github.com/spf13/pflag"
|
|
|
"github.com/stretchr/testify/assert"
|
|
@@ -46,9 +46,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", `{"labels": ["l3=foo"]}`)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(`{"labels": ["l3=foo"]}`))
|
|
|
defer tempFile.Remove()
|
|
|
- configFile := tempFile.Name()
|
|
|
+ configFile := tempFile.Path()
|
|
|
|
|
|
opts := defaultOptions(configFile)
|
|
|
flags := opts.flags
|
|
@@ -62,10 +62,10 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": true}`)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": true}`))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
|
|
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
@@ -75,10 +75,10 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", `{"tlsverify": false}`)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(`{"tlsverify": false}`))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
|
|
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
@@ -88,10 +88,10 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", `{}`)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(`{}`))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
|
|
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
@@ -101,10 +101,10 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", `{"log-level": "warn"}`)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(`{"log-level": "warn"}`))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
|
require.NoError(t, err)
|
|
|
require.NotNil(t, loadedConfig)
|
|
@@ -114,10 +114,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
|
|
|
|
|
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
|
|
content := `{"tlscacert": "/etc/certs/ca.pem", "log-driver": "syslog"}`
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", content)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
|
require.NoError(t, err)
|
|
|
require.NotNil(t, loadedConfig)
|
|
@@ -131,10 +131,10 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
|
|
"registry-mirrors": ["https://mirrors.docker.com"],
|
|
|
"insecure-registries": ["https://insecure.docker.com"]
|
|
|
}`
|
|
|
- tempFile := tempfile.NewTempFile(t, "config", content)
|
|
|
+ tempFile := fs.NewFile(t, "config", fs.WithContent(content))
|
|
|
defer tempFile.Remove()
|
|
|
|
|
|
- opts := defaultOptions(tempFile.Name())
|
|
|
+ opts := defaultOptions(tempFile.Path())
|
|
|
loadedConfig, err := loadDaemonCliConfig(opts)
|
|
|
require.NoError(t, err)
|
|
|
require.NotNil(t, loadedConfig)
|