Forráskód Böngészése

cscli: avoid initializing the db configuration twice (#1982)

mmetc 2 éve
szülő
commit
c4deaf0994

+ 0 - 3
cmd/crowdsec-cli/alerts.go

@@ -443,9 +443,6 @@ cscli alerts delete -s crowdsecurity/ssh-bf"`,
 			if err := csConfig.LoadAPIServer(); err != nil || csConfig.DisableAPI {
 				log.Fatal("Local API is disabled, please run this command on the local API machine")
 			}
-			if err := csConfig.LoadDBConfig(); err != nil {
-				log.Fatal(err)
-			}
 			dbClient, err = database.NewClient(csConfig.DbConfig)
 			if err != nil {
 				log.Fatalf("unable to create new database client: %s", err)

+ 0 - 3
cmd/crowdsec-cli/bouncers.go

@@ -206,9 +206,6 @@ Note: This command requires database direct access, so is intended to be run on
 			if err := csConfig.LoadAPIServer(); err != nil || csConfig.DisableAPI {
 				log.Fatal("Local API is disabled, please run this command on the local API machine")
 			}
-			if err := csConfig.LoadDBConfig(); err != nil {
-				log.Fatal(err)
-			}
 			dbClient, err = database.NewClient(csConfig.DbConfig)
 			if err != nil {
 				log.Fatalf("unable to create new database client: %s", err)

+ 0 - 4
cmd/crowdsec-cli/machines.go

@@ -407,10 +407,6 @@ Note: This command requires database direct access, so is intended to be run on
 				}
 				log.Fatal("Local API is disabled, please run this command on the local API machine")
 			}
-			if err := csConfig.LoadDBConfig(); err != nil {
-				log.Errorf("This command requires direct database access (must be run on the local API machine)")
-				log.Fatal(err)
-			}
 		},
 	}
 

+ 0 - 3
cmd/crowdsec-cli/utils.go

@@ -739,9 +739,6 @@ func getDBClient() (*database.Client, error) {
 	if err := csConfig.LoadAPIServer(); err != nil || csConfig.DisableAPI {
 		return nil, err
 	}
-	if err := csConfig.LoadDBConfig(); err != nil {
-		return nil, err
-	}
 	ret, err := database.NewClient(csConfig.DbConfig)
 	if err != nil {
 		return nil, err