Skip to content

Commit 1073709

Browse files
tas50claude
andcommitted
🐛 Fix review feedback: outbundRule typo, nil-safety guards, and lazy-load AKS/IAM/Redis sub-resources
- Fix pre-existing typo: "outbundRule" → "outboundRule" in CreateResource - Add nil checks on Properties before accessing PrivateIPAddress in: - Firewall ipConfigurations() - Firewall managementIpConfiguration() - VirtualNetworkGateway ipConfigurations() - Lazy-load AKS cluster aadProfile and autoUpgradeProfile - Lazy-load IAM roleDefinition permissions - Lazy-load Redis privateEndpointConnections Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62992e6 commit 1073709

File tree

8 files changed

+220
-147
lines changed

8 files changed

+220
-147
lines changed

providers/azure/resources/aks.go

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -199,45 +199,6 @@ func (a *mqlAzureSubscriptionAksService) clusters() ([]any, error) {
199199
}
200200
}
201201

202-
// Create AAD Profile sub-resource
203-
var aadProfileData *llx.RawData = llx.NilData
204-
if entry.Properties.AADProfile != nil {
205-
aadP := entry.Properties.AADProfile
206-
adminGroupObjectIDs := []any{}
207-
for _, gid := range aadP.AdminGroupObjectIDs {
208-
if gid != nil {
209-
adminGroupObjectIDs = append(adminGroupObjectIDs, *gid)
210-
}
211-
}
212-
aadRes, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster.aadProfile",
213-
map[string]*llx.RawData{
214-
"id": llx.StringData(*entry.ID + "/aadProfile"),
215-
"managed": llx.BoolDataPtr(aadP.Managed),
216-
"enableAzureRBAC": llx.BoolDataPtr(aadP.EnableAzureRBAC),
217-
"adminGroupObjectIDs": llx.ArrayData(adminGroupObjectIDs, types.String),
218-
})
219-
if err != nil {
220-
return nil, err
221-
}
222-
aadProfileData = llx.ResourceData(aadRes, "azure.subscription.aksService.cluster.aadProfile")
223-
}
224-
225-
// Create Auto-Upgrade Profile sub-resource
226-
var autoUpgradeProfileData *llx.RawData = llx.NilData
227-
if entry.Properties.AutoUpgradeProfile != nil {
228-
aup := entry.Properties.AutoUpgradeProfile
229-
autoUpgradeRes, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster.autoUpgradeProfile",
230-
map[string]*llx.RawData{
231-
"id": llx.StringData(*entry.ID + "/autoUpgradeProfile"),
232-
"upgradeChannel": llx.StringDataPtr((*string)(aup.UpgradeChannel)),
233-
"nodeOSUpgradeChannel": llx.StringDataPtr((*string)(aup.NodeOSUpgradeChannel)),
234-
})
235-
if err != nil {
236-
return nil, err
237-
}
238-
autoUpgradeProfileData = llx.ResourceData(autoUpgradeRes, "azure.subscription.aksService.cluster.autoUpgradeProfile")
239-
}
240-
241202
mqlAksCluster, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster",
242203
map[string]*llx.RawData{
243204
"id": llx.StringDataPtr(entry.ID),
@@ -274,14 +235,61 @@ func (a *mqlAzureSubscriptionAksService) clusters() ([]any, error) {
274235
"azureKeyVaultKmsNetworkAccess": llx.StringDataPtr(azureKeyVaultKmsNetworkAccess),
275236
"disableLocalAccounts": llx.BoolDataPtr(entry.Properties.DisableLocalAccounts),
276237
"publicNetworkAccess": llx.StringDataPtr((*string)(entry.Properties.PublicNetworkAccess)),
277-
"aadProfile": aadProfileData,
278-
"autoUpgradeProfile": autoUpgradeProfileData,
279238
})
280239
if err != nil {
281240
return nil, err
282241
}
283-
res = append(res, mqlAksCluster)
242+
mqlCluster := mqlAksCluster.(*mqlAzureSubscriptionAksServiceCluster)
243+
mqlCluster.cacheProperties = entry.Properties
244+
res = append(res, mqlCluster)
284245
}
285246
}
286247
return res, nil
287248
}
249+
250+
type mqlAzureSubscriptionAksServiceClusterInternal struct {
251+
cacheProperties *clusters.ManagedClusterProperties
252+
}
253+
254+
func (a *mqlAzureSubscriptionAksServiceCluster) aadProfile() (*mqlAzureSubscriptionAksServiceClusterAadProfile, error) {
255+
if a.cacheProperties == nil || a.cacheProperties.AADProfile == nil {
256+
a.AadProfile.State = plugin.StateIsSet | plugin.StateIsNull
257+
return nil, nil
258+
}
259+
aadP := a.cacheProperties.AADProfile
260+
adminGroupObjectIDs := []any{}
261+
for _, gid := range aadP.AdminGroupObjectIDs {
262+
if gid != nil {
263+
adminGroupObjectIDs = append(adminGroupObjectIDs, *gid)
264+
}
265+
}
266+
aadRes, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster.aadProfile",
267+
map[string]*llx.RawData{
268+
"id": llx.StringData(a.Id.Data + "/aadProfile"),
269+
"managed": llx.BoolDataPtr(aadP.Managed),
270+
"enableAzureRBAC": llx.BoolDataPtr(aadP.EnableAzureRBAC),
271+
"adminGroupObjectIDs": llx.ArrayData(adminGroupObjectIDs, types.String),
272+
})
273+
if err != nil {
274+
return nil, err
275+
}
276+
return aadRes.(*mqlAzureSubscriptionAksServiceClusterAadProfile), nil
277+
}
278+
279+
func (a *mqlAzureSubscriptionAksServiceCluster) autoUpgradeProfile() (*mqlAzureSubscriptionAksServiceClusterAutoUpgradeProfile, error) {
280+
if a.cacheProperties == nil || a.cacheProperties.AutoUpgradeProfile == nil {
281+
a.AutoUpgradeProfile.State = plugin.StateIsSet | plugin.StateIsNull
282+
return nil, nil
283+
}
284+
aup := a.cacheProperties.AutoUpgradeProfile
285+
autoUpgradeRes, err := CreateResource(a.MqlRuntime, "azure.subscription.aksService.cluster.autoUpgradeProfile",
286+
map[string]*llx.RawData{
287+
"id": llx.StringData(a.Id.Data + "/autoUpgradeProfile"),
288+
"upgradeChannel": llx.StringDataPtr((*string)(aup.UpgradeChannel)),
289+
"nodeOSUpgradeChannel": llx.StringDataPtr((*string)(aup.NodeOSUpgradeChannel)),
290+
})
291+
if err != nil {
292+
return nil, err
293+
}
294+
return autoUpgradeRes.(*mqlAzureSubscriptionAksServiceClusterAutoUpgradeProfile), nil
295+
}

providers/azure/resources/azure.lr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,7 @@ private azure.subscription.authorizationService.roleDefinition @defaults ("name
31903190
// Scopes for which the role definition applies
31913191
scopes []string
31923192
// Permissions that are attached to the role definition
3193-
permissions []azure.subscription.authorizationService.roleDefinition.permission
3193+
permissions() []azure.subscription.authorizationService.roleDefinition.permission
31943194
}
31953195

31963196
// Azure role definition permission
@@ -3308,9 +3308,9 @@ azure.subscription.aksService.cluster @defaults("name location kubernetesVersion
33083308
// Whether public network access is enabled for the cluster ("Enabled" or "Disabled")
33093309
publicNetworkAccess string
33103310
// Azure Active Directory configuration for the cluster
3311-
aadProfile azure.subscription.aksService.cluster.aadProfile
3311+
aadProfile() azure.subscription.aksService.cluster.aadProfile
33123312
// Auto-upgrade configuration for the cluster
3313-
autoUpgradeProfile azure.subscription.aksService.cluster.autoUpgradeProfile
3313+
autoUpgradeProfile() azure.subscription.aksService.cluster.autoUpgradeProfile
33143314
}
33153315

33163316
// Azure Kubernetes Service cluster AAD profile
@@ -3504,7 +3504,7 @@ azure.subscription.cacheService.redisInstance @defaults("id hostName") {
35043504
// Managed identity information
35053505
identity dict
35063506
// Private endpoint connections for the Redis cache
3507-
privateEndpointConnections []azure.subscription.cacheService.redisInstance.privateEndpointConnection
3507+
privateEndpointConnections() []azure.subscription.cacheService.redisInstance.privateEndpointConnection
35083508
// Firewall rules for the Redis cache
35093509
firewallRules() []azure.subscription.cacheService.redisInstance.firewallRule
35103510
// Patch schedules for the Redis cache

providers/azure/resources/azure.lr.go

Lines changed: 55 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/azure/resources/azure.permissions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"provider": "azure",
33
"version": "13.1.6",
4-
"generated_at": "2026-03-20T17:04:23-07:00",
4+
"generated_at": "2026-03-20T17:43:31-07:00",
55
"permissions": [
66
"Microsoft.Advisor/recommendations/read",
77
"Microsoft.Authorization/roleAssignments/read",

providers/azure/resources/iam.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ func (a *mqlAzureSubscriptionAuthorizationService) roles() ([]any, error) {
7878
scopes = append(scopes, *s)
7979
}
8080
}
81-
permissions := []any{}
82-
for idx, p := range roleDef.Properties.Permissions {
83-
id := fmt.Sprintf("%s/azure.subscription.authorizationService.roleDefinition.permission/%d", *roleDef.ID, idx)
84-
permission, err := newMqlRolePermission(a.MqlRuntime, id, p)
85-
if err != nil {
86-
return nil, err
87-
}
88-
permissions = append(permissions, permission)
89-
}
9081
mqlRoleDefinition, err := CreateResource(a.MqlRuntime, "azure.subscription.authorizationService.roleDefinition",
9182
map[string]*llx.RawData{
9283
"__id": llx.StringDataPtr(roleDef.ID),
@@ -95,13 +86,31 @@ func (a *mqlAzureSubscriptionAuthorizationService) roles() ([]any, error) {
9586
"description": llx.StringDataPtr(roleDef.Properties.Description),
9687
"type": llx.StringData(roleType),
9788
"scopes": llx.ArrayData(scopes, types.String),
98-
"permissions": llx.ArrayData(permissions, types.ResourceLike),
9989
})
10090
if err != nil {
10191
return nil, err
10292
}
103-
res = append(res, mqlRoleDefinition)
93+
mqlRole := mqlRoleDefinition.(*mqlAzureSubscriptionAuthorizationServiceRoleDefinition)
94+
mqlRole.cachePermissions = roleDef.Properties.Permissions
95+
res = append(res, mqlRole)
96+
}
97+
}
98+
return res, nil
99+
}
100+
101+
type mqlAzureSubscriptionAuthorizationServiceRoleDefinitionInternal struct {
102+
cachePermissions []*authorization.Permission
103+
}
104+
105+
func (a *mqlAzureSubscriptionAuthorizationServiceRoleDefinition) permissions() ([]any, error) {
106+
res := []any{}
107+
for idx, p := range a.cachePermissions {
108+
id := fmt.Sprintf("%s/azure.subscription.authorizationService.roleDefinition.permission/%d", a.Id.Data, idx)
109+
permission, err := newMqlRolePermission(a.MqlRuntime, id, p)
110+
if err != nil {
111+
return nil, err
104112
}
113+
res = append(res, permission)
105114
}
106115
return res, nil
107116
}

providers/azure/resources/network.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ func (a *mqlAzureSubscriptionNetworkServiceLoadBalancer) outboundRules() ([]any,
557557
if err != nil {
558558
return nil, err
559559
}
560-
mqlOutbound, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.outbundRule",
560+
mqlOutbound, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.outboundRule",
561561
map[string]*llx.RawData{
562562
"id": llx.StringDataPtr(outboundRule.ID),
563563
"type": llx.StringDataPtr(outboundRule.Type),
@@ -1232,12 +1232,16 @@ func (a *mqlAzureSubscriptionNetworkServiceVirtualNetworkGateway) ipConfiguratio
12321232
if err != nil {
12331233
return nil, err
12341234
}
1235+
var privateIP *string
1236+
if ipc.Properties != nil {
1237+
privateIP = ipc.Properties.PrivateIPAddress
1238+
}
12351239
mqlIpc, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.virtualNetworkGateway.ipConfig", map[string]*llx.RawData{
12361240
"id": llx.StringDataPtr(ipc.ID),
12371241
"name": llx.StringDataPtr(ipc.Name),
12381242
"etag": llx.StringDataPtr(ipc.Etag),
12391243
"properties": llx.DictData(props),
1240-
"privateIpAddress": llx.StringDataPtr(ipc.Properties.PrivateIPAddress),
1244+
"privateIpAddress": llx.StringDataPtr(privateIP),
12411245
})
12421246
if err != nil {
12431247
return nil, err
@@ -2271,12 +2275,16 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewall) ipConfigurations() ([]any,
22712275
if err != nil {
22722276
return nil, err
22732277
}
2278+
var privateIP *string
2279+
if ipConfig.Properties != nil {
2280+
privateIP = ipConfig.Properties.PrivateIPAddress
2281+
}
22742282
mqlIpConfig, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.firewall.ipConfig",
22752283
map[string]*llx.RawData{
22762284
"id": llx.StringDataPtr(ipConfig.ID),
22772285
"name": llx.StringDataPtr(ipConfig.Name),
22782286
"etag": llx.StringDataPtr(ipConfig.Etag),
2279-
"privateIpAddress": llx.StringDataPtr(ipConfig.Properties.PrivateIPAddress),
2287+
"privateIpAddress": llx.StringDataPtr(privateIP),
22802288
"properties": llx.DictData(props),
22812289
})
22822290
if err != nil {
@@ -2297,12 +2305,16 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewall) managementIpConfiguration()
22972305
if err != nil {
22982306
return nil, err
22992307
}
2308+
var privateIP *string
2309+
if ipConfig.Properties != nil {
2310+
privateIP = ipConfig.Properties.PrivateIPAddress
2311+
}
23002312
mqlIpConfig, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.firewall.ipConfig",
23012313
map[string]*llx.RawData{
23022314
"id": llx.StringDataPtr(ipConfig.ID),
23032315
"name": llx.StringDataPtr(ipConfig.Name),
23042316
"etag": llx.StringDataPtr(ipConfig.Etag),
2305-
"privateIpAddress": llx.StringDataPtr(ipConfig.Properties.PrivateIPAddress),
2317+
"privateIpAddress": llx.StringDataPtr(privateIP),
23062318
"properties": llx.DictData(props),
23072319
})
23082320
if err != nil {

0 commit comments

Comments
 (0)