Skip to content

Commit 48144d8

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
Create Azure adapter: ElasticSanVolume (#4535)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary This PR adds a new Azure adapter for Elastic SAN Volumes (`ElasticSanVolume`), following the azure-adapter-creation skill workflow. ## Changes ### Client Interface - `sources/azure/clients/elastic-san-volume-client.go`: Client interface wrapping Azure SDK's `VolumesClient` - `sources/azure/shared/mocks/mock_elastic_san_volume_client.go`: Generated mock for testing ### Adapter Implementation - `sources/azure/manual/elastic-san-volume.go`: SearchableWrapper implementation for ElasticSanVolume - `Get`: Retrieves a single volume by elasticSanName, volumeGroupName, volumeName - `Search`: Lists all volumes under a volume group - `SearchStream`: Streaming variant of Search - Linked item queries to parent ElasticSan, VolumeGroup, source snapshot/volume, ManagedBy VM, and DNS hostname ### Registration - `sources/azure/manual/adapters.go`: Added client creation and adapter registration ### Tests - `sources/azure/manual/elastic-san-volume_test.go`: Unit tests with mocks - `sources/azure/integration-tests/elastic-san-volume_test.go`: Integration tests against real Azure APIs ## Linked Item Queries The adapter creates linked item queries for: - **Parent ElasticSan** (GET) - **Parent ElasticSanVolumeGroup** (GET with composite key) - **Source ElasticSanVolumeSnapshot** (GET when created from snapshot) - **Source ElasticSanVolume** (GET when cloned from volume) - **ManagedBy ComputeVirtualMachine** (GET when managed by VM) - **StorageTarget DNS hostname** (SEARCH via NetworkDNS) ## Self-Review Checklist - [x] **IAMPermissions**: Present, references `Microsoft.ElasticSan/elasticSans/volumegroups/volumes/read` - [x] **PredefinedRole**: Present, uses `Reader` - [x] **LinkedItemQueries**: 6 link types verified (ElasticSan, VolumeGroup, VolumeSnapshot, Volume, VM, DNS). DNS link for StorageTarget hostname included. - [x] **PotentialLinks**: 6 types listed (ElasticSan, ElasticSanVolumeGroup, ElasticSanVolumeSnapshot, ElasticSanVolume, ComputeVirtualMachine, NetworkDNS), matches LinkedItemQueries - [x] **Unit tests**: All passing (Get, GetWithLinks, GetWithInsufficientQueryParts, GetWithEmpty*, ErrorHandling, Search, SearchWithEmpty*, SearchStream, StaticTests) - [x] **Integration test**: All sub-tests passing (Setup, Run/GetVolume, Run/SearchVolumes, Run/VerifyLinkedItems, Run/VerifyItemAttributes, Teardown) against live Azure APIs All checklist items passed. Ready for review. ## Related - Linear Issue: ENG-3546 - Parent Adapter: `elastic-san-volume-group.go` (already has SEARCH link to ElasticSanVolume) <!-- CURSOR_AGENT_PR_BODY_END --> Linear Issue: [ENG-3546](https://linear.app/overmind/issue/ENG-3546/create-azure-adapter-elasticsanvolume) <div><a href="https://cursor.com/agents/bc-2a755c21-1fe0-4be9-b498-c4f3f7520652"><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-2a755c21-1fe0-4be9-b498-c4f3f7520652"><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: 2708a089bc7b13fbe57e03128564d18e60201374
1 parent 393d565 commit 48144d8

7 files changed

Lines changed: 1364 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/elasticsan/armelasticsan"
7+
)
8+
9+
//go:generate mockgen -destination=../shared/mocks/mock_elastic_san_volume_client.go -package=mocks -source=elastic-san-volume-client.go
10+
11+
// ElasticSanVolumePager is a type alias for the generic Pager interface with volume list response type.
12+
type ElasticSanVolumePager = Pager[armelasticsan.VolumesClientListByVolumeGroupResponse]
13+
14+
// ElasticSanVolumeClient is an interface for interacting with Azure Elastic SAN volumes.
15+
type ElasticSanVolumeClient interface {
16+
Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *armelasticsan.VolumesClientGetOptions) (armelasticsan.VolumesClientGetResponse, error)
17+
NewListByVolumeGroupPager(resourceGroupName string, elasticSanName string, volumeGroupName string, options *armelasticsan.VolumesClientListByVolumeGroupOptions) ElasticSanVolumePager
18+
}
19+
20+
type elasticSanVolumeClient struct {
21+
client *armelasticsan.VolumesClient
22+
}
23+
24+
func (c *elasticSanVolumeClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *armelasticsan.VolumesClientGetOptions) (armelasticsan.VolumesClientGetResponse, error) {
25+
return c.client.Get(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options)
26+
}
27+
28+
func (c *elasticSanVolumeClient) NewListByVolumeGroupPager(resourceGroupName string, elasticSanName string, volumeGroupName string, options *armelasticsan.VolumesClientListByVolumeGroupOptions) ElasticSanVolumePager {
29+
return c.client.NewListByVolumeGroupPager(resourceGroupName, elasticSanName, volumeGroupName, options)
30+
}
31+
32+
// NewElasticSanVolumeClient creates a new ElasticSanVolumeClient from the Azure SDK client.
33+
func NewElasticSanVolumeClient(client *armelasticsan.VolumesClient) ElasticSanVolumeClient {
34+
return &elasticSanVolumeClient{client: client}
35+
}

0 commit comments

Comments
 (0)