Skip to content

Commit

Permalink
fix: check config file before accessing values (#1120)
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Chew <[email protected]>
  • Loading branch information
chews93319 authored Oct 3, 2024
1 parent a49df29 commit 5a47eec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/finch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func initializeNerdctlCommands(
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
}

if fc.DockerCompat {
if fc != nil && fc.DockerCompat {
for cmdName, cmdDescription := range dockerCompatCmds {
allNerdctlCommands = append(allNerdctlCommands, nerdctlCommandCreator.create(cmdName, cmdDescription))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/finch/nerdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ var cmdFlagSetMap = map[string]map[string]sets.Set[string]{

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

Expand Down Expand Up @@ -280,7 +280,7 @@ func handleBuildx(_ NerdctlCommandSystemDeps, fc *config.Finch, cmdName *string,
}

func handleDockerCompatInspect(_ NerdctlCommandSystemDeps, fc *config.Finch, cmdName *string, args *[]string) error {
if !fc.DockerCompat {
if fc == nil || !fc.DockerCompat {
return nil
}

Expand Down

0 comments on commit 5a47eec

Please sign in to comment.