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