Skip to content

Commit

Permalink
fix(manager/kubernetes): allow trailing comments (#21260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Churro committed Mar 31, 2023
1 parent 480cff5 commit 4ce27f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/modules/manager/kubernetes/__fixtures__/kubernetes.yaml
Expand Up @@ -19,6 +19,10 @@ spec:
image: nginx:1.7.9
ports:
- containerPort: 80
- name: nginx2
image: nginx:1.22.1 # trailing comment
ports:
- containerPort: 8081

---

Expand Down
9 changes: 9 additions & 0 deletions lib/modules/manager/kubernetes/extract.spec.ts
Expand Up @@ -30,6 +30,15 @@ describe('modules/manager/kubernetes/extract', () => {
depName: 'nginx',
replaceString: 'nginx:1.7.9',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: '1.22.1',
datasource: 'docker',
depName: 'nginx',
replaceString: 'nginx:1.22.1',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/kubernetes/extract.ts
Expand Up @@ -44,7 +44,7 @@ function extractImages(
const deps: PackageDependency[] = [];

for (const line of content.split(newlineRegex)) {
const match = regEx(/^\s*-?\s*image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line);
const match = regEx(/^\s*-?\s*image:\s*['"]?([^\s'"]+)['"]?\s*/).exec(line);
if (match) {
const currentFrom = match[1];
const dep = getDep(currentFrom, true, config.registryAliases);
Expand Down

0 comments on commit 4ce27f5

Please sign in to comment.