Skip to content

Commit

Permalink
Add Cosign env pass-through
Browse files Browse the repository at this point in the history
Signed-off-by: Ziwen Ning <[email protected]>
  • Loading branch information
ningziwen committed Mar 15, 2023
1 parent 370a9ef commit 5b84d3f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/finch/nerdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ func (nc *nerdctlCommand) run(cmdName string, args []string) error {
nerdctlArgs = append(nerdctlArgs, arg)
}
}
limaArgs := []string{"shell", limaInstanceName, "sudo"}

// The env variables are not passed through by `limactl shell` by default so we need to assign the variables explicitly.
// https://github.com/lima-vm/lima/issues/1419
ncEnvs := []string{"COSIGN_PASSWORD"}
var ncEnvArgs []string
for _, e := range ncEnvs {
v, b := nc.systemDeps.LookupEnv(e)
if b {
ncEnvArgs = append(ncEnvArgs, fmt.Sprintf("%s=%s", e, v))
}
}
limaArgs = append(limaArgs, ncEnvArgs...)
limaArgs = append(limaArgs, nerdctlCmdName, cmdName)

// to handle environment variables properly, we add all entries found via
// env-file includes to the map first and then all command line environment
// flags, making sure that command line overrides environment file options,
Expand All @@ -146,7 +161,7 @@ func (nc *nerdctlCommand) run(cmdName string, args []string) error {
}
finalArgs = append(finalArgs, nerdctlArgs...)

limaArgs := append([]string{"shell", limaInstanceName, "sudo", nerdctlCmdName, cmdName}, finalArgs...)
limaArgs = append(limaArgs, finalArgs...)

if nc.shouldReplaceForHelp(cmdName, args) {
return nc.creator.RunWithReplacingStdout([]command.Replacement{{Source: "nerdctl", Target: "finch"}}, limaArgs...)
Expand Down

0 comments on commit 5b84d3f

Please sign in to comment.