Skip to content

Commit df6c780

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
Create Azure adapter: SQLServerFailoverGroup (#4539)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Creates a new Azure adapter for SQL Server Failover Groups, following the azure-adapter-creation skill workflow. ## Changes ### New Files - `sources/azure/clients/sql-failover-groups-client.go` - Client interface for Azure SQL Failover Groups SDK - `sources/azure/manual/sql-server-failover-group.go` - SearchableWrapper adapter implementation - `sources/azure/manual/sql-server-failover-group_test.go` - Unit tests - `sources/azure/integration-tests/sql-server-failover-group_test.go` - Integration tests (requires SQL admin credentials) - `sources/azure/shared/mocks/mock_sql_failover_groups_client.go` - Generated mock ### Modified Files - `sources/azure/manual/adapters.go` - Registered the adapter ## Implementation Details - **Wrapper type**: SearchableWrapper (client.Get takes resourceGroupName, serverName, failoverGroupName) - **UniqueAttribute**: Composite key via `shared.CompositeLookupKey(serverName, failoverGroupName)` - **SDK package**: `armsql/v2` (already in go.mod) - **Parent adapter**: `sql-server.go` already has SEARCH link to this child type ### Linked Items - Parent SQL Server (GET) - Partner servers (GET with cross-resource-group scope extraction) - Databases in the failover group (GET with composite key) - Read-only endpoint target server (GET) ### Health Mapping - Empty string / normal → HEALTH_OK - CATCH_UP, PENDING, SEEDING → HEALTH_PENDING - SUSPENDED → HEALTH_WARNING - Unknown states → HEALTH_UNKNOWN ## Self-Review Checklist - [x] **IAMPermissions**: Present, references `Microsoft.Sql/servers/failoverGroups/read` - [x] **PredefinedRole**: Present, uses `Reader` - [x] **LinkedItemQueries**: 4 link types verified (parent server, partner servers, databases, target server) - [x] **PotentialLinks**: 2 types listed (SQLServer, SQLDatabase), matches LinkedItemQueries - [x] **Unit tests**: All passing (Get, Search, SearchStream, StaticTests, ErrorHandling, edge cases) - [x] **Integration test**: Present and structurally correct (skips when SQL admin credentials not available) All checklist items passed. Ready for review. ## Testing Unit tests pass: ``` === RUN TestSqlServerFailoverGroup --- PASS: TestSqlServerFailoverGroup (0.03s) --- PASS: TestSqlServerFailoverGroup/Get --- PASS: TestSqlServerFailoverGroup/Get_WithInsufficientQueryParts --- PASS: TestSqlServerFailoverGroup/GetWithEmptyServerName --- PASS: TestSqlServerFailoverGroup/GetWithEmptyFailoverGroupName --- PASS: TestSqlServerFailoverGroup/Search --- PASS: TestSqlServerFailoverGroup/SearchStream --- PASS: TestSqlServerFailoverGroup/SearchWithEmptyServerName --- PASS: TestSqlServerFailoverGroup/Search_InvalidQueryParts --- PASS: TestSqlServerFailoverGroup/Search_WithNilName --- PASS: TestSqlServerFailoverGroup/ErrorHandling_Get --- PASS: TestSqlServerFailoverGroup/ErrorHandling_Search --- PASS: TestSqlServerFailoverGroup/InterfaceCompliance ``` Linting passes: ``` golangci-lint run ./sources/azure/... 0 issues. ``` Resolves ENG-3551 <!-- CURSOR_AGENT_PR_BODY_END --> Linear Issue: [ENG-3551](https://linear.app/overmind/issue/ENG-3551/create-azure-adapter-sqlserverfailovergroup) <div><a href="https://cursor.com/agents/bc-395e64c7-6cd3-437f-ac44-70ac02f0a153"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-395e64c7-6cd3-437f-ac44-70ac02f0a153"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Lionel Wilson <Lionel-Wilson@users.noreply.github.com> GitOrigin-RevId: b1a861686385e61721059943f5ab67671b29a93b
1 parent ff79a8a commit df6c780

6 files changed

Lines changed: 1553 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package clients
2+
3+
import (
4+
"context"
5+
6+
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql/v2"
7+
)
8+
9+
//go:generate mockgen -destination=../shared/mocks/mock_sql_failover_groups_client.go -package=mocks -source=sql-failover-groups-client.go
10+
11+
// SqlFailoverGroupsPager is a type alias for the generic Pager interface with failover groups response type.
12+
type SqlFailoverGroupsPager = Pager[armsql.FailoverGroupsClientListByServerResponse]
13+
14+
// SqlFailoverGroupsClient is an interface for interacting with Azure SQL Server Failover Groups
15+
type SqlFailoverGroupsClient interface {
16+
ListByServer(ctx context.Context, resourceGroupName string, serverName string) SqlFailoverGroupsPager
17+
Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (armsql.FailoverGroupsClientGetResponse, error)
18+
}
19+
20+
type sqlFailoverGroupsClient struct {
21+
client *armsql.FailoverGroupsClient
22+
}
23+
24+
func (a *sqlFailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) SqlFailoverGroupsPager {
25+
return a.client.NewListByServerPager(resourceGroupName, serverName, nil)
26+
}
27+
28+
func (a *sqlFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (armsql.FailoverGroupsClientGetResponse, error) {
29+
return a.client.Get(ctx, resourceGroupName, serverName, failoverGroupName, nil)
30+
}
31+
32+
// NewSqlFailoverGroupsClient creates a new SqlFailoverGroupsClient from the Azure SDK client
33+
func NewSqlFailoverGroupsClient(client *armsql.FailoverGroupsClient) SqlFailoverGroupsClient {
34+
return &sqlFailoverGroupsClient{client: client}
35+
}

0 commit comments

Comments
 (0)