Skip to content
Snippets Groups Projects
Unverified Commit 217ea888 authored by RahulGautamSingh's avatar RahulGautamSingh Committed by GitHub
Browse files

fix: migrate hostType (#21432)

parent 0d000aea
No related branches found
No related tags found
No related merge requests found
...@@ -5,19 +5,42 @@ describe('config/migrations/custom/host-rules-migration', () => { ...@@ -5,19 +5,42 @@ describe('config/migrations/custom/host-rules-migration', () => {
expect(HostRulesMigration).toMigrate( expect(HostRulesMigration).toMigrate(
{ {
hostRules: [ 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' }, { domainName: 'domain.com/', token: '123test' },
{ matchHost: 'domain.com/', token: '123test' }, { hostType: 'docker', matchHost: 'domain.com/', token: '123test' },
{ hostName: 'some.domain.com', token: '123test' }, { hostName: 'some.domain.com', token: '123test' },
], ],
} as any, } as any,
{ {
hostRules: [ hostRules: [
{ matchHost: 'https://some.domain.com', token: '123test' }, {
{ matchHost: 'domain.com', token: '123test' }, hostType: 'dotnet-version',
{ matchHost: 'https://domain.com/', token: '123test' }, matchHost: 'https://some.domain.com',
{ matchHost: 'https://domain.com/', token: '123test' }, 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' }, { matchHost: 'some.domain.com', token: '123test' },
], ],
} }
......
import is from '@sindresorhus/is'; import is from '@sindresorhus/is';
import type { HostRule } from '../../../types'; import type { HostRule } from '../../../types';
import { AbstractMigration } from '../base/abstract-migration'; import { AbstractMigration } from '../base/abstract-migration';
import { migrateDatasource } from './datasource-migration';
export class HostRulesMigration extends AbstractMigration { export class HostRulesMigration extends AbstractMigration {
override readonly propertyName = 'hostRules'; override readonly propertyName = 'hostRules';
...@@ -25,6 +26,13 @@ export class HostRulesMigration extends AbstractMigration { ...@@ -25,6 +26,13 @@ export class HostRulesMigration extends AbstractMigration {
continue; continue;
} }
if (key === 'hostType') {
if (is.string(value)) {
newRule.hostType ??= migrateDatasource(value);
}
continue;
}
if ( if (
key === 'endpoint' || key === 'endpoint' ||
key === 'host' || key === 'host' ||
......
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