Skip to content

Commit c44cbf7

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 a2a1f1b commit c44cbf7

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
@@ -570,7 +570,7 @@ func (a *mqlAzureSubscriptionNetworkServiceLoadBalancer) outboundRules() ([]any,
570570
if err != nil {
571571
return nil, err
572572
}
573-
mqlOutbound, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.outbundRule",
573+
mqlOutbound, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.outboundRule",
574574
map[string]*llx.RawData{
575575
"id": llx.StringDataPtr(outboundRule.ID),
576576
"type": llx.StringDataPtr(outboundRule.Type),
@@ -1245,12 +1245,16 @@ func (a *mqlAzureSubscriptionNetworkServiceVirtualNetworkGateway) ipConfiguratio
12451245
if err != nil {
12461246
return nil, err
12471247
}
1248+
var privateIP *string
1249+
if ipc.Properties != nil {
1250+
privateIP = ipc.Properties.PrivateIPAddress
1251+
}
12481252
mqlIpc, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.virtualNetworkGateway.ipConfig", map[string]*llx.RawData{
12491253
"id": llx.StringDataPtr(ipc.ID),
12501254
"name": llx.StringDataPtr(ipc.Name),
12511255
"etag": llx.StringDataPtr(ipc.Etag),
12521256
"properties": llx.DictData(props),
1253-
"privateIpAddress": llx.StringDataPtr(ipc.Properties.PrivateIPAddress),
1257+
"privateIpAddress": llx.StringDataPtr(privateIP),
12541258
})
12551259
if err != nil {
12561260
return nil, err
@@ -2284,12 +2288,16 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewall) ipConfigurations() ([]any,
22842288
if err != nil {
22852289
return nil, err
22862290
}
2291+
var privateIP *string
2292+
if ipConfig.Properties != nil {
2293+
privateIP = ipConfig.Properties.PrivateIPAddress
2294+
}
22872295
mqlIpConfig, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.firewall.ipConfig",
22882296
map[string]*llx.RawData{
22892297
"id": llx.StringDataPtr(ipConfig.ID),
22902298
"name": llx.StringDataPtr(ipConfig.Name),
22912299
"etag": llx.StringDataPtr(ipConfig.Etag),
2292-
"privateIpAddress": llx.StringDataPtr(ipConfig.Properties.PrivateIPAddress),
2300+
"privateIpAddress": llx.StringDataPtr(privateIP),
22932301
"properties": llx.DictData(props),
22942302
})
22952303
if err != nil {
@@ -2310,12 +2318,16 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewall) managementIpConfiguration()
23102318
if err != nil {
23112319
return nil, err
23122320
}
2321+
var privateIP *string
2322+
if ipConfig.Properties != nil {
2323+
privateIP = ipConfig.Properties.PrivateIPAddress
2324+
}
23132325
mqlIpConfig, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.firewall.ipConfig",
23142326
map[string]*llx.RawData{
23152327
"id": llx.StringDataPtr(ipConfig.ID),
23162328
"name": llx.StringDataPtr(ipConfig.Name),
23172329
"etag": llx.StringDataPtr(ipConfig.Etag),
2318-
"privateIpAddress": llx.StringDataPtr(ipConfig.Properties.PrivateIPAddress),
2330+
"privateIpAddress": llx.StringDataPtr(privateIP),
23192331
"properties": llx.DictData(props),
23202332
})
23212333
if err != nil {

0 commit comments

Comments
 (0)