Allow overriding cookiecutter's docker imageName
.. to allow running custom-built images that have cookiecutter installed alongwith extensions, for example. https://cookiecutter.readthedocs.io/en/1.7.2/advanced/template_extensions.html related to: https://github.com/backstage/backstage/pull/4956#discussion_r596846365 Signed-off-by: Vinay P <mail@vinayvinay.com>
This commit is contained in:
@@ -117,6 +117,7 @@ describe('fetch:cookiecutter', () => {
|
||||
extensions: [
|
||||
'jinja2_custom_filters_extension.string_filters_extension.StringFilterExtension',
|
||||
],
|
||||
imageName: 'foo/cookiecutter-image-with-extensions',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -130,6 +131,7 @@ describe('fetch:cookiecutter', () => {
|
||||
_extensions: [
|
||||
'jinja2_custom_filters_extension.string_filters_extension.StringFilterExtension',
|
||||
],
|
||||
imageName: 'foo/cookiecutter-image-with-extensions',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,6 +39,7 @@ export function createFetchCookiecutterAction(options: {
|
||||
values: JsonObject;
|
||||
copyWithoutRender?: string[];
|
||||
extensions?: string[];
|
||||
imageName?: string;
|
||||
}>({
|
||||
id: 'fetch:cookiecutter',
|
||||
description:
|
||||
@@ -83,6 +84,12 @@ export function createFetchCookiecutterAction(options: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
imageName: {
|
||||
title: 'Cookiecutter Docker image',
|
||||
description:
|
||||
"Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found.",
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -121,6 +128,7 @@ export function createFetchCookiecutterAction(options: {
|
||||
...(ctx.input.values as TemplaterValues),
|
||||
_copy_without_render: ctx.input.copyWithoutRender,
|
||||
_extensions: ctx.input.extensions,
|
||||
imageName: ctx.input.imageName,
|
||||
};
|
||||
|
||||
// Will execute the template in ./template and put the result in ./result
|
||||
|
||||
@@ -52,9 +52,10 @@ export class CookieCutter implements TemplaterBase {
|
||||
// First lets grab the default cookiecutter.json file
|
||||
const cookieCutterJson = await this.fetchTemplateCookieCutter(templateDir);
|
||||
|
||||
const { imageName, ...valuesForCookieCutterJson } = values;
|
||||
const cookieInfo = {
|
||||
...cookieCutterJson,
|
||||
...values,
|
||||
...valuesForCookieCutterJson,
|
||||
};
|
||||
|
||||
await fs.writeJSON(path.join(templateDir, 'cookiecutter.json'), cookieInfo);
|
||||
@@ -74,7 +75,7 @@ export class CookieCutter implements TemplaterBase {
|
||||
});
|
||||
} else {
|
||||
await runDockerContainer({
|
||||
imageName: 'spotify/backstage-cookiecutter',
|
||||
imageName: imageName || 'spotify/backstage-cookiecutter',
|
||||
args: [
|
||||
'cookiecutter',
|
||||
'--no-input',
|
||||
|
||||
Reference in New Issue
Block a user