From b39ad3a90b9c61711a7b3e13e5fa3d26f7635fcb Mon Sep 17 00:00:00 2001 From: Marc Mognol <8171300+marcmognol@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:31:53 +0100 Subject: [PATCH] fix(manager/nuget): Add autoReplaceStringTemplate (#26508) Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- lib/modules/manager/nuget/extract.spec.ts | 7 +++++++ lib/modules/manager/nuget/extract.ts | 13 +++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/modules/manager/nuget/extract.spec.ts b/lib/modules/manager/nuget/extract.spec.ts index 7070e8f62c..69c2cb01e1 100644 --- a/lib/modules/manager/nuget/extract.spec.ts +++ b/lib/modules/manager/nuget/extract.spec.ts @@ -80,10 +80,13 @@ describe('modules/manager/nuget/extract', () => { expect(await extractPackageFile(contents, contents, config)).toEqual({ deps: [ { + autoReplaceStringTemplate: + '{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}', depName: 'mcr.microsoft.com/dotnet/runtime', depType: 'docker', datasource: 'docker', currentValue: '7.0.10', + replaceString: 'mcr.microsoft.com/dotnet/runtime:7.0.10', }, ], packageFileVersion: '0.1.0', @@ -102,12 +105,16 @@ describe('modules/manager/nuget/extract', () => { expect(await extractPackageFile(contents, contents, config)).toEqual({ deps: [ { + autoReplaceStringTemplate: + '{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}', depName: 'mcr.microsoft.com/dotnet/runtime', depType: 'docker', datasource: 'docker', currentValue: '7.0.10', currentDigest: 'sha256:181067029e094856691ee1ce3782ea3bd3fda01bb5b6d19411d0f673cab1ab19', + replaceString: + 'mcr.microsoft.com/dotnet/runtime:7.0.10@sha256:181067029e094856691ee1ce3782ea3bd3fda01bb5b6d19411d0f673cab1ab19', }, ], packageFileVersion: '0.1.0', diff --git a/lib/modules/manager/nuget/extract.ts b/lib/modules/manager/nuget/extract.ts index f127f32f81..bded649731 100644 --- a/lib/modules/manager/nuget/extract.ts +++ b/lib/modules/manager/nuget/extract.ts @@ -4,7 +4,6 @@ import { logger } from '../../../logger'; import { getSiblingFileName, localPathExists } from '../../../util/fs'; import { hasKey } from '../../../util/object'; import { regEx } from '../../../util/regex'; -import { DockerDatasource } from '../../datasource/docker'; import { NugetDatasource } from '../../datasource/nuget'; import { getDep } from '../dockerfile/extract'; import type { @@ -49,16 +48,10 @@ function extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] { const { name, attr } = child; if (name === 'ContainerBaseImage') { - const dep = getDep(child.val, true); + const { depName, ...dep } = getDep(child.val, true); - if (is.nonEmptyStringAndNotWhitespace(dep.depName)) { - results.push({ - datasource: DockerDatasource.id, - depType: 'docker', - depName: dep.depName, - currentValue: dep.currentValue, - currentDigest: dep.currentDigest, - }); + if (is.nonEmptyStringAndNotWhitespace(depName)) { + results.push({ ...dep, depName, depType: 'docker' }); } } -- GitLab