cloudSQLDialOptions selects the Cloud SQL IP type (private or PSC) for Google Cloud SQL IAM connections. Public IP is the cloudsqlconn default, so no option is needed for PUBLIC or unspecified.
(ds *storepb.DataSource)
| 54 | // Cloud SQL IAM connections. Public IP is the cloudsqlconn default, so no option |
| 55 | // is needed for PUBLIC or unspecified. |
| 56 | func cloudSQLDialOptions(ds *storepb.DataSource) []cloudsqlconn.Option { |
| 57 | switch ds.GetCloudSqlIpType() { |
| 58 | case storepb.DataSource_PRIVATE: |
| 59 | return []cloudsqlconn.Option{cloudsqlconn.WithDefaultDialOptions(cloudsqlconn.WithPrivateIP())} |
| 60 | case storepb.DataSource_PSC: |
| 61 | return []cloudsqlconn.Option{cloudsqlconn.WithDefaultDialOptions(cloudsqlconn.WithPSC())} |
| 62 | default: |
| 63 | return nil |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // GCPCredentialOption returns the appropriate option.ClientOption for the given |
| 68 | // GCP credential JSON, supporting both service account keys and external account |