From 5a47eecdff1371ae0611aadcea251cadf648f856 Mon Sep 17 00:00:00 2001 From: Sam Chew Date: Thu, 3 Oct 2024 00:41:22 -0700 Subject: [PATCH] fix: check config file before accessing values (#1120) Signed-off-by: Sam Chew --- cmd/finch/main.go | 2 +- cmd/finch/nerdctl.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/finch/main.go b/cmd/finch/main.go index 0e77be70c..b605b2313 100644 --- a/cmd/finch/main.go +++ b/cmd/finch/main.go @@ -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)) } diff --git a/cmd/finch/nerdctl.go b/cmd/finch/nerdctl.go index 996535a18..cfeaf040b 100644 --- a/cmd/finch/nerdctl.go +++ b/cmd/finch/nerdctl.go @@ -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" } @@ -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 }