feat: parse env for config

This commit is contained in:
kolaente 2021-12-05 11:50:17 +01:00
parent fa3081b861
commit e1ec1a2af0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"log"
"os"
"strconv"
"strings"
"time"
)
@ -44,6 +45,25 @@ func init() {
config.Folder = folder
}
var err error
interval, has := os.LookupEnv(envInterval)
if has {
config.Interval, err = time.ParseDuration(interval)
if err != nil {
log.Fatalf("Invalid interval: %s\n", err)
}
}
max, has := os.LookupEnv(envMax)
if has {
config.MaxBackups, err = strconv.ParseInt(max, 10, 64)
if err != nil {
log.Fatalf("Invalid max: %s\n", err)
}
}
updateFullBackupPath()
}