INNER CODE UNIT · Go
renderInlineConfig
bank-vaults/bank-vaults · cmd/template/main.go:45
func renderInlineConfig(t *templater.Templater, vaultConfig, filename string, mode os.FileMode) error {
buffer, err := t.EnvTemplate(vaultConfig)
if err != nil {
return fmt.Errorf("executing template: %w", err)
}
if err := os.WriteFile(filename, buffer.Bytes(), mode); err != nil {
return fmt.Errorf("writing template file: %w", err)
}
return nil
}
// renderTemplates reads each source:destination pair, runs it through the templater, and
// writes the rendered output to destination with the given file mode.
func renderTemplates(t *templater.Templater, templates []string, mode os.FileMode) error {
for _, pair := range templates {
parts := strings.Split(pair, ":")