From 73f9eb383b7aabf6cfe46750a6d7732a6f9012f2 Mon Sep 17 00:00:00 2001
From: Ian Howell <ian.howell0@gmail.com>
Date: Mon, 27 Jan 2020 12:08:34 -0600
Subject: [PATCH] Fix an output bug in get-context

This fixes an issue where `airshipctl config get-context` would provide
no output when there were no contexts in the configuration.

Change-Id: I8eaafff8ecee7878f80d22867b0420feba1bf376
---
 cmd/config/get_context.go                                     | 4 ++--
 .../no-contexts.golden                                        | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/config/get_context.go b/cmd/config/get_context.go
index a4abdda9e..cb902e363 100644
--- a/cmd/config/get_context.go
+++ b/cmd/config/get_context.go
@@ -95,8 +95,8 @@ func getContexts(out io.Writer, airconfig *config.Config) error {
 	if err != nil {
 		return err
 	}
-	if contexts == nil {
-		fmt.Fprint(out, "No Contexts found in the configuration.\n")
+	if len(contexts) == 0 {
+		fmt.Fprintln(out, "No Contexts found in the configuration.")
 	}
 	for _, context := range contexts {
 		fmt.Fprintf(out, "%s", context.PrettyString())
diff --git a/cmd/config/testdata/TestNoContextsGetContextCmdGoldenOutput/no-contexts.golden b/cmd/config/testdata/TestNoContextsGetContextCmdGoldenOutput/no-contexts.golden
index e69de29bb..e8e4b77ed 100644
--- a/cmd/config/testdata/TestNoContextsGetContextCmdGoldenOutput/no-contexts.golden
+++ b/cmd/config/testdata/TestNoContextsGetContextCmdGoldenOutput/no-contexts.golden
@@ -0,0 +1 @@
+No Contexts found in the configuration.