Skip to content
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

Pass allow_downloads config through to parser - fixes #158 #161

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion gotfparse/cmd/tfparse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ func Parse(a *C.char, stopHCL C.int, debug C.int, allowDownloads C.int, num_vars
if debug != 0 {
options = append(options, converter.WithDebug())
}

if allowDownloads != 0 {
options = append(options, converter.WithAllowDownloads())
options = append(options, converter.WithAllowDownloads(true))
} else {
options = append(options, converter.WithAllowDownloads(false))
}

var varFiles []string
Expand Down
4 changes: 2 additions & 2 deletions gotfparse/pkg/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ func (t *terraformConverter) SetStopOnHCLError() {
}

// SetAllowDownloads is a TerraformConverter option that enables downloading modules.
func (t *terraformConverter) SetAllowDownloads() {
t.parserOptions = append(t.parserOptions, parser.OptionWithDownloads(true))
func (t *terraformConverter) SetAllowDownloads(allowed bool) {
t.parserOptions = append(t.parserOptions, parser.OptionWithDownloads(allowed))
}

// SetTFVarsPaths is a TerraformConverter option that sets a variables file for HCL interpolation.
Expand Down
6 changes: 3 additions & 3 deletions gotfparse/pkg/converter/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package converter
type TerraformConverterOptions interface {
SetDebug()
SetStopOnHCLError()
SetAllowDownloads()
SetAllowDownloads(allowed bool)
SetTFVarsPaths(paths ...string)
}

Expand All @@ -26,9 +26,9 @@ func WithStopOnHCLError() TerraformConverterOption {
}

// WithStopOnHCLError sets the underlying defsec parser to error and stop on HCL parsing errors.
func WithAllowDownloads() TerraformConverterOption {
func WithAllowDownloads(allowed bool) TerraformConverterOption {
return func(t TerraformConverterOptions) {
t.SetAllowDownloads()
t.SetAllowDownloads(allowed)
}
}

Expand Down