Skip to content

wip: add ability to disable sops decryption #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions libs/digger_config/terragrunt/atlantis/parse_hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/hashicorp/hcl/v2/gohcl"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/function"
"path/filepath"
)

Expand Down Expand Up @@ -49,6 +51,19 @@ func updateBareIncludeBlock(file *hcl.File, filename string) ([]byte, bool, erro
return hclFile.Bytes(), codeWasUpdated, nil
}

func createNoopFuncImplementation(
trackInclude *config.TrackInclude,
terragruntOptions *options.TerragruntOptions,
) function.Function {
return function.New(&function.Spec{
VarParam: &function.Parameter{Type: cty.String},
Type: function.StaticReturnType(cty.String),
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
return cty.MapVal(map[string]cty.Value{}), nil
},
})
}

// decodeHcl uses the HCL2 parser to decode the parsed HCL into the struct specified by out.
//
// Note that we take a two pass approach to support parsing include blocks without a label. Ideally we can parse include
Expand Down Expand Up @@ -93,6 +108,8 @@ func decodeHcl(
return err
}

// override sops decrypt function to avoid decryption errors when parsing on backend
evalContext.Functions[config.FuncNameSopsDecryptFile] = createNoopFuncImplementation(extensions.TrackInclude, terragruntOptions)
decodeDiagnostics := gohcl.DecodeBody(file.Body, evalContext, out)
if decodeDiagnostics != nil && decodeDiagnostics.HasErrors() {
return decodeDiagnostics
Expand Down
Loading