From 4fd397137adb696e353a4e3212d91571cc4536ab Mon Sep 17 00:00:00 2001 From: Evan Harris Date: Sun, 27 Oct 2024 13:40:19 -0400 Subject: [PATCH] Add nil check for current docker context (#68) * Add nil check for current docker contxt Signed-off-by: Evan Harris * Rm comments Signed-off-by: Evan Harris --------- Signed-off-by: Evan Harris --- pkg/crt/docker/dockerclient/client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/crt/docker/dockerclient/client.go b/pkg/crt/docker/dockerclient/client.go index 86e3fa60..635fe4e2 100644 --- a/pkg/crt/docker/dockerclient/client.go +++ b/pkg/crt/docker/dockerclient/client.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strings" - "github.com/fsouza/go-dockerclient" + docker "github.com/fsouza/go-dockerclient" log "github.com/sirupsen/logrus" "github.com/mintoolkit/mint/pkg/app/master/config" @@ -210,8 +210,12 @@ func New(config *config.DockerClient) (*docker.Client, error) { //so we need to lookup the context first to extract its connection info var currentDockerContext string if dcf, err := ReadConfigFile(ConfigFilePath()); err == nil { - currentDockerContext = dcf.CurrentContext - log.Debugf("dockerclient.New: currentDockerContext - '%s'", currentDockerContext) + if dcf == nil { + log.Debug("dockerclient.New: No config file.") + } else { + currentDockerContext = dcf.CurrentContext + log.Debugf("dockerclient.New: currentDockerContext - '%s'", currentDockerContext) + } } else { log.Debugf("dockerclient.New: ReadConfigFile error - %v", err) }