Skip to content

Commit

Permalink
add test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Alvarez <[email protected]>
  • Loading branch information
pendo324 committed Oct 30, 2023
1 parent 2081773 commit dd4cc56
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmd/finch/nerdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ func isDockerCompatEnvSet(systemDeps NerdctlCommandSystemDeps) bool {

// ensureRemoteCredentials is called before any actions that may require remote resources, in order
// to ensure that fresh credentials are available inside the VM.
// For more details on how `aws configure export-credentials` works, checks the docs.
//
// [the docs]: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configure/export-credentials.html
func ensureRemoteCredentials(
fc *config.Finch,
ecc command.Creator,
Expand All @@ -446,12 +449,15 @@ func ensureRemoteCredentials(
).CombinedOutput()
if err != nil {
logger.Debugln("failed to run `aws configure` command")
return
}

var exportCredsOut credentials.Value
err = json.Unmarshal(out, &exportCredsOut)
if err != nil {
logger.Debugln("`aws configure export-credentials` output is unexpected, is command available?")
logger.Debugln("`aws configure export-credentials` output is unexpected, is command available? " +
"This may result in a broken ecr-credential helper experience.")
return
}

*outEnv = append(*outEnv, fmt.Sprintf("AWS_ACCESS_KEY_ID=%s", exportCredsOut.AccessKeyID))
Expand Down
Loading

0 comments on commit dd4cc56

Please sign in to comment.