Skip to content
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
16 changes: 9 additions & 7 deletions internal/parser/terraform/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ func expandModules(
for k, v := range childInputs {
childVars[k] = v
}

// Fill in optional() defaults from the variable type
// constraints. This bridges the gap between Terraform's
// runtime type-system and c3x's static parsing: attributes
// like `os_disk = optional(object({disk_size_gb = optional(number, 64)}), {})`
// get their defaults applied to the caller-supplied values.
applyOptionalDefaults(childSources, childVars)
// Normalise the child's inputs (and defaults) to the child's
// declared `type` constraints, filling optional() attribute
// defaults. This bridges Terraform's runtime type-system and
// c3x's static parsing: it applies explicit `optional(t, def)`
// defaults and materialises bare `optional(t)` as null, so a
// caller value like `instances = { one = {} }` exposes
// `each.value.instance_class` instead of erroring inside the
// module's expressions.
applyVariableTypes(childVars, collectVariableTypes(childSources))

childData := collectDataBlocks(childSources)
childLocals := resolveLocals(childSources, childVars, childData)
Expand Down
245 changes: 0 additions & 245 deletions internal/parser/terraform/optional_defaults.go

This file was deleted.

122 changes: 0 additions & 122 deletions internal/parser/terraform/optional_defaults_test.go

This file was deleted.

Loading
Loading