grafana-backuper/internal/config/config.go
Tom Neuber 535ed5a5c6
All checks were successful
continuous-integration/drone/push Build is passing
feat(internal): add quiet flag
2024-08-19 20:22:41 +02:00

56 lines
1.1 KiB
Go

package config
import (
"errors"
"io"
"github.com/rs/zerolog"
)
type Config struct {
Debug bool
ForceCommits bool
JSONFormat bool
GrafanaURL string
GrafanaToken string
GitBranch string
GitEmail string
GitRepo string
GitUser string
GitPass string
GPGKey string
Quiet bool
Output io.Writer
Logger zerolog.Logger
}
func (c *Config) Validate() []error {
var errs []error
if c.GrafanaURL == "" {
errs = append(errs, errors.New("invalid grafana URL, must not be blank"))
}
if c.GrafanaToken == "" {
errs = append(errs, errors.New("invalid auth token for grafana, must not be blank"))
}
if c.GitRepo == "" {
errs = append(errs, errors.New("invalid repo url for git, must not be blank"))
}
if c.GitUser == "" {
errs = append(errs, errors.New("invalid username for git, must not be blank"))
}
if c.GitPass == "" {
errs = append(errs, errors.New("invalid password for git, must not be blank"))
}
if c.GitBranch == "" {
errs = append(errs, errors.New("invalid branch name for git, must not be blank"))
}
return errs
}