hashicorp / hashicorp/terraform-plugin-sdk
Default TypeList / TypeSet
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
Terraform provides a test example for using a default for TypeList:
https://github.com/hashicorp/terraform/blob/master/helper/schema/schema_test.go#L3624
However if I define one in a provider I get:
`
foo: Default is not valid for lists or sets
`
I have also tried using a DefaultFunc:
```go
"foo": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
DefaultFunc: func() (interface{}, error) {
return []interface{}{"bar", "thing"}, nil
},
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
```
Which compiles but doesn't provide a default, how would you go about achieving this?
Thanks!
Contributor guide
Research direction
Start with helper/schema/schema_test.go at the referenced default TypeList example, then trace validation for TypeList/TypeSet and DefaultFunc. Done means the SDK behavior matches the test example or clearly documents the supported way to configure a collection default, with a regression test covering it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, terraform
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100