diff --git a/lib/modules/datasource/azure-bicep-resource/index.spec.ts b/lib/modules/datasource/azure-bicep-resource/index.spec.ts index 4afbff7d53e9ee7d32a41e77f09fe78eb672bd7f..0b1dff2be12647e45da84f0f854115a5464a9016 100644 --- a/lib/modules/datasource/azure-bicep-resource/index.spec.ts +++ b/lib/modules/datasource/azure-bicep-resource/index.spec.ts @@ -28,7 +28,7 @@ describe('modules/datasource/azure-bicep-resource/index', () => { expect(result).toBeNull(); }); - it('should return versions when package is a function', async () => { + it('should return null when package is a function', async () => { httpMock .scope(gitHubHost) .get(indexPath) @@ -57,23 +57,10 @@ describe('modules/datasource/azure-bicep-resource/index', () => { const azureBicepResourceDatasource = new AzureBicepResourceDatasource(); const result = await azureBicepResourceDatasource.getReleases({ - packageName: 'Microsoft.Billing/billingAccounts', + packageName: 'unknown', }); - expect(result).toEqual({ - releases: [ - { - version: '2019-10-01-preview', - changelogUrl: - 'https://learn.microsoft.com/en-us/azure/templates/microsoft.billing/change-log/billingaccounts#2019-10-01-preview', - }, - { - version: '2020-05-01', - changelogUrl: - 'https://learn.microsoft.com/en-us/azure/templates/microsoft.billing/change-log/billingaccounts#2020-05-01', - }, - ], - }); + expect(result).toBeNull(); }); it('should return versions when package is a resource', async () => { @@ -117,4 +104,46 @@ describe('modules/datasource/azure-bicep-resource/index', () => { ], }); }); + + it('should return versions when package is a resource and a function', async () => { + httpMock + .scope(gitHubHost) + .get(indexPath) + .reply( + 200, + codeBlock` + { + "resources": { + "Microsoft.OperationalInsights/workspaces@2023-09-01": { + "$ref": "operationalinsights/microsoft.operationalinsights/2023-09-01/types.json#/31" + } + }, + "resourceFunctions": { + "microsoft.operationalinsights/workspaces": { + "2015-03-20": [ + { + "$ref": "operationalinsights/workspaces/2015-03-20/types.json#/304" + } + ] + } + } + } + `, + ); + + const azureBicepResourceDatasource = new AzureBicepResourceDatasource(); + const result = await azureBicepResourceDatasource.getReleases({ + packageName: 'Microsoft.OperationalInsights/workspaces', + }); + + expect(result).toEqual({ + releases: [ + { + version: '2023-09-01', + changelogUrl: + 'https://learn.microsoft.com/en-us/azure/templates/microsoft.operationalinsights/change-log/workspaces#2023-09-01', + }, + ], + }); + }); }); diff --git a/lib/modules/datasource/azure-bicep-resource/schema.ts b/lib/modules/datasource/azure-bicep-resource/schema.ts index 70dd2938f54f03fe65f7771817144eec52a6eaac..c94db6faea33defd51f0ecadb43ee2967a23d365 100644 --- a/lib/modules/datasource/azure-bicep-resource/schema.ts +++ b/lib/modules/datasource/azure-bicep-resource/schema.ts @@ -3,9 +3,8 @@ import { z } from 'zod'; export const BicepResourceVersionIndex = z .object({ resources: z.record(z.string(), z.unknown()), - resourceFunctions: z.record(z.string(), z.record(z.string(), z.unknown())), }) - .transform(({ resources, resourceFunctions }) => { + .transform(({ resources }) => { const releaseMap = new Map<string, string[]>(); for (const resourceReference of Object.keys(resources)) { @@ -15,11 +14,6 @@ export const BicepResourceVersionIndex = z releaseMap.set(type, versions); } - for (const [type, versionMap] of Object.entries(resourceFunctions)) { - const versions = Object.keys(versionMap); - releaseMap.set(type, versions); - } - return Object.fromEntries(releaseMap); });