Skip to content

Commit bf1fcda

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
Create Azure adapter: OperationalInsightsWorkspace (#4540)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Creates a new Azure adapter for `OperationalInsightsWorkspace` (Log Analytics Workspace) resources. ## Changes ### New Files - `sources/azure/clients/operational-insights-workspace-client.go` - Client interface wrapping Azure SDK - `sources/azure/shared/mocks/mock_operational_insights_workspace_client.go` - Generated mock client - `sources/azure/manual/operational-insights-workspace.go` - Adapter implementation using `ListableWrapper` - `sources/azure/manual/operational-insights-workspace_test.go` - Unit tests - `sources/azure/integration-tests/operational-insights-workspace_test.go` - Integration tests ### Modified Files - `sources/azure/shared/models.go` - Added `Insights` API, `Cluster` and `PrivateLinkScopeScopedResource` resource constants - `sources/azure/shared/item-types.go` - Added `OperationalInsightsWorkspace`, `OperationalInsightsCluster`, and `InsightsPrivateLinkScopeScopedResource` item types - `sources/azure/manual/adapters.go` - Registered the new adapter - `go.mod` / `go.sum` - Added `armoperationalinsights` SDK dependency ## Adapter Details - **Type**: `ListableWrapper` (top-level resource scoped to resource groups) - **Category**: `ADAPTER_CATEGORY_OBSERVABILITY` - **Health Mapping**: Maps `ProvisioningState` to SDP health status - **Linked Items**: - `OperationalInsightsCluster` - via `Properties.Features.ClusterResourceID` - `InsightsPrivateLinkScopeScopedResource` - via `Properties.PrivateLinkScopedResources[].ResourceID` (using composite lookup key for child resource) - **IAM Permission**: `Microsoft.OperationalInsights/workspaces/read` - **Predefined Role**: `Log Analytics Reader` ## Testing - Unit tests cover Get, List, ListStream, error handling, health state mapping, and cross-resource-group links - Integration test creates actual Azure resources and verifies adapter behavior (skips gracefully if service principal lacks permissions) - All tests pass locally <!-- CURSOR_AGENT_PR_BODY_END --> Linear Issue: [ENG-3550](https://linear.app/overmind/issue/ENG-3550/create-azure-adapter-operationalinsightsworkspace) <div><a href="https://cursor.com/agents/bc-061cf487-00ae-466f-932e-7aef5591cc06"><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-061cf487-00ae-466f-932e-7aef5591cc06"><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: 70d59ce34a023205779927eb148648f51f837eba
1 parent 1833c86 commit bf1fcda

11 files changed

Lines changed: 1285 additions & 14 deletions

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ require (
5555
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault/v2 v2.0.2
5656
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.3.0
5757
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 v9.0.0
58+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights v1.2.0
5859
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5 v5.0.0
5960
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0
6061
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2 v2.1.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 h1:lpOxw
128128
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0/go.mod h1:fSvRkb8d26z9dbL40Uf/OO6Vo9iExtZK3D0ulRV+8M0=
129129
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan v1.2.0 h1:8xYBtaMs3Msy1bFYTVrVFBh05JUGNMMP/v3z3x5hoIw=
130130
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan v1.2.0/go.mod h1:bXxc3uCnIUCh68pl4njcH45qUgRuR0kZfR6v06k18/A=
131+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do=
132+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI=
131133
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.1 h1:1kpY4qe+BGAH2ykv4baVSqyx+AY5VjXeJ15SldlU6hs=
132134
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.1/go.mod h1:nT6cWpWdUt+g81yuKmjeYPUtI73Ak3yQIT4PVVsCEEQ=
133135
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault/v2 v2.0.2 h1:O2iuZYGa1nIMDk2uAFR0F7hDALVXMvz8Zwarz6itQ3E=
@@ -138,6 +140,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.3.0 h1:L7G3d
138140
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.3.0/go.mod h1:Ms6gYEy0+A2knfKrwdatsggTXYA2+ICKug8w7STorFw=
139141
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 v9.0.0 h1:CbHDMVJhcJSmXenq+UDWyIjumzVkZIb5pVUGzsCok5M=
140142
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9 v9.0.0/go.mod h1:raqbEXrok4aycS74XoU6p9Hne1dliAFpHLizlp+qJoM=
143+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights v1.2.0 h1:4FlNvfcPu7tTvOgOzXxIbZLvwvmZq1OdhQUdIa9g2N4=
144+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights v1.2.0/go.mod h1:A4nzEXwVd5pAyneR6KOvUAo72svUc5rmCzRHhAbP6lA=
141145
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5 v5.0.0 h1:S7K+MLPEYe+g9AX9dLKldBpYV03bPl7zeDaWhiNDqqs=
142146
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v5 v5.0.0/go.mod h1:EHRrmrnS2Q8fB3+DE30TTk04JLqjui5ZJEF7eMVQ2/M=
143147
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0 h1:yzrctSl9GMIQ5lHu7jc8olOsGjWDCsBpJhWqfGa/YIM=
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package clients
2+
3+
import (
4+
"context"
5+
6+
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights"
7+
)
8+
9+
//go:generate mockgen -destination=../shared/mocks/mock_operational_insights_workspace_client.go -package=mocks -source=operational-insights-workspace-client.go
10+
11+
// OperationalInsightsWorkspacePager is a type alias for the generic Pager interface with workspace response type.
12+
// This uses the generic Pager[T] interface to avoid code duplication.
13+
type OperationalInsightsWorkspacePager = Pager[armoperationalinsights.WorkspacesClientListByResourceGroupResponse]
14+
15+
// OperationalInsightsWorkspaceClient is an interface for interacting with Azure Log Analytics Workspaces
16+
type OperationalInsightsWorkspaceClient interface {
17+
NewListByResourceGroupPager(resourceGroupName string, options *armoperationalinsights.WorkspacesClientListByResourceGroupOptions) OperationalInsightsWorkspacePager
18+
Get(ctx context.Context, resourceGroupName string, workspaceName string, options *armoperationalinsights.WorkspacesClientGetOptions) (armoperationalinsights.WorkspacesClientGetResponse, error)
19+
}
20+
21+
type operationalInsightsWorkspaceClient struct {
22+
client *armoperationalinsights.WorkspacesClient
23+
}
24+
25+
func (o *operationalInsightsWorkspaceClient) NewListByResourceGroupPager(resourceGroupName string, options *armoperationalinsights.WorkspacesClientListByResourceGroupOptions) OperationalInsightsWorkspacePager {
26+
return o.client.NewListByResourceGroupPager(resourceGroupName, options)
27+
}
28+
29+
func (o *operationalInsightsWorkspaceClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, options *armoperationalinsights.WorkspacesClientGetOptions) (armoperationalinsights.WorkspacesClientGetResponse, error) {
30+
return o.client.Get(ctx, resourceGroupName, workspaceName, options)
31+
}
32+
33+
// NewOperationalInsightsWorkspaceClient creates a new OperationalInsightsWorkspaceClient from the Azure SDK client
34+
func NewOperationalInsightsWorkspaceClient(client *armoperationalinsights.WorkspacesClient) OperationalInsightsWorkspaceClient {
35+
return &operationalInsightsWorkspaceClient{client: client}
36+
}

0 commit comments

Comments
 (0)