Skip to content

Commit 2724804

Browse files
committed
chore: Expose the refresh strategy UseIAMAuthN() value to the dialer.
Part of #842
1 parent b6823f8 commit 2724804

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

dialer.go

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type connectionInfoCache interface {
107107
ConnectionInfo(context.Context) (cloudsql.ConnectionInfo, error)
108108
UpdateRefresh(*bool)
109109
ForceRefresh()
110+
UseIAMAuthN() bool
110111
io.Closer
111112
}
112113

internal/cloudsql/instance.go

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ func (i *RefreshAheadCache) Close() error {
165165
return nil
166166
}
167167

168+
// UseIAMAuthN returns true if this dialer is using IAM AuthN
169+
func (i *RefreshAheadCache) UseIAMAuthN() bool {
170+
return i.useIAMAuthNDial
171+
}
172+
168173
// ConnectionInfo contains all necessary information to connect securely to the
169174
// server-side Proxy running on a Cloud SQL instance.
170175
type ConnectionInfo struct {

internal/cloudsql/lazy.go

+5
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,8 @@ func (c *LazyRefreshCache) ForceRefresh() {
141141
func (c *LazyRefreshCache) Close() error {
142142
return nil
143143
}
144+
145+
// UseIAMAuthN returns true if this dialer is using IAM AuthN
146+
func (c *LazyRefreshCache) UseIAMAuthN() bool {
147+
return c.useIAMAuthNDial
148+
}

internal/mock/cloudsql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func StartServerProxy(t *testing.T, i FakeCSQLInstance) func() {
309309
if err != nil {
310310
t.Fatalf("failed to create X.509 Key Pair: %v", err)
311311
}
312-
ln, err := tls.Listen("tcp", ":3307", &tls.Config{
312+
ln, err := tls.Listen("tcp", fmt.Sprintf(":3307"), &tls.Config{
313313
Certificates: []tls.Certificate{serverCert},
314314
})
315315
if err != nil {

0 commit comments

Comments
 (0)