add entityMetadata to scaffolder templateInfo field

Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
Paul Cowan
2022-08-22 16:34:50 +01:00
parent 8436d52ff3
commit 1ff817b3f0
9 changed files with 36 additions and 3 deletions
+8
View File
@@ -0,0 +1,8 @@
---
'@backstage/plugin-scaffolder-backend': minor
'@backstage/plugin-scaffolder-backend-module-cookiecutter': minor
'@backstage/plugin-scaffolder-backend-module-rails': minor
'@backstage/plugin-scaffolder-common': minor
---
add entityMetadata to the scaffolder templateInfo field
@@ -92,6 +92,9 @@ describe('fetch:cookiecutter', () => {
templateInfo: {
entityRef: 'template:default/cookiecutter',
baseUrl: 'somebase',
entityMetadata: {
name: 'cookiecutter',
},
},
workspacePath: mockTmpDir,
logger: getVoidLogger(),
@@ -65,6 +65,9 @@ describe('fetch:rails', () => {
templateInfo: {
baseUrl: 'somebase',
entityRef: 'template:default/myTemplate',
entityMetadata: {
name: 'myTemplate',
},
},
workspacePath: mockTmpDir,
logger: getVoidLogger(),
@@ -78,6 +78,9 @@ describe('fetch:template', () => {
templateInfo: {
baseUrl: 'base-url',
entityRef: 'template:default/test-template',
entityMetadata: {
name: 'test-template',
},
},
input: {
url: './skeleton',
@@ -106,6 +106,9 @@ export function createDryRunner(options: TemplateTesterCreateOptions) {
baseUrl: pathToFileURL(
resolveSafeChildPath(contentsPath, 'template.yaml'),
).toString(),
entityMetadata: {
name: 'dry-run',
},
},
},
secrets: input.secrets,
@@ -181,13 +181,21 @@ describe('DefaultWorkflowRunner', () => {
input: { foo: 1 },
},
],
templateInfo: { entityRef },
templateInfo: {
entityRef,
entityMetadata: {
name: 'templateName',
},
},
});
await runner.execute(task);
expect(fakeActionHandler.mock.calls[0][0].templateInfo).toEqual({
entityRef,
entityMetadata: {
name: 'templateName',
},
});
});
@@ -261,6 +261,7 @@ describe('createRouter', () => {
name: mockTemplate.metadata?.name,
}),
baseUrl: 'https://dev.azure.com',
entityMetadata: mockTemplate.metadata,
},
},
}),
@@ -312,6 +313,7 @@ describe('createRouter', () => {
name: mockTemplate.metadata?.name,
}),
baseUrl: 'https://dev.azure.com',
entityMetadata: mockTemplate.metadata,
},
},
}),
@@ -249,6 +249,7 @@ export async function createRouter(
name: template.metadata?.name,
}),
baseUrl,
entityMetadata: template.metadata,
},
};
+4 -2
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { UserEntity } from '@backstage/catalog-model';
import { JsonValue, JsonObject } from '@backstage/types';
import type { EntityMeta, UserEntity } from '@backstage/catalog-model';
import type { JsonValue, JsonObject } from '@backstage/types';
/**
* Information about a template that is stored on a task specification.
@@ -32,6 +32,8 @@ export type TemplateInfo = {
* Where the template is stored, so we can resolve relative paths for things like `fetch:template` paths.
*/
baseUrl?: string;
entityMetadata: EntityMeta;
};
/**