From 217ea888a94086547a1d470ae8a42d63557be9eb Mon Sep 17 00:00:00 2001 From: RahulGautamSingh <rahultesnik@gmail.com> Date: Wed, 12 Apr 2023 09:35:07 +0530 Subject: [PATCH] fix: migrate hostType (#21432) --- .../custom/host-rules-migration.spec.ts | 37 +++++++++++++++---- .../migrations/custom/host-rules-migration.ts | 8 ++++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/lib/config/migrations/custom/host-rules-migration.spec.ts b/lib/config/migrations/custom/host-rules-migration.spec.ts index fe399a79db..30aed0c47d 100644 --- a/lib/config/migrations/custom/host-rules-migration.spec.ts +++ b/lib/config/migrations/custom/host-rules-migration.spec.ts @@ -5,19 +5,42 @@ describe('config/migrations/custom/host-rules-migration', () => { expect(HostRulesMigration).toMigrate( { hostRules: [ - { baseUrl: 'https://some.domain.com', token: '123test' }, - { domainName: 'domain.com', token: '123test' }, + { + hostType: 'dotnet', + baseUrl: 'https://some.domain.com', + token: '123test', + }, + { + hostType: 'adoptium-java', + domainName: 'domain.com', + token: '123test', + }, { domainName: 'domain.com/', token: '123test' }, - { matchHost: 'domain.com/', token: '123test' }, + { hostType: 'docker', matchHost: 'domain.com/', token: '123test' }, { hostName: 'some.domain.com', token: '123test' }, ], } as any, { hostRules: [ - { matchHost: 'https://some.domain.com', token: '123test' }, - { matchHost: 'domain.com', token: '123test' }, - { matchHost: 'https://domain.com/', token: '123test' }, - { matchHost: 'https://domain.com/', token: '123test' }, + { + hostType: 'dotnet-version', + matchHost: 'https://some.domain.com', + token: '123test', + }, + { + hostType: 'java-version', + matchHost: 'domain.com', + token: '123test', + }, + { + matchHost: 'https://domain.com/', + token: '123test', + }, + { + hostType: 'docker', + matchHost: 'https://domain.com/', + token: '123test', + }, { matchHost: 'some.domain.com', token: '123test' }, ], } diff --git a/lib/config/migrations/custom/host-rules-migration.ts b/lib/config/migrations/custom/host-rules-migration.ts index 45bd9f13f5..d2c368f7aa 100644 --- a/lib/config/migrations/custom/host-rules-migration.ts +++ b/lib/config/migrations/custom/host-rules-migration.ts @@ -1,6 +1,7 @@ import is from '@sindresorhus/is'; import type { HostRule } from '../../../types'; import { AbstractMigration } from '../base/abstract-migration'; +import { migrateDatasource } from './datasource-migration'; export class HostRulesMigration extends AbstractMigration { override readonly propertyName = 'hostRules'; @@ -25,6 +26,13 @@ export class HostRulesMigration extends AbstractMigration { continue; } + if (key === 'hostType') { + if (is.string(value)) { + newRule.hostType ??= migrateDatasource(value); + } + continue; + } + if ( key === 'endpoint' || key === 'host' || -- GitLab