Files
docker-volume-backup/cmd/backup/print_config.go
Mitchell Michalak 6a83ce4034 Support reading timezone info from env (#748)
* add tzdata package

* updated timezone documentation

* add missing bind-mount from updated docs

* Add timezone deprecation warnings and related logging to backup commands

* fix lint CI job error

* Address PR comments: refactor timezone deprecation warning handling, update docs
2026-04-20 14:10:00 +02:00

55 lines
1.4 KiB
Go

// Copyright 2025 - offen.software <hioffen@posteo.de>
// SPDX-License-Identifier: MPL-2.0
package main
import (
"errors"
"fmt"
"regexp"
"github.com/offen/docker-volume-backup/internal/errwrap"
)
func runPrintConfig() error {
configurations, err := sourceConfiguration(configStrategyConfd)
if err != nil {
return errwrap.Wrap(err, "error sourcing configuration")
}
formatter := regexp.MustCompile(`\s([A-Z])`)
for _, config := range configurations {
if err := func() (err error) {
unset, warnings, err := config.resolve()
if err != nil {
return errwrap.Wrap(err, "error resolving configuration")
}
defer func() {
if derr := unset(); derr != nil {
err = errors.Join(err, errwrap.Wrap(derr, "error unsetting environment variables"))
}
}()
fmt.Printf("source=%s\n", config.source)
for _, warning := range warnings {
fmt.Printf("warning:%s\n", warning)
}
timezoneWarnings, warnErr := config.timezoneDeprecationWarnings()
if warnErr != nil {
return errwrap.Wrap(warnErr, "error collecting timezone deprecation warnings")
}
for _, warning := range timezoneWarnings {
fmt.Printf("warning:%s\n", warning)
}
// insert line breaks before each field name, assuming field names start with uppercase letters
formatted := formatter.ReplaceAllString(fmt.Sprintf("%+v", *config), "\n$1")
fmt.Printf("%s\n", formatted)
return nil
}(); err != nil {
return err
}
}
return nil
}