| 248 | } |
| 249 | |
| 250 | func applyTemplateForEachResource(schemas []*SchemaWithPolicy, tpl *pongo2.Template, outputPath string) { |
| 251 | for _, schemaWithPolicy := range schemas { |
| 252 | schema := schemaWithPolicy.Schema |
| 253 | if schema.Metadata["type"] == "metaschema" || schema.Type == "abstract" { |
| 254 | continue |
| 255 | } |
| 256 | output, err := tpl.Execute(pongo2.Context{"schema": schemaWithPolicy}) |
| 257 | if err != nil { |
| 258 | util.ExitFatal(err) |
| 259 | return |
| 260 | } |
| 261 | outputPathForResource := strings.Replace(outputPath, "__resource__", schema.ID, 1) |
| 262 | ioutil.WriteFile(outputPathForResource, []byte(output), 0644) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | func getAllResourceGroupsFromSchemas(schemas []*SchemaWithPolicy) []string { |
| 267 | resourcesSet := make(map[string]bool) |