Skip to content

Commit 4fd3971

Browse files
authored
Add nil check for current docker context (#68)
* Add nil check for current docker contxt Signed-off-by: Evan Harris <echarris@smcm.edu> * Rm comments Signed-off-by: Evan Harris <echarris@smcm.edu> --------- Signed-off-by: Evan Harris <echarris@smcm.edu>
1 parent 5b8fa39 commit 4fd3971

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/crt/docker/dockerclient/client.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"path/filepath"
99
"strings"
1010

11-
"github.com/fsouza/go-dockerclient"
11+
docker "github.com/fsouza/go-dockerclient"
1212
log "github.com/sirupsen/logrus"
1313

1414
"github.com/mintoolkit/mint/pkg/app/master/config"
@@ -210,8 +210,12 @@ func New(config *config.DockerClient) (*docker.Client, error) {
210210
//so we need to lookup the context first to extract its connection info
211211
var currentDockerContext string
212212
if dcf, err := ReadConfigFile(ConfigFilePath()); err == nil {
213-
currentDockerContext = dcf.CurrentContext
214-
log.Debugf("dockerclient.New: currentDockerContext - '%s'", currentDockerContext)
213+
if dcf == nil {
214+
log.Debug("dockerclient.New: No config file.")
215+
} else {
216+
currentDockerContext = dcf.CurrentContext
217+
log.Debugf("dockerclient.New: currentDockerContext - '%s'", currentDockerContext)
218+
}
215219
} else {
216220
log.Debugf("dockerclient.New: ReadConfigFile error - %v", err)
217221
}

0 commit comments

Comments
 (0)