Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config/self-hosted): userAgent #28737

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,11 @@ For example: `:warning:` will be replaced with `⚠️`.
Some cloud providers offer services to receive metadata about the current instance, for example [AWS Instance metadata](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html) or [GCP VM metadata](https://cloud.google.com/compute/docs/metadata/overview).
You can control if Renovate should try to access these services with the `useCloudMetadataServices` config option.

## userAgent

If set to any string, Renovate will use this as the `user-agent` it sends with HTTP requests.
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
Otherwise, it will default to `RenovateBot/${renovateVersion} (https://github.com/renovatebot/renovate)`.

## username

You may need to set a `username` if you:
Expand Down
4 changes: 0 additions & 4 deletions docs/usage/self-hosted-experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ Skipping the check will speed things up, but may result in versions being return

If set to any value, Renovate will always paginate requests to GitHub fully, instead of stopping after 10 pages.

## `RENOVATE_USER_AGENT`

If set to any string, Renovate will use this as the `user-agent` it sends with HTTP requests.

## `RENOVATE_X_AUTODISCOVER_REPO_ORDER`

<!-- prettier-ignore -->
Expand Down
1 change: 1 addition & 0 deletions lib/config/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class GlobalConfig {
'platform',
'endpoint',
'httpCacheTtlDays',
'userAgent',
];

private static config: RepoGlobalConfig = {};
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 @@ -47,6 +47,14 @@ const options: RenovateOptions[] = [
default: true,
globalOnly: true,
},
{
name: 'userAgent',
description:
'If set to any string, Renovate will use this as the `user-agent` it sends with HTTP requests.',
type: 'string',
default: null,
globalOnly: true,
},
{
name: 'allowPostUpgradeCommandTemplating',
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 @@ -159,6 +159,7 @@ export interface RepoGlobalConfig {
privateKey?: string;
privateKeyOld?: string;
httpCacheTtlDays?: number;
userAgent?: string;
}

export interface LegacyAdminConfig {
Expand Down
3 changes: 2 additions & 1 deletion lib/util/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import merge from 'deepmerge';
import got, { Options, RequestError } from 'got';
import type { SetRequired } from 'type-fest';
import { infer as Infer, type ZodError, ZodType } from 'zod';
import { GlobalConfig } from '../../config/global';
import { HOST_DISABLED } from '../../constants/error-messages';
import { pkg } from '../../expose.cjs';
import { logger } from '../../logger';
Expand Down Expand Up @@ -50,7 +51,7 @@ function applyDefaultHeaders(options: Options): void {
options.headers = {
...options.headers,
'user-agent':
process.env.RENOVATE_USER_AGENT ??
GlobalConfig.get('userAgent') ??
`RenovateBot/${renovateVersion} (https://github.com/renovatebot/renovate)`,
};
}
Expand Down