Skip to content

Commit

Permalink
Add new helper schema for variable collection
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed May 7, 2024
1 parent 9254447 commit a56f5f7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions schema/variable_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ import (
"github.com/zclconf/go-cty/cty"
)

// SchemaForVariableCollection returns a schema for collecting all
// variables in a variable file. It doesn't check if a variable has
// been defined in the module or not.
func AnySchemaForVariableCollection(modPath string) *schema.BodySchema {
return &schema.BodySchema{
AnyAttribute: &schema.AttributeSchema{
OriginForTarget: &schema.PathTarget{
Address: schema.Address{
schema.StaticStep{Name: "var"},
schema.AttrNameStep{},
},
Path: lang.Path{
Path: modPath,
LanguageID: ModuleLanguageID,
},
Constraints: schema.Constraints{
ScopeId: refscope.VariableScope,
Type: cty.DynamicPseudoType,
},
},
Constraint: schema.AnyExpression{OfType: cty.DynamicPseudoType},
},
}
}

func SchemaForVariables(vars map[string]module.Variable, modPath string) (*schema.BodySchema, error) {
attributes := make(map[string]*schema.AttributeSchema)

Expand Down

0 comments on commit a56f5f7

Please sign in to comment.