Skip to content

Commit

Permalink
Skip inferring module inputs from default values
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Nov 1, 2023
1 parent 8c97616 commit 492821f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
3 changes: 1 addition & 2 deletions internal/schema/0.12/variable_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func variableBlockSchema(v *version.Version) *schema.BlockSchema {
ScopeId: refscope.VariableScope,
AsReference: true,
AsTypeOf: &schema.BlockAsTypeOf{
AttributeExpr: "type",
AttributeValue: "default",
AttributeExpr: "type",
},
},
SemanticTokenModifiers: lang.SemanticTokenModifiers{tokmod.Variable},
Expand Down
3 changes: 1 addition & 2 deletions internal/schema/0.14/variable_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func variableBlockSchema() *schema.BlockSchema {
ScopeId: refscope.VariableScope,
AsReference: true,
AsTypeOf: &schema.BlockAsTypeOf{
AttributeExpr: "type",
AttributeValue: "default",
AttributeExpr: "type",
},
},
SemanticTokenModifiers: lang.SemanticTokenModifiers{tokmod.Variable},
Expand Down
2 changes: 1 addition & 1 deletion schema/module_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func schemaForDependentModuleBlock(module module.InstalledModuleCall, modMeta *m

for name, modVar := range modMeta.Variables {
aSchema := moduleVarToAttribute(modVar)
varType := typeOfModuleVar(modVar)
varType := modVar.Type
aSchema.Constraint = convertAttributeTypeToConstraint(varType)
aSchema.OriginForTarget = &schema.PathTarget{
Address: schema.Address{
Expand Down
13 changes: 1 addition & 12 deletions schema/variable_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func SchemaForVariables(vars map[string]module.Variable, modPath string) (*schem

for name, modVar := range vars {
aSchema := moduleVarToAttribute(modVar)
varType := typeOfModuleVar(modVar)
varType := modVar.Type
aSchema.Constraint = schema.LiteralType{Type: varType}
aSchema.OriginForTarget = &schema.PathTarget{
Address: schema.Address{
Expand Down Expand Up @@ -60,14 +60,3 @@ func moduleVarToAttribute(modVar module.Variable) *schema.AttributeSchema {

return aSchema
}

func typeOfModuleVar(modVar module.Variable) cty.Type {
if (modVar.Type == cty.DynamicPseudoType || modVar.Type == cty.NilType) &&
modVar.DefaultValue != cty.NilVal {
// infer type from default value if one is not specified
// or when it's "any"
return modVar.DefaultValue.Type()
}

return modVar.Type
}

0 comments on commit 492821f

Please sign in to comment.