From ad64f11af4aed89ebda081b322551fceeb28aa6c Mon Sep 17 00:00:00 2001
From: Philip <42116482+PhilipAbed@users.noreply.github.com>
Date: Tue, 27 Aug 2024 16:31:34 +0300
Subject: [PATCH] fix(helmfile): url joiner is broken, use upath instead
 (#31008)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
---
 lib/modules/manager/helmfile/extract.spec.ts | 27 ++++++++++++++++++++
 lib/modules/manager/helmfile/extract.ts      |  5 ++--
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts
index c3b1a7be23..9ce660515e 100644
--- a/lib/modules/manager/helmfile/extract.spec.ts
+++ b/lib/modules/manager/helmfile/extract.spec.ts
@@ -483,5 +483,32 @@ describe('modules/manager/helmfile/extract', () => {
         managerData: { needKustomize: true },
       });
     });
+
+    it('makes sure url joiner works correctly', async () => {
+      const content = codeBlock`
+      releases:
+        - name: argocd
+          version: 0.4.2
+          chart: oci://gitlab.example.com:5000/group/subgroup
+      `;
+      const fileName = 'helmfile.yaml';
+      const result = await extractPackageFile(content, fileName, {
+        registryAliases: {
+          stable: 'https://charts.helm.sh/stable',
+        },
+      });
+      expect(result).toMatchObject({
+        datasource: 'helm',
+        deps: [
+          {
+            currentValue: '0.4.2',
+            datasource: 'docker',
+            depName: 'subgroup',
+            packageName: 'gitlab.example.com:5000/group/subgroup',
+            registryUrls: [],
+          },
+        ],
+      });
+    });
   });
 });
diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts
index 3ae6013116..07f0ce0868 100644
--- a/lib/modules/manager/helmfile/extract.ts
+++ b/lib/modules/manager/helmfile/extract.ts
@@ -2,7 +2,6 @@ import is from '@sindresorhus/is';
 import { logger } from '../../../logger';
 import { coerceArray } from '../../../util/array';
 import { regEx } from '../../../util/regex';
-import { joinUrlParts } from '../../../util/url';
 import { parseYaml } from '../../../util/yaml';
 import { DockerDatasource } from '../../datasource/docker';
 import { HelmDatasource } from '../../datasource/helm';
@@ -118,12 +117,12 @@ export async function extractPackageFile(
 
       if (isOCIRegistry(dep.chart)) {
         res.datasource = DockerDatasource.id;
-        res.packageName = joinUrlParts(repoName, depName);
+        res.packageName = `${repoName}/${depName}`;
       } else if (registryData[repoName]?.oci) {
         res.datasource = DockerDatasource.id;
         const alias = registryData[repoName]?.url;
         if (alias) {
-          res.packageName = joinUrlParts(alias, depName);
+          res.packageName = `${alias}/${depName}`;
         }
       }
 
-- 
GitLab