diff --git a/dialer.go b/dialer.go index 8a62a997..3d9216a5 100644 --- a/dialer.go +++ b/dialer.go @@ -107,6 +107,7 @@ type connectionInfoCache interface { ConnectionInfo(context.Context) (cloudsql.ConnectionInfo, error) UpdateRefresh(*bool) ForceRefresh() + UseIAMAuthN() bool io.Closer } diff --git a/internal/cloudsql/instance.go b/internal/cloudsql/instance.go index f8e44b3b..caabc43a 100644 --- a/internal/cloudsql/instance.go +++ b/internal/cloudsql/instance.go @@ -165,6 +165,11 @@ func (i *RefreshAheadCache) Close() error { return nil } +// UseIAMAuthN returns true if this dialer is using IAM AuthN +func (i *RefreshAheadCache) UseIAMAuthN() bool { + return i.useIAMAuthNDial +} + // ConnectionInfo contains all necessary information to connect securely to the // server-side Proxy running on a Cloud SQL instance. type ConnectionInfo struct { diff --git a/internal/cloudsql/lazy.go b/internal/cloudsql/lazy.go index 5b65b3b9..ef490c27 100644 --- a/internal/cloudsql/lazy.go +++ b/internal/cloudsql/lazy.go @@ -141,3 +141,8 @@ func (c *LazyRefreshCache) ForceRefresh() { func (c *LazyRefreshCache) Close() error { return nil } + +// UseIAMAuthN returns true if this dialer is using IAM AuthN +func (c *LazyRefreshCache) UseIAMAuthN() bool { + return c.useIAMAuthNDial +} diff --git a/internal/mock/cloudsql.go b/internal/mock/cloudsql.go index 27fc80a3..dc341240 100644 --- a/internal/mock/cloudsql.go +++ b/internal/mock/cloudsql.go @@ -325,7 +325,7 @@ func StartServerProxy(t *testing.T, i FakeCSQLInstance) func() { if err != nil { t.Fatalf("failed to create X.509 Key Pair: %v", err) } - ln, err := tls.Listen("tcp", ":3307", &tls.Config{ + ln, err := tls.Listen("tcp", fmt.Sprintf(":3307"), &tls.Config{ Certificates: []tls.Certificate{serverCert}, }) if err != nil {