From 677fc8b332085a0092599162766ce8951614316d Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Fri, 8 Jul 2022 16:05:29 +0200
Subject: [PATCH] fix(datasource/docker): do not use json for '/v2/' (#16482)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
---
 lib/modules/datasource/docker/index.ts | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/modules/datasource/docker/index.ts b/lib/modules/datasource/docker/index.ts
index c258891cda..6c539394ad 100644
--- a/lib/modules/datasource/docker/index.ts
+++ b/lib/modules/datasource/docker/index.ts
@@ -57,12 +57,15 @@ export async function getAuthHeaders(
   apiCheckUrl = `${registryHost}/v2/`
 ): Promise<OutgoingHttpHeaders | null> {
   try {
-    // use json request, as this will be cached for tags, so it returns json
-    // TODO: add cache test
-    const apiCheckResponse = await http.getJson(apiCheckUrl, {
+    const options = {
       throwHttpErrors: false,
       noAuth: true,
-    });
+    };
+    const apiCheckResponse = apiCheckUrl.endsWith('/v2/')
+      ? await http.get(apiCheckUrl, options)
+      : // use json request, as this will be cached for tags, so it returns json
+        // TODO: add cache test
+        await http.getJson(apiCheckUrl, options);
 
     if (apiCheckResponse.statusCode === 200) {
       logger.debug({ apiCheckUrl }, 'No registry auth required');
-- 
GitLab