Skip to content
Snippets Groups Projects
Unverified Commit b39ad3a9 authored by Marc Mognol's avatar Marc Mognol Committed by GitHub
Browse files

fix(manager/nuget): Add autoReplaceStringTemplate (#26508)

parent 31dc0fd0
No related branches found
Tags 37.125.1
No related merge requests found
...@@ -80,10 +80,13 @@ describe('modules/manager/nuget/extract', () => { ...@@ -80,10 +80,13 @@ describe('modules/manager/nuget/extract', () => {
expect(await extractPackageFile(contents, contents, config)).toEqual({ expect(await extractPackageFile(contents, contents, config)).toEqual({
deps: [ deps: [
{ {
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
depName: 'mcr.microsoft.com/dotnet/runtime', depName: 'mcr.microsoft.com/dotnet/runtime',
depType: 'docker', depType: 'docker',
datasource: 'docker', datasource: 'docker',
currentValue: '7.0.10', currentValue: '7.0.10',
replaceString: 'mcr.microsoft.com/dotnet/runtime:7.0.10',
}, },
], ],
packageFileVersion: '0.1.0', packageFileVersion: '0.1.0',
...@@ -102,12 +105,16 @@ describe('modules/manager/nuget/extract', () => { ...@@ -102,12 +105,16 @@ describe('modules/manager/nuget/extract', () => {
expect(await extractPackageFile(contents, contents, config)).toEqual({ expect(await extractPackageFile(contents, contents, config)).toEqual({
deps: [ deps: [
{ {
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
depName: 'mcr.microsoft.com/dotnet/runtime', depName: 'mcr.microsoft.com/dotnet/runtime',
depType: 'docker', depType: 'docker',
datasource: 'docker', datasource: 'docker',
currentValue: '7.0.10', currentValue: '7.0.10',
currentDigest: currentDigest:
'sha256:181067029e094856691ee1ce3782ea3bd3fda01bb5b6d19411d0f673cab1ab19', 'sha256:181067029e094856691ee1ce3782ea3bd3fda01bb5b6d19411d0f673cab1ab19',
replaceString:
'mcr.microsoft.com/dotnet/runtime:7.0.10@sha256:181067029e094856691ee1ce3782ea3bd3fda01bb5b6d19411d0f673cab1ab19',
}, },
], ],
packageFileVersion: '0.1.0', packageFileVersion: '0.1.0',
......
...@@ -4,7 +4,6 @@ import { logger } from '../../../logger'; ...@@ -4,7 +4,6 @@ import { logger } from '../../../logger';
import { getSiblingFileName, localPathExists } from '../../../util/fs'; import { getSiblingFileName, localPathExists } from '../../../util/fs';
import { hasKey } from '../../../util/object'; import { hasKey } from '../../../util/object';
import { regEx } from '../../../util/regex'; import { regEx } from '../../../util/regex';
import { DockerDatasource } from '../../datasource/docker';
import { NugetDatasource } from '../../datasource/nuget'; import { NugetDatasource } from '../../datasource/nuget';
import { getDep } from '../dockerfile/extract'; import { getDep } from '../dockerfile/extract';
import type { import type {
...@@ -49,16 +48,10 @@ function extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] { ...@@ -49,16 +48,10 @@ function extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] {
const { name, attr } = child; const { name, attr } = child;
if (name === 'ContainerBaseImage') { if (name === 'ContainerBaseImage') {
const dep = getDep(child.val, true); const { depName, ...dep } = getDep(child.val, true);
if (is.nonEmptyStringAndNotWhitespace(dep.depName)) { if (is.nonEmptyStringAndNotWhitespace(depName)) {
results.push({ results.push({ ...dep, depName, depType: 'docker' });
datasource: DockerDatasource.id,
depType: 'docker',
depName: dep.depName,
currentValue: dep.currentValue,
currentDigest: dep.currentDigest,
});
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment