From 1cb1919f0c922d8d1e2675cb768fff16bfd1937a Mon Sep 17 00:00:00 2001 From: David Tuite Date: Tue, 15 Sep 2020 10:49:27 +0100 Subject: [PATCH 1/2] Send component description to GitHub We might as well set the description on the GitHub repo while we're creating it. --- .../src/scaffolder/stages/publish/github.test.ts | 2 ++ .../scaffolder-backend/src/scaffolder/stages/publish/github.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.test.ts index c06a553771..e68b0d0447 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.test.ts @@ -147,6 +147,7 @@ describe('GitHub Publisher', () => { storePath: 'blam/test', owner: 'bob', access: 'bob', + description: 'description', }, directory: '/tmp/test', }); @@ -154,6 +155,7 @@ describe('GitHub Publisher', () => { expect( mockGithubClient.repos.createForAuthenticatedUser, ).toHaveBeenCalledWith({ + description: 'description', name: 'test', private: false, }); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts index 1d5c9e1947..d3aafb1e07 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts @@ -61,6 +61,7 @@ export class GithubPublisher implements PublisherBase { values: RequiredTemplateValues & Record, ) { const [owner, name] = values.storePath.split('/'); + const description = values.description as string; const user = await this.client.users.getByUsername({ username: owner }); @@ -71,10 +72,12 @@ export class GithubPublisher implements PublisherBase { org: owner, private: this.repoVisibility !== 'public', visibility: this.repoVisibility, + description, }) : this.client.repos.createForAuthenticatedUser({ name, private: this.repoVisibility === 'private', + description, }); const { data } = await repoCreationPromise; From 2e35f300d0263ff22694ea21e512be75d0a7262c Mon Sep 17 00:00:00 2001 From: David Tuite Date: Tue, 15 Sep 2020 10:56:42 +0100 Subject: [PATCH 2/2] Mark docs template description as required In my testing, attempts to create a docs site with no description would fail with the error: ``` Unable to create file 'component-info.yaml' Error message: 'collections.OrderedDict object' has no attribute 'description' ``` Better to mark it required than let the user hit the error. --- .../sample-templates/docs-template/template.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml b/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml index b4bd45d163..31b57135ad 100644 --- a/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml @@ -17,6 +17,7 @@ spec: schema: required: - component_id + - description properties: component_id: title: Name