func dump()

in internal/tfengine/tfengine.go [122:155]


func dump(conf *Config, pwd, cacheDir, outputPath string, wantedTemplates map[string]bool) error {
	for _, ti := range conf.Templates {
		// If a templates filter was provided, check against it.
		if len(wantedTemplates) > 0 {
			if _, ok := wantedTemplates[ti.Name]; !ok {
				continue
			}

			// Mark it so we can report on wrong template values at the end.
			// Don't delete, to avoid modifying the underlying data structure.
			wantedTemplates[ti.Name] = false
		}

		if err := dumpTemplate(conf, pwd, cacheDir, outputPath, ti); err != nil {
			return fmt.Errorf("template %q: %v", ti.Name, err)
		}
	}

	// Report on any templates that were supposed to be generated but weren't.
	// This most likely indicates a misspelling.
	var missingTemplates []string
	for t, missed := range wantedTemplates {
		if missed {
			missingTemplates = append(missingTemplates, t)
		}
		// Unmark.
		wantedTemplates[t] = true
	}
	if len(missingTemplates) > 0 {
		return fmt.Errorf("templates not found in engine config: %v", strings.Join(missingTemplates, ","))
	}

	return nil
}