Skip to content

Commit

Permalink
feat(self-hosted): convert experimental vars to config options (#29137)
Browse files Browse the repository at this point in the history
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
  • Loading branch information
RahulGautamSingh and HonkingGoose authored Aug 19, 2024
1 parent 26a1e3d commit 8ec8391
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 11 deletions.
7 changes: 7 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,13 @@ For example, `{"dockerCliOptions": "--memory=4g"}` will add a CLI flag to the `d

Read the [Docker Docs, configure runtime resource constraints](https://docs.docker.com/config/containers/resource_constraints/) to learn more.

## dockerMaxPages

By default, Renovate will fetch a maximum of 20 pages when looking up Docker tags on Docker registries.

If set to an positive integer, Renovate will use this value as the maximum page number.
Setting a different limit is useful for registries that ignore the `n` parameter in Renovate's query string and thus only return 50 tags per page.

## dockerSidecarImage

By default Renovate pulls the sidecar Docker containers from `ghcr.io/containerbase/sidecar`.
Expand Down
5 changes: 0 additions & 5 deletions docs/usage/self-hosted-experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ This includes the following:

If set to any value, Renovate will stop using the Docker Hub API (`https://hub.docker.com`) to fetch tags and instead use the normal Docker API for images pulled from `https://index.docker.io`.

## `RENOVATE_X_DOCKER_MAX_PAGES`

If set to an integer, Renovate will use this as max page number for docker tags lookup on docker registries, instead of the default 20 pages.
This is useful for registries which ignores the `n` parameter in the query string and only return 50 tags per page.

## `RENOVATE_X_EXEC_GPID_HANDLE`

If set, Renovate will terminate the whole process group of a terminated child process spawned by Renovate.
Expand Down
1 change: 1 addition & 0 deletions lib/config/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class GlobalConfig {
'autodiscoverRepoSort',
'autodiscoverRepoOrder',
'userAgent',
'dockerMaxPages',
's3Endpoint',
's3PathStyle',
'cachePrivatePackages',
Expand Down
8 changes: 8 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,14 @@ const options: RenovateOptions[] = [
default: 90,
globalOnly: true,
},
{
name: 'dockerMaxPages',
description:
'By default, Renovate fetches up to 20 pages of Docker tags from registries. But you can set your own limit with this config option.',
type: 'integer',
default: 20,
globalOnly: true,
},
{
name: 'deleteConfigFile',
description:
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export interface RepoGlobalConfig {
autodiscoverRepoSort?: RepoSortMethod;
autodiscoverRepoOrder?: SortMethod;
userAgent?: string;
dockerMaxPages?: number;
s3Endpoint?: string;
s3PathStyle?: boolean;
cachePrivatePackages?: boolean;
Expand Down
5 changes: 3 additions & 2 deletions lib/modules/datasource/docker/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getDigest, getPkgReleases } from '..';
import { range } from '../../../../lib/util/range';
import * as httpMock from '../../../../test/http-mock';
import { logger, mocked } from '../../../../test/util';
import { GlobalConfig } from '../../../config/global';
import { EXTERNAL_HOST_ERROR } from '../../../constants/error-messages';
import * as _hostRules from '../../../util/host-rules';
import { DockerDatasource } from '.';
Expand Down Expand Up @@ -38,13 +39,13 @@ function mockEcrAuthReject(msg: string) {

describe('modules/datasource/docker/index', () => {
beforeEach(() => {
GlobalConfig.reset();
ecrMock.reset();
hostRules.find.mockReturnValue({
username: 'some-username',
password: 'some-password',
});
hostRules.hosts.mockReturnValue([]);
delete process.env.RENOVATE_X_DOCKER_MAX_PAGES;
delete process.env.RENOVATE_X_DOCKER_HUB_TAGS_DISABLE;
});

Expand Down Expand Up @@ -1372,8 +1373,8 @@ describe('modules/datasource/docker/index', () => {
});

it('uses custom max pages', async () => {
GlobalConfig.set({ dockerMaxPages: 2 });
process.env.RENOVATE_X_DOCKER_HUB_TAGS_DISABLE = 'true';
process.env.RENOVATE_X_DOCKER_MAX_PAGES = '2';
httpMock
.scope(baseUrl)
.get('/library/node/tags/list?n=10000')
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/datasource/docker/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import is from '@sindresorhus/is';
import { GlobalConfig } from '../../../config/global';
import { PAGE_NOT_FOUND_ERROR } from '../../../constants/error-messages';
import { logger } from '../../../logger';
import { ExternalHostError } from '../../../types/errors/external-host-error';
Expand Down Expand Up @@ -665,9 +666,7 @@ export class DockerDatasource extends Datasource {
return null;
}
let page = 0;
const pages = process.env.RENOVATE_X_DOCKER_MAX_PAGES
? parseInt(process.env.RENOVATE_X_DOCKER_MAX_PAGES, 10)
: 20;
const pages = GlobalConfig.get('dockerMaxPages', 20);
let foundMaxResultsError = false;
do {
let res: HttpResponse<{ tags: string[] }>;
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/config/parse/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ describe('workers/global/config/parse/env', () => {
RENOVATE_X_S3_PATH_STYLE: 'true',
};
const config = await env.getConfig(envParam);
expect(config.dockerMaxPages).toBeUndefined();
expect(config).toMatchObject({
mergeConfidenceEndpoint: 'some-url',
mergeConfidenceDatasources: ['docker'],
autodiscoverRepoSort: 'alpha',
autodiscoverRepoOrder: 'desc',
dockerMaxPages: 10,
deleteConfigFile: true,
s3Endpoint: 'endpoint',
s3PathStyle: true,
Expand Down
2 changes: 2 additions & 0 deletions lib/workers/global/config/parse/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ function massageEnvKeyValues(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
return result;
}

// these experimental env vars have been converted into self-hosted config options
const convertedExperimentalEnvVars = [
'RENOVATE_X_AUTODISCOVER_REPO_SORT',
'RENOVATE_X_AUTODISCOVER_REPO_ORDER',
'RENOVATE_X_DOCKER_MAX_PAGES',
'RENOVATE_X_DELETE_CONFIG_FILE',
'RENOVATE_X_S3_ENDPOINT',
'RENOVATE_X_S3_PATH_STYLE',
Expand Down

0 comments on commit 8ec8391

Please sign in to comment.