зеркало из https://github.com/microsoft/docker.git
Fix pkg/plugins TLSConfig panic
Fix #25046 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Родитель
4144e11d32
Коммит
b1e71bdd1d
|
@ -116,7 +116,7 @@ func readPluginJSONInfo(name, path string) (*Plugin, error) {
|
|||
return nil, err
|
||||
}
|
||||
p.name = name
|
||||
if len(p.TLSConfig.CAFile) == 0 {
|
||||
if p.TLSConfig != nil && len(p.TLSConfig.CAFile) == 0 {
|
||||
p.TLSConfig.InsecureSkipVerify = true
|
||||
}
|
||||
p.activateWait = sync.NewCond(&sync.Mutex{})
|
||||
|
|
|
@ -117,3 +117,36 @@ func TestFileJSONSpecPlugin(t *testing.T) {
|
|||
t.Fatalf("Expected plugin Key `/usr/shared/docker/certs/example-key.pem`, got %s\n", plugin.TLSConfig.KeyFile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileJSONSpecPluginWithoutTLSConfig(t *testing.T) {
|
||||
tmpdir, unregister := Setup(t)
|
||||
defer unregister()
|
||||
|
||||
p := filepath.Join(tmpdir, "example.json")
|
||||
spec := `{
|
||||
"Name": "plugin-example",
|
||||
"Addr": "https://example.com/docker/plugin"
|
||||
}`
|
||||
|
||||
if err := ioutil.WriteFile(p, []byte(spec), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := newLocalRegistry()
|
||||
plugin, err := r.Plugin("example")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if plugin.name != "example" {
|
||||
t.Fatalf("Expected plugin `plugin-example`, got %s\n", plugin.Name)
|
||||
}
|
||||
|
||||
if plugin.Addr != "https://example.com/docker/plugin" {
|
||||
t.Fatalf("Expected plugin addr `https://example.com/docker/plugin`, got %s\n", plugin.Addr)
|
||||
}
|
||||
|
||||
if plugin.TLSConfig != nil {
|
||||
t.Fatalf("Expected plugin TLSConfig nil, got %v\n", plugin.TLSConfig)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче