Skip to content

Commit

Permalink
chore: add tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Jan 9, 2024
1 parent 7eb6b12 commit 9fa8199
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,12 @@ This is currently applicable to `npm` only, and only used in cases where bugs in
If enabled emoji shortcodes are replaced with their Unicode equivalents.
For example: `:warning:` will be replaced with `⚠️`.

## useCloudMetadataServices

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).
Use this option to control whether Renovate should try to access these services.

## username

You may need to set a `username` if you:
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 @@ -21,6 +21,14 @@ const options: RenovateOptions[] = [
default: false,
globalOnly: true,
},
{
name: 'useCloudMetadataServices',
description:
'If `false`, Renovate does not try to access cloud metadata services.',
type: 'boolean',
default: true,
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 @@ -116,6 +116,7 @@ export interface GlobalOnlyConfig {
repositories?: RenovateRepository[];
platform?: PlatformId;
endpoint?: string;
useCloudMetadataServices?: boolean;
}

// Config options used within the repository worker, but not user configurable
Expand Down
23 changes: 23 additions & 0 deletions lib/workers/global/initialize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,27 @@ describe('workers/global/initialize', () => {
await expect(globalInitialize(config)).toResolve();
});
});

describe('configureThirdPartyLibraries()', () => {
beforeEach(() => {
delete process.env.AWS_EC2_METADATA_DISABLED;
delete process.env.METADATA_SERVER_DETECTION;
});

it('sets env vars when cloud metadata services disabled', async () => {
const config: RenovateConfig = { useCloudMetadataServices: false };
git.validateGitVersion.mockResolvedValueOnce(true);
await expect(globalInitialize(config)).toResolve();
expect(process.env.AWS_EC2_METADATA_DISABLED).toBe('true');
expect(process.env.METADATA_SERVER_DETECTION).toBe('none');
});

it('does not set env vars when cloud metadata services enabled', async () => {
const config: RenovateConfig = { useCloudMetadataServices: true };
git.validateGitVersion.mockResolvedValueOnce(true);
await expect(globalInitialize(config)).toResolve();
expect(process.env.AWS_EC2_METADATA_DISABLED).toBeUndefined();
expect(process.env.METADATA_SERVER_DETECTION).toBeUndefined();
});
});
});

0 comments on commit 9fa8199

Please sign in to comment.