Skip to content

Commit

Permalink
fix: migrate hostType (#21432)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Apr 12, 2023
1 parent 0d000ae commit 217ea88
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
37 changes: 30 additions & 7 deletions lib/config/migrations/custom/host-rules-migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
}
Expand Down
8 changes: 8 additions & 0 deletions lib/config/migrations/custom/host-rules-migration.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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' ||
Expand Down

0 comments on commit 217ea88

Please sign in to comment.