فهرست منبع

fatal if cannot add bouncer: fix for #1066 (#1067)

mmetc 3 سال پیش
والد
کامیت
ca67be8fca
2فایلهای تغییر یافته به همراه3 افزوده شده و 4 حذف شده
  1. 1 2
      cmd/crowdsec-cli/bouncers.go
  2. 2 2
      scripts/func_tests/tests_post-install_1bouncers.sh

+ 1 - 2
cmd/crowdsec-cli/bouncers.go

@@ -123,8 +123,7 @@ cscli bouncers add MyBouncerName -k %s`, generatePassword(32)),
 			}
 			}
 			err = dbClient.CreateBouncer(keyName, keyIP, middlewares.HashSHA512(apiKey))
 			err = dbClient.CreateBouncer(keyName, keyIP, middlewares.HashSHA512(apiKey))
 			if err != nil {
 			if err != nil {
-				log.Errorf("unable to create bouncer: %s", err)
-				return
+				log.Fatalf("unable to create bouncer: %s", err)
 			}
 			}
 
 
 			if csConfig.Cscli.Output == "human" {
 			if csConfig.Cscli.Output == "human" {

+ 2 - 2
scripts/func_tests/tests_post-install_1bouncers.sh

@@ -12,8 +12,8 @@ ${CSCLI} bouncers list -ojson  | ${JQ} '. | length == 0' || fail "expected 0 bou
 # we can add one bouncer - should we save token for later ?
 # we can add one bouncer - should we save token for later ?
 ${CSCLI} bouncers add ciTestBouncer || fail "failed to add bouncer"
 ${CSCLI} bouncers add ciTestBouncer || fail "failed to add bouncer"
 
 
-# but we can't add it twice - we would get an error
-${CSCLI} bouncers add ciTestBouncer -ojson  2>&1 | ${JQ} '.level == "error"' || fail "didn't receive the expected error"
+# but we can't add it twice - we would get a fatal error
+${CSCLI} bouncers add ciTestBouncer -ojson  2>&1 | ${JQ} '.level == "fatal"' || fail "didn't receive the expected error"
 
 
 # we should have 1 bouncer
 # we should have 1 bouncer
 ${CSCLI} bouncers list -ojson  | ${JQ} '. | length == 1' || fail "expected 1 bouncers"
 ${CSCLI} bouncers list -ojson  | ${JQ} '. | length == 1' || fail "expected 1 bouncers"