Skip to content

Commit

Permalink
chore: Expose the refresh strategy UseIAMAuthN() value to the dialer.
Browse files Browse the repository at this point in the history
Part of #842
  • Loading branch information
hessjcg committed Aug 8, 2024
1 parent 35526b7 commit 2c56b58
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type connectionInfoCache interface {
ConnectionInfo(context.Context) (cloudsql.ConnectionInfo, error)
UpdateRefresh(*bool)
ForceRefresh()
UseIAMAuthN() bool
io.Closer
}

Expand Down
5 changes: 5 additions & 0 deletions internal/cloudsql/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions internal/cloudsql/lazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion internal/mock/cloudsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,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 {
Expand Down

0 comments on commit 2c56b58

Please sign in to comment.