Skip to content

Commit 5a47eec

Browse files
authored
fix: check config file before accessing values (runfinch#1120)
Signed-off-by: Sam Chew <stchew@amazon.com>
1 parent a49df29 commit 5a47eec

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cmd/finch/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func initializeNerdctlCommands(
4545
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
4646
}
4747

48-
if fc.DockerCompat {
48+
if fc != nil && fc.DockerCompat {
4949
for cmdName, cmdDescription := range dockerCompatCmds {
5050
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
5151
}

cmd/finch/nerdctl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ var cmdFlagSetMap = map[string]map[string]sets.Set[string]{
249249

250250
// converts "docker build --load" flag to "nerdctl build --output=type=docker".
251251
func handleDockerBuildLoad(_ NerdctlCommandSystemDeps, fc *config.Finch, nerdctlCmdArgs []string, index int) error {
252-
if fc.DockerCompat {
252+
if fc != nil && fc.DockerCompat {
253253
nerdctlCmdArgs[index] = "--output=type=docker"
254254
}
255255

@@ -280,7 +280,7 @@ func handleBuildx(_ NerdctlCommandSystemDeps, fc *config.Finch, cmdName *string,
280280
}
281281

282282
func handleDockerCompatInspect(_ NerdctlCommandSystemDeps, fc *config.Finch, cmdName *string, args *[]string) error {
283-
if !fc.DockerCompat {
283+
if fc == nil || !fc.DockerCompat {
284284
return nil
285285
}
286286

0 commit comments

Comments
 (0)