Skip to content

Commit ff79a8a

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
Create Azure adapter: NetworkIPGroup (#4536)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Adds a new Azure adapter for IP Groups, which are collections of IP addresses and CIDR ranges used for firewall rules. ## Changes - **Client Interface**: Added `IPGroupsClient` interface in `sources/azure/clients/ip-groups-client.go` - **Adapter**: Implemented `NetworkIPGroup` ListableWrapper in `sources/azure/manual/network-ip-group.go` - **Item Types**: Added `NetworkIPGroup`, `NetworkFirewall`, and `NetworkFirewallPolicy` item types - **Registration**: Registered the adapter in `adapters.go` - **Unit Tests**: Comprehensive unit tests covering Get, List, ListStream, error handling, health status mapping, and interface compliance - **Integration Test**: Integration test verified against live Azure APIs ## Linked Items The adapter creates linked item queries for: - **IP addresses**: Each IP address/CIDR in the IP Group links to `stdlib.NetworkIP` (GET, global scope) - **Firewalls**: References to Azure Firewalls using this IP Group (via `NetworkFirewall`) - **Firewall Policies**: References to Firewall Policies using this IP Group (via `NetworkFirewallPolicy`) ## Self-Review Checklist - [x] **IAMPermissions**: Present, references `Microsoft.Network/ipGroups/read` - [x] **PredefinedRole**: Present, uses `Reader` - [x] **LinkedItemQueries**: 3 link types verified (IP addresses, Firewalls, FirewallPolicies) - [x] **PotentialLinks**: 3 types listed (stdlib.NetworkIP, NetworkFirewall, NetworkFirewallPolicy), matches LinkedItemQueries - [x] **Unit tests**: All passing (Get, StaticTests, GetWithEmptyName, NilName handling, List, ListStream, ErrorHandling, InterfaceCompliance, HealthStatus) - [x] **Integration test**: All sub-tests passing (Setup, Run/GetIPGroup, Run/ListIPGroups, Run/VerifyItemAttributes, Run/VerifyLinkedItems, Teardown) against live Azure APIs All checklist items passed. Ready for review. Closes ENG-3553 <!-- CURSOR_AGENT_PR_BODY_END --> Linear Issue: [ENG-3553](https://linear.app/overmind/issue/ENG-3553/create-azure-adapter-networkipgroup) <div><a href="https://cursor.com/agents/bc-f157a60b-3abd-47df-9039-cce55f589931"><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-f157a60b-3abd-47df-9039-cce55f589931"><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: cf27e510842cad09cabf630c052f2e7ec00cf07c
1 parent 48144d8 commit ff79a8a

8 files changed

Lines changed: 1144 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/network/armnetwork/v9"
7+
)
8+
9+
//go:generate mockgen -destination=../shared/mocks/mock_ip_groups_client.go -package=mocks -source=ip-groups-client.go
10+
11+
// IPGroupsPager is a type alias for the generic Pager interface with IP groups response type.
12+
type IPGroupsPager = Pager[armnetwork.IPGroupsClientListByResourceGroupResponse]
13+
14+
// IPGroupsClient is an interface for interacting with Azure IP Groups.
15+
type IPGroupsClient interface {
16+
Get(ctx context.Context, resourceGroupName string, ipGroupsName string, options *armnetwork.IPGroupsClientGetOptions) (armnetwork.IPGroupsClientGetResponse, error)
17+
NewListByResourceGroupPager(resourceGroupName string, options *armnetwork.IPGroupsClientListByResourceGroupOptions) IPGroupsPager
18+
}
19+
20+
type ipGroupsClient struct {
21+
client *armnetwork.IPGroupsClient
22+
}
23+
24+
func (c *ipGroupsClient) Get(ctx context.Context, resourceGroupName string, ipGroupsName string, options *armnetwork.IPGroupsClientGetOptions) (armnetwork.IPGroupsClientGetResponse, error) {
25+
return c.client.Get(ctx, resourceGroupName, ipGroupsName, options)
26+
}
27+
28+
func (c *ipGroupsClient) NewListByResourceGroupPager(resourceGroupName string, options *armnetwork.IPGroupsClientListByResourceGroupOptions) IPGroupsPager {
29+
return c.client.NewListByResourceGroupPager(resourceGroupName, options)
30+
}
31+
32+
// NewIPGroupsClient creates a new IPGroupsClient from the Azure SDK client.
33+
func NewIPGroupsClient(client *armnetwork.IPGroupsClient) IPGroupsClient {
34+
return &ipGroupsClient{client: client}
35+
}

0 commit comments

Comments
 (0)