Skip to content

Commit

Permalink
Fix relative paths with sops_decrypt_file()
Browse files Browse the repository at this point in the history
sops_decrypt_file() computed the file path relative to the working
directory instead of relative to the Terragrunt configuration. This
generally worked with individual `terragrunt apply` operations but
failed for `terragrunt run-all apply`, as it would look for the file in
the parent directory.

Fixes #1319.
  • Loading branch information
sybereal committed Mar 28, 2024
1 parent 52425e4 commit 8f3d433
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ func sopsDecryptFile(ctx *ParsingContext, params []string) (string, error) {
if err != nil {
return "", errors.WithStackTrace(err)
}
canonicalSourceFile, err := util.CanonicalPath(sourceFile, ctx.TerragruntOptions.WorkingDir)
canonicalSourceFile, err := util.CanonicalPath(sourceFile, filepath.Dir(ctx.TerragruntOptions.TerragruntConfigPath))
if err != nil {
return "", errors.WithStackTrace(err)
}
Expand All @@ -751,7 +751,7 @@ func sopsDecryptFile(ctx *ParsingContext, params []string) (string, error) {
return val, nil
}

rawData, err := decrypt.File(sourceFile, format)
rawData, err := decrypt.File(canonicalSourceFile, format)
if err != nil {
return "", errors.WithStackTrace(err)
}
Expand Down

0 comments on commit 8f3d433

Please sign in to comment.