From b3dc9d59cd0811c857c0c66f114aa96e75283702 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 6 Nov 2015 17:22:48 -0500 Subject: [PATCH] Use an empty slice as default value for DNS, DNSSearch and DNSOptions So we don't print those 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 Upstream-commit: 8c734c8cde079e6b0178f7e4af0146ca49f06dff Component: cli --- components/cli/opts/opts.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/cli/opts/opts.go b/components/cli/opts/opts.go index a61b82cdee..ed93002b24 100644 --- a/components/cli/opts/opts.go +++ b/components/cli/opts/opts.go @@ -95,6 +95,16 @@ func (opts *ListOpts) GetAll() []string { 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. func (opts *ListOpts) Get(key string) bool { for _, k := range *opts.values {