diff --git a/lib/modules/datasource/custom/index.ts b/lib/modules/datasource/custom/index.ts index 64d0fcfff9d757..80029a31e672f0 100644 --- a/lib/modules/datasource/custom/index.ts +++ b/lib/modules/datasource/custom/index.ts @@ -2,7 +2,7 @@ import is from '@sindresorhus/is'; import jsonata from 'jsonata'; import { logger } from '../../../logger'; import { Datasource } from '../datasource'; -import type { GetReleasesConfig, ReleaseResult } from '../types'; +import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types'; import { fetchers } from './formats'; import { ReleaseResultZodSchema } from './schema'; import { getCustomConfig } from './utils'; @@ -57,4 +57,14 @@ export class CustomDatasource extends Datasource { return null; } } + + override getDigest( + { packageName: repo, registryUrl }: Partial, + newValue?: string, + ): Promise { + // Return null here to support setting a digest: value can be provided digest in getReleases + return new Promise((resolve) => { + resolve(null); + }); + } } diff --git a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap index ec745fa6955e38..b9ae40694fc1dc 100644 --- a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap @@ -91,6 +91,22 @@ exports[`workers/repository/process/lookup/index .lookupUpdates() handles digest } `; +exports[`workers/repository/process/lookup/index .lookupUpdates() handles digest update for custom datasource 1`] = ` +{ + "currentVersion": "1.0.0", + "fixedVersion": "1.0.0", + "updates": [ + { + "newDigest": "0123456789abcdef", + "newValue": "1.0.0", + "updateType": "digest", + }, + ], + "versioning": "npm", + "warnings": [], +} +`; + exports[`workers/repository/process/lookup/index .lookupUpdates() handles digest update for non-version 1`] = ` { "updates": [ diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index e9001458c7177b..fbff03858b3ddb 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -4,6 +4,7 @@ import * as httpMock from '../../../../../test/http-mock'; import { partial } from '../../../../../test/util'; import { getConfig } from '../../../../config/defaults'; import { CONFIG_VALIDATION } from '../../../../constants/error-messages'; +import { CustomDatasource } from '../../../../modules/datasource/custom'; import { DockerDatasource } from '../../../../modules/datasource/docker'; import { GitRefsDatasource } from '../../../../modules/datasource/git-refs'; import { GithubReleasesDatasource } from '../../../../modules/datasource/github-releases'; @@ -56,6 +57,11 @@ describe('workers/repository/process/lookup/index', () => { 'getReleases', ); + const getCustomDatasourceReleases = jest.spyOn( + CustomDatasource.prototype, + 'getReleases', + ); + const getDockerDigest = jest.spyOn(DockerDatasource.prototype, 'getDigest'); beforeEach(() => { @@ -1938,6 +1944,31 @@ describe('workers/repository/process/lookup/index', () => { }); }); + it('handles digest update for custom datasource', async () => { + config.currentValue = '1.0.0'; + config.packageName = 'my-package'; + config.datasource = CustomDatasource.id; + config.currentDigest = 'zzzzzzzzzzzzzzz'; + getCustomDatasourceReleases.mockResolvedValueOnce({ + releases: [ + { + version: '1.0.0', + newDigest: '0123456789abcdef', + }, + ], + }); + const res = await lookup.lookupUpdates(config); + expect(res).toMatchSnapshot({ + updates: [ + { + newDigest: '0123456789abcdef', + newValue: '1.0.0', + updateType: 'digest', + }, + ], + }); + }); + it('handles digest update for non-version', async () => { config.currentValue = 'alpine'; config.packageName = 'node';