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(manager/copier): Implement manager #29215

Merged
merged 11 commits into from
Aug 6, 2024
34 changes: 34 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,40 @@ When using with `npm`, we recommend you:
- Use `constraintsFiltering` on `dependencies`, not `devDependencies` (usually you do not need to be strict about development dependencies)
- Do _not_ enable `rollbackPrs` at the same time (otherwise your _current_ version may be rolled back if it's incompatible)

## copierOptions

Configure how the `copier` manager invokes the CLI tool.

The `copierOptions` configuration consists of six fields:

### recopy

By default, the manager uses `copier update --skip-answered --defaults` to update a templated project.
Merge conflicts are warned about, but still result in a PR.
This switch instructs the manager to use `copier recopy --skip-answered --defaults --overwrite` instead, which disables the smart update algorithm and overwrites any customizations.

### skipTasks

Instruct Copier to skip template tasks execution.
Mind that they are only executed if the admin has enabled `copierTrust` in the self-hosted configuration.

### data

A mapping of arbitrary template variable names to their (string) values to pass to Copier.

### dataFile

The relative path of a YAML file to load Copier template variables from.
Must be part of the repository.

### skip

An array of paths (globs) to skip updates from the Copier template on if they exist already in the respository.

### exclude

An array of paths (globs) that should not be copied from the Copier template.

## customDatasources

Use `customDatasources` to fetch releases from APIs or statically hosted sites and Renovate has no own datasource.
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ This directory is used to cache downloads when `binarySource=docker` or `binaryS

Use this option if you need such downloads to be stored outside of Renovate's regular cache directory (`cacheDir`).

## copierTrust

When using the `copier` manager, whether to instruct it to allow templates with unsafe features (Jinja extensions, migrations, tasks).

## customEnvVariables

This configuration will be applied after all other environment variables so you can use it to override defaults.
Expand Down
72 changes: 72 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3088,6 +3088,78 @@ const options: RenovateOptions[] = [
default: 90,
globalOnly: true,
},
{
name: 'copierOptions',
description:
'Configure how Copier is invoked. Unsafe features (--trust) can only be enabled in the self-hosted configuration.',
type: 'object',
default: {
recopy: false,
skipTasks: false,
data: {},
dataFile: '',
skip: [],
exclude: [],
},
},
{
name: 'recopy',
description:
'Request Copier to recopy a template instead of using the smart update algorithm.',
parents: ['copierOptions'],
type: 'boolean',
default: false,
},
{
name: 'skipTasks',
description: 'Skip Copier template tasks execution.',
parents: ['copierOptions'],
type: 'boolean',
default: false,
},
{
name: 'data',
description: 'Pass arbitrary Copier template variables with their values.',
parents: ['copierOptions'],
type: 'object',
freeChoice: true,
mergeable: true,
default: {},
},
{
name: 'dataFile',
description:
'An optional relative path of a YAML file to load Copier template variables from.',
parents: ['copierOptions'],
type: 'string',
default: '',
},
{
name: 'skip',
description:
'An array of paths/globs to skip during Copier template rendering if they exist already.',
parents: ['copierOptions'],
type: 'array',
subType: 'string',
default: [],
},
{
name: 'exclude',
description:
'An array of paths/globs that should never be copied during Copier template rendering.',
parents: ['copierOptions'],
type: 'array',
subType: 'string',
default: [],
},
{
name: 'copierTrust',
description:
'Allow templates with unsafe features (Jinja extensions, migrations, tasks).',
type: 'boolean',
default: false,
globalOnly: true,
},
];

export function getOptions(): RenovateOptions[] {
Expand Down
14 changes: 13 additions & 1 deletion lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export interface RepoGlobalConfig {
cacheHardTtlMinutes?: number;
cacheTtlOverride?: Record<string, number>;
containerbaseDir?: string;
copierTrust?: boolean;
customEnvVariables?: Record<string, string>;
dockerChildPrefix?: string;
dockerCliOptions?: string;
Expand Down Expand Up @@ -266,6 +267,7 @@ export interface RenovateConfig
prConcurrentLimit?: number;
prHourlyLimit?: number;
forkModeDisallowMaintainerEdits?: boolean;
copierOptions?: CopierOptions;

defaultRegistryUrls?: string[];
registryUrls?: string[] | null;
Expand Down Expand Up @@ -401,7 +403,8 @@ export type AllowedParents =
| 'hostRules'
| 'postUpgradeTasks'
| 'packageRules'
| 'logLevelRemap';
| 'logLevelRemap'
| 'copierOptions';
export interface RenovateOptionBase {
/**
* If true, the option can only be configured by people with access to the Renovate instance.
Expand Down Expand Up @@ -577,3 +580,12 @@ export interface ValidationResult {
errors: ValidationMessage[];
warnings: ValidationMessage[];
}

export interface CopierOptions extends Record<string, any> {
recopy?: boolean;
skipTasks?: boolean;
data?: Record<string, string>;
dataFile?: string;
skip?: string[];
exclude?: string[];
}
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as cloudbuild from './cloudbuild';
import * as cocoapods from './cocoapods';
import * as composer from './composer';
import * as conan from './conan';
import * as copier from './copier';
import * as cpanfile from './cpanfile';
import * as crossplane from './crossplane';
import * as depsEdn from './deps-edn';
Expand Down Expand Up @@ -117,6 +118,7 @@ api.set('cloudbuild', cloudbuild);
api.set('cocoapods', cocoapods);
api.set('composer', composer);
api.set('conan', conan);
api.set('copier', copier);
api.set('cpanfile', cpanfile);
api.set('crossplane', crossplane);
api.set('deps-edn', depsEdn);
Expand Down
Loading