From a8ecbbd365ba4e808333d0c0eedfd576e821fd84 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 13 Apr 2018 13:54:52 -0700 Subject: [PATCH] Check if config fields are nil --- pkg/commands/expose.go | 3 +++ pkg/commands/label.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/commands/expose.go b/pkg/commands/expose.go index 293ef541c..1778e6cc8 100644 --- a/pkg/commands/expose.go +++ b/pkg/commands/expose.go @@ -33,6 +33,9 @@ func (r *ExposeCommand) ExecuteCommand(config *manifest.Schema2Config) error { logrus.Info("cmd: EXPOSE") // Grab the currently exposed ports existingPorts := config.ExposedPorts + if existingPorts == nil { + existingPorts = make(map[manifest.Schema2Port]struct{}) + } // Add any new ones in for _, p := range r.cmd.Ports { // Resolve any environment variables diff --git a/pkg/commands/label.go b/pkg/commands/label.go index a9c42455a..93978d0c0 100644 --- a/pkg/commands/label.go +++ b/pkg/commands/label.go @@ -35,7 +35,9 @@ func (r *LabelCommand) ExecuteCommand(config *manifest.Schema2Config) error { func updateLabels(labels []instructions.KeyValuePair, config *manifest.Schema2Config) error { existingLabels := config.Labels - + if existingLabels == nil { + existingLabels = make(map[string]string) + } // Let's unescape values before setting the label for index, kvp := range labels { unescaped, err := util.ResolveEnvironmentReplacement(kvp.Value, []string{}, false)