feat: created new output parameter
Signed-off-by: Alisson Fabiano <afabiano@eshopworld.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': minor
|
||||
---
|
||||
|
||||
Added repositoryId return when creating a repository in Azure
|
||||
|
||||
```diff
|
||||
output: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
remoteUrl: {
|
||||
title: 'A URL to the repository with the provider',
|
||||
type: 'string',
|
||||
},
|
||||
repoContentsUrl: {
|
||||
title: 'A URL to the root of the repository',
|
||||
type: 'string',
|
||||
},
|
||||
+ repositoryId: {
|
||||
+ title: 'The Id of the created repository',
|
||||
+ type: 'string',
|
||||
+ },
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
const remoteUrl = returnedRepo.remoteUrl;
|
||||
|
||||
if (!remoteUrl) {
|
||||
throw new InputError(
|
||||
'No remote URL returned from create repository for Azure',
|
||||
);
|
||||
}
|
||||
+const repositoryId = returnedRepo.id;
|
||||
|
||||
+if (!repositoryId) {
|
||||
+ throw new InputError('No Id returned from create repository for Azure');
|
||||
+}
|
||||
|
||||
|
||||
ctx.output('remoteUrl', remoteUrl);
|
||||
ctx.output('repoContentsUrl', repoContentsUrl);
|
||||
+ctx.output('repositoryId', repositoryId);
|
||||
```
|
||||
@@ -159,6 +159,21 @@ describe('publish:azure', () => {
|
||||
).rejects.toThrow(/No remote URL returned/);
|
||||
});
|
||||
|
||||
it('should throw if there is no repositoryId returned', async () => {
|
||||
mockGitClient.createRepository.mockImplementation(() => ({
|
||||
remoteUrl: 'http://google.com',
|
||||
id: null,
|
||||
}));
|
||||
await expect(
|
||||
action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
repoUrl: 'dev.azure.com?repo=bob&owner=owner&organization=org',
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow(/No Id returned/);
|
||||
});
|
||||
|
||||
it('should call the azureApis with the correct values', async () => {
|
||||
mockGitClient.createRepository.mockImplementation(() => ({
|
||||
remoteUrl: 'http://google.com',
|
||||
@@ -298,9 +313,10 @@ describe('publish:azure', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should call output with the remoteUrl and the repoContentsUrl', async () => {
|
||||
it('should call output with the remoteUrl the repoContentsUrl and the repositoryId', async () => {
|
||||
mockGitClient.createRepository.mockImplementation(() => ({
|
||||
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
|
||||
id: '709e891c-dee7-4f91-b963-534713c0737f',
|
||||
}));
|
||||
|
||||
await action.handler(mockContext);
|
||||
@@ -313,5 +329,9 @@ describe('publish:azure', () => {
|
||||
'repoContentsUrl',
|
||||
'https://dev.azure.com/organization/project/_git/repo',
|
||||
);
|
||||
expect(mockContext.output).toHaveBeenCalledWith(
|
||||
'repositoryId',
|
||||
'709e891c-dee7-4f91-b963-534713c0737f',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,6 +44,7 @@ export function createPublishAzureAction(options: {
|
||||
gitAuthorName?: string;
|
||||
gitAuthorEmail?: string;
|
||||
}>({
|
||||
supportsDryRun: true,
|
||||
id: 'publish:azure',
|
||||
description:
|
||||
'Initializes a git repository of the content in the workspace, and publishes it to Azure.',
|
||||
@@ -104,6 +105,10 @@ export function createPublishAzureAction(options: {
|
||||
title: 'A URL to the root of the repository',
|
||||
type: 'string',
|
||||
},
|
||||
repositoryId: {
|
||||
title: 'The Id of the created repository',
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -160,6 +165,11 @@ export function createPublishAzureAction(options: {
|
||||
'No remote URL returned from create repository for Azure',
|
||||
);
|
||||
}
|
||||
const repositoryId = returnedRepo.id;
|
||||
|
||||
if (!repositoryId) {
|
||||
throw new InputError('No Id returned from create repository for Azure');
|
||||
}
|
||||
|
||||
// blam: Repo contents is serialized into the path,
|
||||
// so it's just the base path I think
|
||||
@@ -191,6 +201,7 @@ export function createPublishAzureAction(options: {
|
||||
|
||||
ctx.output('remoteUrl', remoteUrl);
|
||||
ctx.output('repoContentsUrl', repoContentsUrl);
|
||||
ctx.output('repositoryId', repositoryId);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user