grafana-backuper/internal/config/config.go

52 lines
1 KiB
Go
Raw Normal View History

2024-07-01 00:54:05 +02:00
package config
import (
"errors"
"io"
2024-07-01 00:54:05 +02:00
)
type Config struct {
Debug bool
2024-07-01 00:54:05 +02:00
ForceCommits bool
GrafanaURL string
GrafanaToken string
GitBranch string
GitEmail string
2024-07-01 00:54:05 +02:00
GitRepo string
GitUser string
GitPass string
GPGKey string
Output io.Writer
2024-07-01 00:54:05 +02:00
}
func (c *Config) Validate() error {
var err error
if c.GrafanaURL == "" {
err = errors.Join(err, errors.New("invalid grafana URL, must not be blank"))
}
if c.GrafanaToken == "" {
err = errors.Join(err, errors.New("invalid auth token for grafana, must not be blank"))
}
if c.GitRepo == "" {
err = errors.Join(err, errors.New("invalid repo url for git, must not be blank"))
}
if c.GitUser == "" {
err = errors.Join(err, errors.New("invalid username for git, must not be blank"))
}
if c.GitPass == "" {
err = errors.Join(err, errors.New("invalid password for git, must not be blank"))
}
if c.GitBranch == "" {
err = errors.Join(err, errors.New("invalid branch name for git, must not be blank"))
}
return err
2024-07-01 00:54:05 +02:00
}