2021-04-20 08:52:57 +00:00
|
|
|
import type { RenovateConfig } from '../../config/types';
|
2022-05-11 05:52:33 +00:00
|
|
|
|
2020-01-12 07:50:11 +00:00
|
|
|
import {
|
2020-09-12 05:28:12 +00:00
|
|
|
CONFIG_SECRETS_EXPOSED,
|
|
|
|
CONFIG_VALIDATION,
|
2023-05-18 17:02:13 +00:00
|
|
|
MISSING_API_CREDENTIALS,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_ACCESS_FORBIDDEN,
|
|
|
|
REPOSITORY_ARCHIVED,
|
|
|
|
REPOSITORY_BLOCKED,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_CLOSED_ONBOARDING,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_DISABLED,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_DISABLED_BY_CONFIG,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_EMPTY,
|
|
|
|
REPOSITORY_FORKED,
|
2024-03-02 07:16:07 +00:00
|
|
|
REPOSITORY_FORK_MODE_FORKED,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_MIRRORED,
|
2021-01-19 22:07:12 +00:00
|
|
|
REPOSITORY_NOT_FOUND,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_NO_CONFIG,
|
|
|
|
REPOSITORY_NO_PACKAGE_FILES,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_RENAMED,
|
|
|
|
REPOSITORY_UNINITIATED,
|
|
|
|
} from '../../constants/error-messages';
|
2020-09-12 05:28:12 +00:00
|
|
|
import { logger } from '../../logger';
|
2018-05-07 04:33:49 +00:00
|
|
|
|
2022-05-11 05:52:33 +00:00
|
|
|
export type ProcessStatus =
|
|
|
|
| 'disabled'
|
|
|
|
| 'onboarded'
|
|
|
|
| 'activated'
|
|
|
|
| 'onboarding'
|
|
|
|
| 'unknown';
|
|
|
|
|
2020-01-10 10:35:49 +00:00
|
|
|
export interface ProcessResult {
|
|
|
|
res: string;
|
|
|
|
status: ProcessStatus;
|
2022-02-11 10:02:30 +00:00
|
|
|
enabled: boolean | undefined;
|
|
|
|
onboarded: boolean | undefined;
|
2020-01-10 10:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function processResult(
|
|
|
|
config: RenovateConfig,
|
2023-11-07 15:50:29 +00:00
|
|
|
res: string,
|
2020-01-10 10:35:49 +00:00
|
|
|
): ProcessResult {
|
2018-05-07 04:33:49 +00:00
|
|
|
const disabledStatuses = [
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_ACCESS_FORBIDDEN,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_ARCHIVED,
|
|
|
|
REPOSITORY_BLOCKED,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_CLOSED_ONBOARDING,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_DISABLED,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_DISABLED_BY_CONFIG,
|
|
|
|
REPOSITORY_EMPTY,
|
2024-03-02 07:16:07 +00:00
|
|
|
REPOSITORY_FORK_MODE_FORKED,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_FORKED,
|
|
|
|
REPOSITORY_MIRRORED,
|
2021-02-11 12:32:29 +00:00
|
|
|
REPOSITORY_NOT_FOUND,
|
|
|
|
REPOSITORY_NO_CONFIG,
|
|
|
|
REPOSITORY_NO_PACKAGE_FILES,
|
2020-01-12 07:50:11 +00:00
|
|
|
REPOSITORY_RENAMED,
|
|
|
|
REPOSITORY_UNINITIATED,
|
2018-05-07 04:33:49 +00:00
|
|
|
];
|
2023-05-18 17:02:13 +00:00
|
|
|
const enabledStatuses = [
|
|
|
|
CONFIG_SECRETS_EXPOSED,
|
|
|
|
CONFIG_VALIDATION,
|
|
|
|
MISSING_API_CREDENTIALS,
|
|
|
|
];
|
2020-01-10 10:35:49 +00:00
|
|
|
let status: ProcessStatus;
|
2022-02-11 10:02:30 +00:00
|
|
|
let enabled: boolean | undefined;
|
|
|
|
let onboarded: boolean | undefined;
|
2018-05-07 04:33:49 +00:00
|
|
|
// istanbul ignore next
|
|
|
|
if (disabledStatuses.includes(res)) {
|
|
|
|
status = 'disabled';
|
2020-10-14 14:20:02 +00:00
|
|
|
enabled = false;
|
2022-05-11 05:52:33 +00:00
|
|
|
} else if (config.repoIsActivated) {
|
|
|
|
status = 'activated';
|
|
|
|
enabled = true;
|
|
|
|
onboarded = true;
|
2020-09-12 05:28:12 +00:00
|
|
|
} else if (enabledStatuses.includes(res) || config.repoIsOnboarded) {
|
2022-05-11 05:52:33 +00:00
|
|
|
status = 'onboarded';
|
2020-10-14 14:20:02 +00:00
|
|
|
enabled = true;
|
|
|
|
onboarded = true;
|
2018-07-19 06:54:15 +00:00
|
|
|
} else if (config.repoIsOnboarded === false) {
|
2018-05-07 04:33:49 +00:00
|
|
|
status = 'onboarding';
|
2020-10-14 14:20:02 +00:00
|
|
|
enabled = true;
|
|
|
|
onboarded = false;
|
2018-07-19 06:54:15 +00:00
|
|
|
} else {
|
2022-11-07 11:29:02 +00:00
|
|
|
logger.debug(`Unknown res: ${res}`);
|
2018-07-19 06:54:15 +00:00
|
|
|
status = 'unknown';
|
2018-05-07 04:33:49 +00:00
|
|
|
}
|
2022-05-11 05:52:33 +00:00
|
|
|
logger.debug(
|
2023-08-15 09:31:15 +00:00
|
|
|
// TODO: types (#22198)
|
2023-11-07 15:50:29 +00:00
|
|
|
`Repository result: ${res}, status: ${status}, enabled: ${enabled!}, onboarded: ${onboarded!}`,
|
2022-05-11 05:52:33 +00:00
|
|
|
);
|
2022-07-26 08:32:12 +00:00
|
|
|
return { res, status, enabled, onboarded };
|
2018-05-07 04:33:49 +00:00
|
|
|
}
|