51 lines
1 KiB
Go
51 lines
1 KiB
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
type Config struct {
|
|
Debug bool
|
|
ForceCommits bool
|
|
GrafanaURL string
|
|
GrafanaToken string
|
|
GitBranch string
|
|
GitEmail string
|
|
GitRepo string
|
|
GitUser string
|
|
GitPass string
|
|
GPGKey string
|
|
|
|
Output io.Writer
|
|
}
|
|
|
|
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
|
|
}
|