feat(config): add config package
This commit is contained in:
parent
373c961deb
commit
cc49a79c81
3 changed files with 44 additions and 0 deletions
36
internal/config/config.go
Normal file
36
internal/config/config.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"github.com/peterbourgon/ff"
|
||||
)
|
||||
|
||||
const envVarPrefix = "GB"
|
||||
|
||||
type Config struct {
|
||||
ForceCommits bool
|
||||
GrafanaURL string
|
||||
GrafanaToken string
|
||||
GitBranch string
|
||||
GitRepo string
|
||||
GitUser string
|
||||
GitEmail string
|
||||
GitPass string
|
||||
GPGKey string
|
||||
}
|
||||
|
||||
func (c *Config) RegisterFlags(fs *flag.FlagSet) error {
|
||||
fs.BoolVar(&c.ForceCommits, "force-commits", false, "Force git commits / ignore existence check")
|
||||
fs.StringVar(&c.GrafanaURL, "grafana-url", "", "Grafana URL to access the API")
|
||||
fs.StringVar(&c.GrafanaToken, "grafana-token", "", "Grafana auth token to access the API")
|
||||
fs.StringVar(&c.GitBranch, "git-branch", "main", "Git branch name")
|
||||
fs.StringVar(&c.GitRepo, "git-repo", "", "Complete Git repository URL")
|
||||
fs.StringVar(&c.GitUser, "git-user", "", "Git username")
|
||||
fs.StringVar(&c.GitEmail, "git-email", "", "Git email address")
|
||||
fs.StringVar(&c.GitPass, "git-pass", "", "Git user password")
|
||||
fs.StringVar(&c.GPGKey, "signing-key", "", "Path to the GPG signing key")
|
||||
|
||||
return ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix(envVarPrefix))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue