style: make linter happy

This commit is contained in:
Tom Neuber 2024-06-19 22:07:51 +02:00
parent 886c9dffa8
commit 20a47d9abc
Signed by: tom
GPG key ID: F17EFE4272D89FF6
6 changed files with 34 additions and 6 deletions

View file

@ -43,7 +43,7 @@ func Parse() *AppSettings {
)
validateFlags(ctx)
settings := &AppSettings{
return &AppSettings{
Force: cliStruct.Force,
GrafanaURL: cliStruct.GrafanaURL,
GrafanaToken: cliStruct.GrafanaToken,
@ -54,34 +54,42 @@ func Parse() *AppSettings {
GitPass: cliStruct.GitPass,
GPGKey: cliStruct.GPGKey,
}
return settings
}
func validateFlags(cliCtx *kong.Context) {
var flagsValid = true
var messages = []string{}
flagsValid := true
messages := []string{}
if cliStruct.GrafanaURL == "" {
messages = append(messages, "error: invalid grafana URL, must not be blank")
flagsValid = false
}
if cliStruct.GrafanaToken == "" {
messages = append(messages, "error: invalid auth token for grafana, must not be blank")
flagsValid = false
}
if cliStruct.GitRepoURL == "" {
messages = append(messages, "error: invalid repo url for git, must not be blank")
flagsValid = false
}
if cliStruct.GitUser == "" {
messages = append(messages, "error: invalid username for git, must not be blank")
flagsValid = false
}
if cliStruct.GitPass == "" {
messages = append(messages, "error: invalid password for git, must not be blank")
flagsValid = false
}
if !flagsValid {
cliCtx.PrintUsage(false)
if err := cliCtx.PrintUsage(false); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
fmt.Println()
for i := 0; i < len(messages); i++ {
fmt.Println(messages[i])