Compare commits

..

6 commits

Author SHA1 Message Date
Rhys Arkins
a8fc6409ba
Merge fddeee8aaf into 141467b9b0 2025-01-01 01:10:18 +01:00
renovate[bot]
141467b9b0
fix(deps): update ghcr.io/renovatebot/base-image docker tag to v9.27.12 (#33358)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-31 23:23:23 +00:00
renovate[bot]
9917ebb8c2
chore(deps): update ghcr.io/containerbase/devcontainer docker tag to v13.5.7 (#33357)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-31 23:23:03 +00:00
renovate[bot]
bcc61a052a
fix(deps): update ghcr.io/containerbase/sidecar docker tag to v13.5.7 (#33356)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-31 19:39:11 +00:00
renovate[bot]
9d91197498
fix(deps): update ghcr.io/renovatebot/base-image docker tag to v9.27.11 (#33354)
Some checks are pending
Build / setup (push) Waiting to run
Build / setup-build (push) Waiting to run
Build / prefetch (push) Blocked by required conditions
Build / lint-eslint (push) Blocked by required conditions
Build / lint-prettier (push) Blocked by required conditions
Build / lint-docs (push) Blocked by required conditions
Build / lint-other (push) Blocked by required conditions
Build / (push) Blocked by required conditions
Build / codecov (push) Blocked by required conditions
Build / coverage-threshold (push) Blocked by required conditions
Build / test-success (push) Blocked by required conditions
Build / build (push) Blocked by required conditions
Build / build-docs (push) Blocked by required conditions
Build / test-e2e (push) Blocked by required conditions
Build / release (push) Blocked by required conditions
Code scanning / CodeQL-Build (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
whitesource-scan / WS_SCAN (push) Waiting to run
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-31 16:34:37 +00:00
Gabriel-Ladzaretti
6aa5c4238f
refactor(config): reusable env getConfig function (#33350)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-12-31 13:28:26 +00:00
5 changed files with 107 additions and 88 deletions

View file

@ -1 +1 @@
FROM ghcr.io/containerbase/devcontainer:13.5.6
FROM ghcr.io/containerbase/devcontainer:13.5.7

View file

@ -516,7 +516,7 @@ const options: RenovateOptions[] = [
description:
'Change this value to override the default Renovate sidecar image.',
type: 'string',
default: 'ghcr.io/containerbase/sidecar:13.5.6',
default: 'ghcr.io/containerbase/sidecar:13.5.7',
globalOnly: true,
},
{

View file

@ -306,7 +306,11 @@ describe('workers/global/config/parse/env', () => {
it('crashes', async () => {
const envParam: NodeJS.ProcessEnv = { RENOVATE_CONFIG: '!@#' };
await env.getConfig(envParam);
processExit.mockImplementationOnce(() => {
throw new Error('terminate function to simulate process.exit call');
});
await expect(env.getConfig(envParam)).toReject();
expect(processExit).toHaveBeenCalledWith(1);
});

View file

@ -3,6 +3,7 @@ import JSON5 from 'json5';
import { getOptions } from '../../../../config/options';
import type { AllConfig } from '../../../../config/types';
import { logger } from '../../../../logger';
import { parseJson } from '../../../../util/common';
import { coersions } from './coersions';
import type { ParseConfigOptions } from './types';
import { migrateAndValidateConfig } from './util';
@ -118,9 +119,9 @@ function massageConvertedExperimentalVars(
export async function getConfig(
inputEnv: NodeJS.ProcessEnv,
configEnvKey = 'RENOVATE_CONFIG',
): Promise<AllConfig> {
let env = inputEnv;
env = normalizePrefixes(inputEnv, inputEnv.ENV_PREFIX);
let env = normalizePrefixes(inputEnv, inputEnv.ENV_PREFIX);
env = massageConvertedExperimentalVars(env);
env = renameEnvKeys(env);
// massage the values of migrated configuration keys
@ -128,27 +129,21 @@ export async function getConfig(
const options = getOptions();
let config: AllConfig = {};
if (env.RENOVATE_CONFIG) {
try {
config = JSON5.parse(env.RENOVATE_CONFIG);
logger.debug({ config }, 'Detected config in env RENOVATE_CONFIG');
config = await migrateAndValidateConfig(config, 'RENOVATE_CONFIG');
} catch (err) {
logger.fatal({ err }, 'Could not parse RENOVATE_CONFIG');
process.exit(1);
}
}
const config = await parseAndValidateOrExit(env, configEnvKey);
config.hostRules ??= [];
options.forEach((option) => {
if (option.env !== false) {
for (const option of options) {
if (option.env === false) {
continue;
}
const envName = getEnvName(option);
const envVal = env[envName];
if (envVal) {
if (!envVal) {
continue;
}
if (option.type === 'array' && option.subType === 'object') {
try {
const parsed = JSON5.parse(envVal);
@ -171,19 +166,16 @@ export async function getConfig(
config[option.name] = coerce(envVal);
if (option.name === 'dryRun') {
if ((config[option.name] as string) === 'true') {
logger.warn(
'env config dryRun property has been changed to full',
);
logger.warn('env config dryRun property has been changed to full');
config[option.name] = 'full';
} else if ((config[option.name] as string) === 'false') {
logger.warn(
'env config dryRun property has been changed to null',
);
logger.warn('env config dryRun property has been changed to null');
delete config[option.name];
} else if ((config[option.name] as string) === 'null') {
delete config[option.name];
}
}
if (option.name === 'requireConfig') {
if ((config[option.name] as string) === 'true') {
logger.warn(
@ -197,6 +189,7 @@ export async function getConfig(
config[option.name] = 'optional';
}
}
if (option.name === 'platformCommit') {
if ((config[option.name] as string) === 'true') {
logger.warn(
@ -212,8 +205,6 @@ export async function getConfig(
}
}
}
}
});
if (env.GITHUB_COM_TOKEN) {
logger.debug(`Converting GITHUB_COM_TOKEN into a global host rule`);
@ -237,7 +228,31 @@ export async function getConfig(
'VSTS_TOKEN',
];
unsupportedEnv.forEach((val) => delete env[val]);
for (const val of unsupportedEnv) {
delete env[val];
}
return config;
}
async function parseAndValidateOrExit(
env: NodeJS.ProcessEnv,
configEnvKey: string,
): Promise<AllConfig> {
if (!env[configEnvKey]) {
return {};
}
try {
const config = parseJson(
env[configEnvKey],
`${configEnvKey}.env.json5`,
) as AllConfig;
logger.debug({ config }, `Detected config in env ${configEnvKey}`);
return await migrateAndValidateConfig(config, `${configEnvKey}`);
} catch (err) {
logger.fatal({ err }, `Could not parse ${configEnvKey}`);
process.exit(1);
}
}

View file

@ -5,19 +5,19 @@ ARG BASE_IMAGE_TYPE=slim
# --------------------------------------
# slim image
# --------------------------------------
FROM ghcr.io/renovatebot/base-image:9.27.10@sha256:bb66c6760180eca52655624f8cfb86e1581ba56ba014d788eb5edddd3fb4405f AS slim-base
FROM ghcr.io/renovatebot/base-image:9.27.12@sha256:4e40805172da37b74583f26b811aa47bde3f4e68afea511d451dad0ddc86d40a AS slim-base
# --------------------------------------
# full image
# --------------------------------------
FROM ghcr.io/renovatebot/base-image:9.27.10-full@sha256:7345a26aba660efc97621a291785e951079f3e03077a6e57b06a022a0cb22c54 AS full-base
FROM ghcr.io/renovatebot/base-image:9.27.12-full@sha256:5925cfd3e6ade0d1c7ca0b6c20be80ee055ce3d18e2d1d75b92fce1e0604f5a0 AS full-base
ENV RENOVATE_BINARY_SOURCE=global
# --------------------------------------
# build image
# --------------------------------------
FROM --platform=$BUILDPLATFORM ghcr.io/renovatebot/base-image:9.27.10@sha256:bb66c6760180eca52655624f8cfb86e1581ba56ba014d788eb5edddd3fb4405f AS build
FROM --platform=$BUILDPLATFORM ghcr.io/renovatebot/base-image:9.27.12@sha256:4e40805172da37b74583f26b811aa47bde3f4e68afea511d451dad0ddc86d40a AS build
# We want a specific node version here
# renovate: datasource=node-version