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

fix- panic when terraform list variable doesn't have a type #654

Merged
merged 1 commit into from
Apr 13, 2021
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
6 changes: 5 additions & 1 deletion pkg/iac-providers/terraform/commons/cty-converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func ctyToSlice(ctyVal cty.Value) (interface{}, error) {
var val []interface{}
var allErrs error

if ctyVal.Type().IsListType() {
if ctyVal.Type().IsListType() || ctyVal.Type().IsTupleType() || ctyVal.Type().IsSetType() {
for _, v := range ctyVal.AsValueSlice() {
for _, converter := range ctyNativeConverterFuncs {
resolved, err := converter(v)
Expand All @@ -88,6 +88,10 @@ func ctyToSlice(ctyVal cty.Value) (interface{}, error) {
// native golang value and create a new map[string]interface{}
func ctyToMap(ctyVal cty.Value) (interface{}, error) {

if !(ctyVal.Type().IsMapType() || ctyVal.Type().IsObjectType()) {
return nil, fmt.Errorf("not map type")
}

var (
ctyValMap = ctyVal.AsValueMap() // map[string]cty.Value
val = make(map[string]interface{})
Expand Down
Loading