Skip to content

Commit

Permalink
Merge branch 'main' into feat/flux-helmrepo-oci
Browse files Browse the repository at this point in the history
  • Loading branch information
samip5 committed May 23, 2023
2 parents 94bebcb + c8f4935 commit 26c5fe1
Show file tree
Hide file tree
Showing 20 changed files with 300 additions and 235 deletions.
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -1675,6 +1675,7 @@ Supported lock files are:
- `jsonnetfile.lock.json`
- `package-lock.json`
- `packages.lock.json`
- `pdm.lock`
- `Pipfile.lock`
- `pnpm-lock.yaml`
- `poetry.lock`
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/docker.md
Expand Up @@ -388,7 +388,7 @@ To get access to the token a custom Renovate Docker image is needed that include
The Dockerfile to create such an image can look like this:

```Dockerfile
FROM renovate/renovate:35.82.0
FROM renovate/renovate:35.98.0
# Include the "Docker tip" which you can find here https://cloud.google.com/sdk/docs/install
# under "Installation" for "Debian/Ubuntu"
RUN ...
Expand Down
1 change: 1 addition & 0 deletions docs/usage/python.md
Expand Up @@ -47,6 +47,7 @@ There are three ways to do this:

- index-url in `requirements.txt`
- sources in `Pipfile`
- sources in `pyproject.toml`
- set URL in Renovate configuration

### index-url in `requirements.txt`
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/reading-list.md
Expand Up @@ -51,7 +51,7 @@ Read this list _after_ experiencing Renovate's default behavior, once you really
- [Noise Reduction](./noise-reduction.md)

Skim the [repository configuration options](./configuration-options.md) to learn about the kind of customizations you can make to Renovate.
Feel free to read up on anything that looks intersting to you.
Feel free to read up on anything that looks interesting to you.

## Advanced

Expand Down
1 change: 0 additions & 1 deletion lib/config/migration.spec.ts
Expand Up @@ -20,7 +20,6 @@ describe('config/migration', () => {
{
platform: 'docker',
endpoint: 'https://docker.io',
host: 'docker.io',
username: 'some-username',
password: 'some-password',
},
Expand Down
39 changes: 39 additions & 0 deletions lib/config/migrations/custom/host-rules-migration.spec.ts
@@ -1,3 +1,4 @@
import { CONFIG_VALIDATION } from '../../../constants/error-messages';
import { HostRulesMigration } from './host-rules-migration';

describe('config/migrations/custom/host-rules-migration', () => {
Expand All @@ -10,6 +11,12 @@ describe('config/migrations/custom/host-rules-migration', () => {
baseUrl: 'https://some.domain.com',
token: '123test',
},
{
hostType: 'dotnet',
baseUrl: 'https://some.domain.com',
matchHost: 'https://some.domain.com',
token: '123test',
},
{
hostType: 'adoptium-java',
domainName: 'domain.com',
Expand All @@ -18,10 +25,17 @@ describe('config/migrations/custom/host-rules-migration', () => {
{ domainName: 'domain.com/', token: '123test' },
{ hostType: 'docker', matchHost: 'domain.com/', token: '123test' },
{ hostName: 'some.domain.com', token: '123test' },
{ endpoint: 'domain.com/', token: '123test' },
{ host: 'some.domain.com', token: '123test' },
],
} as any,
{
hostRules: [
{
hostType: 'dotnet-version',
matchHost: 'https://some.domain.com',
token: '123test',
},
{
hostType: 'dotnet-version',
matchHost: 'https://some.domain.com',
Expand All @@ -42,8 +56,33 @@ describe('config/migrations/custom/host-rules-migration', () => {
token: '123test',
},
{ matchHost: 'some.domain.com', token: '123test' },
{ matchHost: 'https://domain.com/', token: '123test' },
{ matchHost: 'some.domain.com', token: '123test' },
],
}
);
});

it('throws when multiple hosts are present', () => {
expect(() =>
new HostRulesMigration(
{
hostRules: [
{
matchHost: 'https://some-diff.domain.com',
baseUrl: 'https://some.domain.com',
token: '123test',
},
],
} as any,
{}
).run([
{
matchHost: 'https://some-diff.domain.com',
baseUrl: 'https://some.domain.com',
token: '123test',
},
])
).toThrow(CONFIG_VALIDATION);
});
});
48 changes: 47 additions & 1 deletion lib/config/migrations/custom/host-rules-migration.ts
@@ -1,14 +1,18 @@
import is from '@sindresorhus/is';
import { CONFIG_VALIDATION } from '../../../constants/error-messages';
import { logger } from '../../../logger';
import type { HostRule } from '../../../types';
import type { LegacyHostRule } from '../../../util/host-rules';
import { AbstractMigration } from '../base/abstract-migration';
import { migrateDatasource } from './datasource-migration';

export class HostRulesMigration extends AbstractMigration {
override readonly propertyName = 'hostRules';

override run(value: Record<string, unknown>[]): void {
override run(value: (LegacyHostRule & HostRule)[]): void {
const newHostRules: HostRule[] = [];
for (const hostRule of value) {
validateHostRule(hostRule);
const newRule: any = {};

for (const [key, value] of Object.entries(hostRule)) {
Expand Down Expand Up @@ -56,10 +60,52 @@ export class HostRulesMigration extends AbstractMigration {
}
}

function validateHostRule(rule: LegacyHostRule & HostRule): void {
const { matchHost, hostName, domainName, baseUrl, endpoint, host } = rule;
const hosts: Record<string, string> = removeUndefinedFields({
matchHost,
hostName,
domainName,
baseUrl,
endpoint,
host,
});

if (Object.keys(hosts).length > 1) {
const distinctHostValues = new Set(Object.values(hosts));
// check if the host values are duplicated
if (distinctHostValues.size > 1) {
const error = new Error(CONFIG_VALIDATION);
error.validationSource = 'config';
error.validationMessage = `hostRules cannot contain more than one host-matching field - use "matchHost" only.`;
error.validationError =
'The renovate configuration file contains some invalid settings';
throw error;
} else {
logger.warn(
{ hosts },
'Duplicate host values found, please only use `matchHost` to specify the host'
);
}
}
}

function massageUrl(url: string): string {
if (!url.includes('://') && url.includes('/')) {
return 'https://' + url;
} else {
return url;
}
}

function removeUndefinedFields(
obj: Record<string, any>
): Record<string, string> {
const result: Record<string, string> = {};
for (const key of Object.keys(obj)) {
if (is.string(obj[key])) {
result[key] = obj[key];
}
}
return result;
}
7 changes: 5 additions & 2 deletions lib/modules/datasource/bitbucket-tags/index.ts
Expand Up @@ -2,7 +2,6 @@ import { cache } from '../../../util/cache/package/decorator';
import { BitbucketHttp } from '../../../util/http/bitbucket';
import { ensureTrailingSlash } from '../../../util/url';
import type { PagedResult, RepoInfoBody } from '../../platform/bitbucket/types';
import * as utils from '../../platform/bitbucket/utils';
import { Datasource } from '../datasource';
import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
import type { BitbucketCommit, BitbucketTag } from './types';
Expand Down Expand Up @@ -56,7 +55,11 @@ export class BitbucketTagsDatasource extends Datasource {
packageName: repo,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
const url = `/2.0/repositories/${repo}/refs/tags`;
const bitbucketTags = await utils.accumulateValues(url);
const bitbucketTags = (
await this.bitbucketHttp.getJson<PagedResult<BitbucketTag>>(url, {
paginate: true,
})
).body.values;

const dependency: ReleaseResult = {
sourceUrl: BitbucketTagsDatasource.getSourceUrl(repo, registryUrl),
Expand Down
14 changes: 9 additions & 5 deletions lib/modules/platform/bitbucket/comments.ts
@@ -1,8 +1,7 @@
import { logger } from '../../../logger';
import { BitbucketHttp } from '../../../util/http/bitbucket';
import type { EnsureCommentConfig, EnsureCommentRemovalConfig } from '../types';
import type { Config } from './types';
import { accumulateValues } from './utils';
import type { Config, PagedResult } from './types';

const bitbucketHttp = new BitbucketHttp();

Expand All @@ -21,9 +20,14 @@ async function getComments(
config: CommentsConfig,
prNo: number
): Promise<Comment[]> {
const comments = await accumulateValues<Comment>(
`/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`
);
const comments = (
await bitbucketHttp.getJson<PagedResult<Comment>>(
`/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`,
{
paginate: true,
}
)
).body.values;

logger.debug(`Found ${comments.length} comments`);
return comments;
Expand Down
34 changes: 23 additions & 11 deletions lib/modules/platform/bitbucket/index.ts
Expand Up @@ -114,9 +114,14 @@ export async function initPlatform({
export async function getRepos(): Promise<string[]> {
logger.debug('Autodiscovering Bitbucket Cloud repositories');
try {
const repos = await utils.accumulateValues<{ full_name: string }>(
`/2.0/repositories/?role=contributor`
);
const repos = (
await bitbucketHttp.getJson<PagedResult<RepoInfoBody>>(
`/2.0/repositories/?role=contributor`,
{
paginate: true,
}
)
).body.values;
return repos.map((repo) => repo.full_name);
} catch (err) /* istanbul ignore next */ {
logger.error({ err }, `bitbucket getRepos error`);
Expand Down Expand Up @@ -274,7 +279,12 @@ export async function getPrList(): Promise<Pr[]> {
if (renovateUserUuid && !config.ignorePrAuthor) {
url += `&q=author.uuid="${renovateUserUuid}"`;
}
const prs = await utils.accumulateValues(url, undefined, undefined, 50);
const prs = (
await bitbucketHttp.getJson<PagedResult<PrResponse>>(url, {
paginate: true,
pagelen: 50,
})
).body.values;
config.prList = prs.map(utils.prInfo);
logger.debug(`Retrieved Pull Requests, count: ${config.prList.length}`);
}
Expand Down Expand Up @@ -365,13 +375,15 @@ async function getStatus(
memCache = true
): Promise<BitbucketStatus[]> {
const sha = await getBranchCommit(branchName);
return utils.accumulateValues<BitbucketStatus>(
// TODO: types (#7154)
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`/2.0/repositories/${config.repository}/commit/${sha}/statuses`,
'get',
{ memCache }
);
return (
await bitbucketHttp.getJson<PagedResult<BitbucketStatus>>(
`/2.0/repositories/${config.repository}/commit/${sha!}/statuses`,
{
paginate: true,
memCache,
}
)
).body.values;
}
// Returns the combined status for a branch.
export async function getBranchStatus(
Expand Down
1 change: 1 addition & 0 deletions lib/modules/platform/bitbucket/types.ts
Expand Up @@ -62,6 +62,7 @@ export interface RepoInfoBody {
mainbranch: { name: string };
has_issues: boolean;
uuid: string;
full_name: string;
}

export interface PrResponse {
Expand Down
35 changes: 0 additions & 35 deletions lib/modules/platform/bitbucket/utils.spec.ts

This file was deleted.

0 comments on commit 26c5fe1

Please sign in to comment.