Fix regression in Dns and DnsSearch settings

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2015-03-24 16:17:05 -07:00
parent 1f06070f12
commit 83dcceacaf
2 changed files with 13 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import re
import os import os
from operator import attrgetter from operator import attrgetter
import sys import sys
import six
from docker.errors import APIError from docker.errors import APIError
from docker.utils import create_host_config from docker.utils import create_host_config
@ -435,11 +436,11 @@ class Service(object):
cap_drop = options.get('cap_drop', None) cap_drop = options.get('cap_drop', None)
dns = options.get('dns', None) dns = options.get('dns', None)
if not isinstance(dns, list): if isinstance(dns, six.string_types):
dns = [dns] dns = [dns]
dns_search = options.get('dns_search', None) dns_search = options.get('dns_search', None)
if not isinstance(dns_search, list): if isinstance(dns_search, six.string_types):
dns_search = [dns_search] dns_search = [dns_search]
restart = parse_restart_spec(options.get('restart', None)) restart = parse_restart_spec(options.get('restart', None))

View File

@ -424,6 +424,11 @@ class ServiceTest(DockerClientTestCase):
container = create_and_start_container(service) container = create_and_start_container(service)
self.assertEqual(container.get('HostConfig.NetworkMode'), 'host') self.assertEqual(container.get('HostConfig.NetworkMode'), 'host')
def test_dns_no_value(self):
service = self.create_service('web')
container = create_and_start_container(service)
self.assertIsNone(container.get('HostConfig.Dns'))
def test_dns_single_value(self): def test_dns_single_value(self):
service = self.create_service('web', dns='8.8.8.8') service = self.create_service('web', dns='8.8.8.8')
container = create_and_start_container(service) container = create_and_start_container(service)
@ -455,6 +460,11 @@ class ServiceTest(DockerClientTestCase):
container = create_and_start_container(service) container = create_and_start_container(service)
self.assertEqual(container.get('HostConfig.CapDrop'), ['SYS_ADMIN', 'NET_ADMIN']) self.assertEqual(container.get('HostConfig.CapDrop'), ['SYS_ADMIN', 'NET_ADMIN'])
def test_dns_search_no_value(self):
service = self.create_service('web')
container = create_and_start_container(service)
self.assertIsNone(container.get('HostConfig.DnsSearch'))
def test_dns_search_single_value(self): def test_dns_search_single_value(self):
service = self.create_service('web', dns_search='example.com') service = self.create_service('web', dns_search='example.com')
container = create_and_start_container(service) container = create_and_start_container(service)