1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
--- a/exporter.go
+++ b/exporter.go
@@ -1,18 +1,13 @@
package main
import (
- "context"
"fmt"
- "cloud.google.com/go/cloudsqlconn"
- "cloud.google.com/go/cloudsqlconn/mysql/mysql"
- "cloud.google.com/go/cloudsqlconn/postgres/pgxv4"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/robfig/cron/v3"
- "google.golang.org/api/option"
sqladmin "google.golang.org/api/sqladmin/v1beta4"
)
@@ -54,36 +49,6 @@
cronScheduler: cron.New(),
}
- if cfg.CloudSQLConfig != nil {
- if cfg.CloudSQLConfig.KeyFile == "" {
- return nil, fmt.Errorf("as cloudsql_config is not empty, then cloudsql_config.key_file must be set")
- }
-
- // We currently only support keyfile. Additional authentication options would be via automatic IAM
- // with cloudsqlconn.WithIAMAuthN()
- cloudsqlconnection := cloudsqlconn.WithCredentialsFile(cfg.CloudSQLConfig.KeyFile)
- sqladminService, err := sqladmin.NewService(context.Background(), option.WithAPIKey(cfg.CloudSQLConfig.KeyFile))
- if err != nil {
- return nil, fmt.Errorf("could not create new cloud sqladmin service: %w", err)
- }
- exp.sqladminService = sqladminService
-
- //
- // Register all possible cloudsql drivers
-
- // drop cleanup as we don't really know when to end this
- _, err = pgxv4.RegisterDriver(CLOUDSQL_POSTGRES, cloudsqlconnection)
- if err != nil {
- return nil, fmt.Errorf("could not register cloudsql-postgres driver: %w", err)
- }
-
- // drop cleanup as we don't really know when to end this
- _, err = mysql.RegisterDriver(CLOUDSQL_MYSQL, cloudsqlconnection)
- if err != nil {
- return nil, fmt.Errorf("could not register cloudsql-mysql driver: %w", err)
- }
- }
-
// dispatch all jobs
for _, job := range cfg.Jobs {
if job == nil {
|