private static async Task VisitAKSCluster()

in src/PSRule.Rules.Azure/Pipeline/Export/ResourceExportVisitor.cs [606:635]


    private static async Task<bool> VisitAKSCluster(ResourceContext context, JObject resource, string resourceType, string resourceId)
    {
        if (!string.Equals(resourceType, TYPE_CONTAINERSERVICE_MANAGEDCLUSTERS, StringComparison.OrdinalIgnoreCase))
            return false;

        // Get related VNET
        if (resource.TryGetProperty(PROPERTY_PROPERTIES, out JObject properties) &&
            properties.TryGetProperty(PROPERTY_NETWORKPROFILE, out JObject networkProfile) &&
            networkProfile.TryGetProperty(PROPERTY_NETOWORKPLUGIN, out var networkPlugin) &&
            string.Equals(networkPlugin, "azure", StringComparison.OrdinalIgnoreCase) &&
            properties.TryArrayProperty(PROPERTY_AGENTPOOLPROFILES, out var agentPoolProfiles) &&
            agentPoolProfiles.Count > 0)
        {
            for (var i = 0; i < agentPoolProfiles.Count; i++)
            {
                if (agentPoolProfiles[i] is JObject profile && profile.TryGetProperty("vnetSubnetID", out var vnetSubnetID))
                {
                    // Get VNET.
                    AddSubResource(resource, await GetResource(context, vnetSubnetID, APIVERSION_2022_07_01));
                }
            }
        }

        // Get maintenance configurations
        AddSubResource(resource, await GetSubResourcesByType(context, resourceId, PROPERTY_MAINTENANCECONFIGURATIONS, APIVERSION_2024_03_02_PREVIEW));

        // Get diagnostic settings
        await GetDiagnosticSettings(context, resource, resourceId);
        return true;
    }