fix: panic (#2071)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Jason Song 2023-11-04 22:10:53 +08:00 committed by GitHub
parent 1bb2ee7098
commit 5a79256ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -16,15 +16,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/go-git/go-billy/v5/helper/polyfill" "github.com/Masterminds/semver"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/joho/godotenv"
"github.com/imdario/mergo"
"github.com/kballard/go-shellquote"
"github.com/spf13/pflag"
"github.com/docker/cli/cli/connhelper" "github.com/docker/cli/cli/connhelper"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
@ -32,9 +24,14 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/go-git/go-billy/v5/helper/polyfill"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/imdario/mergo"
"github.com/joho/godotenv"
"github.com/kballard/go-shellquote"
specs "github.com/opencontainers/image-spec/specs-go/v1" specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/spf13/pflag"
"github.com/Masterminds/semver"
"golang.org/x/term" "golang.org/x/term"
"github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/common"
@ -484,11 +481,17 @@ func (cr *containerReference) extractFromImageEnv(env *map[string]string) common
inspect, _, err := cr.cli.ImageInspectWithRaw(ctx, cr.input.Image) inspect, _, err := cr.cli.ImageInspectWithRaw(ctx, cr.input.Image)
if err != nil { if err != nil {
logger.Error(err) logger.Error(err)
return fmt.Errorf("inspect image: %w", err)
}
if inspect.Config == nil {
return nil
} }
imageEnv, err := godotenv.Unmarshal(strings.Join(inspect.Config.Env, "\n")) imageEnv, err := godotenv.Unmarshal(strings.Join(inspect.Config.Env, "\n"))
if err != nil { if err != nil {
logger.Error(err) logger.Error(err)
return fmt.Errorf("unmarshal image env: %w", err)
} }
for k, v := range imageEnv { for k, v := range imageEnv {