Use an empty slice as default value for DNS, DNSSearch and DNSOptions

So we don't print those <no value> in the client and we don't fail
executing inspect templates with API field names.

Make sure those fields are initialized as empty slices when
a container is loaded from disk and their values are nil.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-11-06 17:22:48 -05:00 committed by Vincent Demeester
parent d02ac2a694
commit 8c734c8cde
1 changed files with 10 additions and 0 deletions

View File

@ -95,6 +95,16 @@ func (opts *ListOpts) GetAll() []string {
return (*opts.values) return (*opts.values)
} }
// GetAllOrEmpty returns the values of the slice
// or an empty slice when there are no values.
func (opts *ListOpts) GetAllOrEmpty() []string {
v := *opts.values
if v == nil {
return make([]string, 0)
}
return v
}
// Get checks the existence of the specified key. // Get checks the existence of the specified key.
func (opts *ListOpts) Get(key string) bool { func (opts *ListOpts) Get(key string) bool {
for _, k := range *opts.values { for _, k := range *opts.values {