Skip to content

Commit 467b324

Browse files
committed
Add nil check for current docker contxt
Signed-off-by: Evan Harris <[email protected]>
1 parent 5b8fa39 commit 467b324

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/crt/docker/dockerclient/client.go

Lines changed: 9 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,14 @@ 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+
// Handle the case where CurrentContext is empty
217+
// For example, set a default context or log a warning
218+
currentDockerContext = dcf.CurrentContext
219+
log.Debugf("dockerclient.New: currentDockerContext - '%s'", currentDockerContext)
220+
}
215221
} else {
216222
log.Debugf("dockerclient.New: ReadConfigFile error - %v", err)
217223
}

0 commit comments

Comments
 (0)