Skip to content

Commit ebfd3f9

Browse files
kirbyquerbyhfwang
authored andcommitted
Add input flag to change API base path
1 parent dcb3922 commit ebfd3f9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmd/cloud_sql_proxy/cloud_sql_proxy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ You may set the GOOGLE_APPLICATION_CREDENTIALS environment variable for the same
8484

8585
// Set to non-default value when gcloud execution failed.
8686
gcloudStatus gcloudStatusCode
87+
88+
// Setting to choose what API to connect to
89+
host = flag.String("host", "https://www.googleapis.com/sql/v1beta4/", "When set, the proxy uses this host as the base API path.")
8790
)
8891

8992
type gcloudStatusCode int
@@ -98,7 +101,6 @@ const (
98101
const (
99102
minimumRefreshCfgThrottle = time.Second
100103

101-
host = "https://www.googleapis.com/sql/v1beta4/"
102104
port = 3307
103105
)
104106

@@ -493,7 +495,7 @@ func main() {
493495
Port: port,
494496
MaxConnections: *maxConnections,
495497
Certs: certs.NewCertSourceOpts(client, certs.RemoteOpts{
496-
APIBasePath: host,
498+
APIBasePath: *host,
497499
IgnoreRegion: !*checkRegion,
498500
UserAgent: userAgentFromVersionString(),
499501
}),

cmd/cloud_sql_proxy/proxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func parseInstanceConfig(dir, instance string, cl *http.Client) (instanceConfig,
238238
}
239239
} else {
240240
sql, err := sqladmin.New(cl)
241+
sql.BasePath = *host
241242
if err != nil {
242243
return instanceConfig{}, err
243244
}

0 commit comments

Comments
 (0)