return an error if we can't add a bouncer (#1085)

This commit is contained in:
AlteredCoder 2021-12-14 11:09:57 +01:00 committed by GitHub
parent 01130a5e17
commit ab93cec736
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,16 +110,14 @@ cscli bouncers add MyBouncerName -k %s`, generatePassword(32)),
var apiKey string
var err error
if keyName == "" {
log.Errorf("Please provide a name for the api key")
return
log.Fatalf("Please provide a name for the api key")
}
apiKey = key
if key == "" {
apiKey, err = middlewares.GenerateAPIKey(keyLength)
}
if err != nil {
log.Errorf("unable to generate api key: %s", err)
return
log.Fatalf("unable to generate api key: %s", err)
}
err = dbClient.CreateBouncer(keyName, keyIP, middlewares.HashSHA512(apiKey))
if err != nil {
@ -154,8 +152,7 @@ cscli bouncers add MyBouncerName -k %s`, generatePassword(32)),
for _, bouncerID := range args {
err := dbClient.DeleteBouncer(bouncerID)
if err != nil {
log.Errorf("unable to delete bouncer: %s", err)
return
log.Fatalf("unable to delete bouncer: %s", err)
}
log.Infof("bouncer '%s' deleted successfully", bouncerID)
}