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

This commit is contained in:
mmetc 2023-01-11 09:50:12 +01:00 committed by GitHub
parent ca12432a2a
commit c4deaf0994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 13 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)
}
},
}

View file

@ -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