style: make linter happy
This commit is contained in:
parent
886c9dffa8
commit
20a47d9abc
6 changed files with 34 additions and 6 deletions
18
cfg/cfg.go
18
cfg/cfg.go
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue