Skip to content

Commit 515f14b

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
feat: add Azure NetworkLoadBalancerProbe adapter (#4402)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Adds a new Azure adapter for Load Balancer Probes (`NetworkLoadBalancerProbe`). Probes are child resources of Load Balancers that define health check configurations for backend pool members. ## Changes - **Client interface** (`sources/azure/clients/load-balancer-probes-client.go`): New `LoadBalancerProbesClient` interface wrapping `armnetwork.LoadBalancerProbesClient` with `Get` and `NewListPager` methods - **Mock** (`sources/azure/shared/mocks/mock_load_balancer_probes_client.go`): Generated mock for unit testing - **Adapter** (`sources/azure/manual/network-load-balancer-probe.go`): `SearchableWrapper` implementation with: - `Get(scope, loadBalancerName, probeName)` - retrieves a specific probe - `Search(scope, loadBalancerName)` - lists all probes under a load balancer - `SearchStream` - streaming variant of Search - Health status mapping from provisioning state - Linked items: parent LoadBalancer (GET), LoadBalancingRules (GET) - **Registration** (`sources/azure/manual/adapters.go`): Registered in both init and placeholder blocks - **Unit tests** (`sources/azure/manual/network-load-balancer-probe_test.go`): Comprehensive tests including Get, Search, StaticTests, error handling, empty name validation, nil name handling - **Integration test** (`sources/azure/integration-tests/network-load-balancer-probe_test.go`): Full Setup/Run/Teardown test against live Azure APIs ## Bidirectional Links The parent `NetworkLoadBalancer` adapter already links to probes via GET (iterating `Properties.Probes`) and includes `NetworkLoadBalancerProbe` in `PotentialLinks()`. The child probe adapter links back to the parent via GET. Both directions are tested. ## Self-Review Checklist - [x] **IAMPermissions**: Present, references `Microsoft.Network/loadBalancers/probes/read` - [x] **PredefinedRole**: Present, uses `Reader` - [x] **LinkedItemQueries**: 2 link types verified (parent LoadBalancer GET, LoadBalancingRules GET). No IP/DNS fields in Probe struct. - [x] **PotentialLinks**: 2 types listed (`NetworkLoadBalancer`, `NetworkLoadBalancerLoadBalancingRule`), matches LinkedItemQueries - [x] **Unit tests**: All passing (Get, Get_WithInsufficientQueryParts, Get_WithEmptyLoadBalancerName, Get_WithEmptyProbeName, Search, Search_WithNilName, Search_InvalidQueryParts, Search_WithEmptyLoadBalancerName, ErrorHandling_Get, ErrorHandling_Search, Get_NoProperties, StaticTests) - [x] **Integration test**: All sub-tests passing (Setup, Run/GetProbe, Run/SearchProbes, Run/VerifyLinkedItems, Run/VerifyItemAttributes, Teardown) against live Azure APIs All checklist items passed. Ready for review. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-863ee979-1cff-4ba2-9947-c616fe0372ee"><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-863ee979-1cff-4ba2-9947-c616fe0372ee"><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: c44110ae2ba31335086570b41a867ca262fdde88
1 parent 79f33f1 commit 515f14b

6 files changed

Lines changed: 1293 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package clients
2+
3+
import (
4+
"context"
5+
6+
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v9"
7+
)
8+
9+
//go:generate mockgen -destination=../shared/mocks/mock_load_balancer_probes_client.go -package=mocks -source=load-balancer-probes-client.go
10+
11+
type LoadBalancerProbesPager = Pager[armnetwork.LoadBalancerProbesClientListResponse]
12+
13+
type LoadBalancerProbesClient interface {
14+
Get(ctx context.Context, resourceGroupName string, loadBalancerName string, probeName string) (armnetwork.LoadBalancerProbesClientGetResponse, error)
15+
NewListPager(resourceGroupName string, loadBalancerName string) LoadBalancerProbesPager
16+
}
17+
18+
type loadBalancerProbesClient struct {
19+
client *armnetwork.LoadBalancerProbesClient
20+
}
21+
22+
func (a *loadBalancerProbesClient) Get(ctx context.Context, resourceGroupName string, loadBalancerName string, probeName string) (armnetwork.LoadBalancerProbesClientGetResponse, error) {
23+
return a.client.Get(ctx, resourceGroupName, loadBalancerName, probeName, nil)
24+
}
25+
26+
func (a *loadBalancerProbesClient) NewListPager(resourceGroupName string, loadBalancerName string) LoadBalancerProbesPager {
27+
return a.client.NewListPager(resourceGroupName, loadBalancerName, nil)
28+
}
29+
30+
func NewLoadBalancerProbesClient(client *armnetwork.LoadBalancerProbesClient) LoadBalancerProbesClient {
31+
return &loadBalancerProbesClient{client: client}
32+
}

0 commit comments

Comments
 (0)