I’m having some difficulty assembling complex schemas.
For instance, Having a TypeList inside of a TypeMap or even a TypeMap inside of a TypeMap appears to be failing validation
compressionSchema := &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Description: "GZIP and GZIP level of compression with mime type",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Default: true,
Optional: true,
},
"gzip": {
Type: schema.TypeString,
Optional: true,
Default: "txt,js,htm,html,css",
Description: "File suffixes to compress if requested",
},
"level": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The level of compression used for gzip",
},
"mime": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Description: "Mime types to be used with gzip compression",
Default: []string{"text/*"},
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
}
compression = {
enabled = true
gzip = "m3u8,ts"
level = 2
mime = ["text/*", "application/x-mpegUR", "vnd.apple.mpegURL", "video/MP2T"]
}
Causes
Inappropriate value for attribute "compression": element "mime": string
required.
The only way I can seem to get lists to work at all is at the top level of the resource. It is making it impossible to logically group settings.
Another long-form example of a structure I was attempting to implement would have looked like
delivery = {
compression = {
enabled = true
gzip = "m3u8,ts"
level = 2
mime = ["text/*", "application/x-mpegUR", "vnd.apple.mpegURL", "video/MP2T"]
}
static_header {
enabled = true
http = "TEST:inject"
}
static_header {
enabled = true
client_request = "TEST2:secondinject"
}
http_methods = {
enabled = true
passthru = "*"
}
}
Is this kind of structure impossible (maps and lists inside a map), or am I missing something about the Schema’s and Resources? I’ve been through all of the documentation and the providers repos to look at examples, and others seem to do this kind of structure without an issue.