From ae30a9ae8cbedc6df69c0656bf7044d1c869db40 Mon Sep 17 00:00:00 2001 From: Andy Muldoon Date: Wed, 11 Oct 2023 12:08:54 +0100 Subject: [PATCH] Added description for publish:gerrit scaffolder actions Signed-off-by: Andy Muldoon --- .changeset/lovely-turtles-remain.md | 5 + .../builtin/publish/gerrit.examples.ts | 159 ++++++++++++++++++ .../actions/builtin/publish/gerrit.ts | 2 + 3 files changed, 166 insertions(+) create mode 100644 .changeset/lovely-turtles-remain.md create mode 100644 plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.examples.ts diff --git a/.changeset/lovely-turtles-remain.md b/.changeset/lovely-turtles-remain.md new file mode 100644 index 0000000000..711a397baa --- /dev/null +++ b/.changeset/lovely-turtles-remain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Added description for publish:gerrit scaffolder actions diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.examples.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.examples.ts new file mode 100644 index 0000000000..6729b3602f --- /dev/null +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.examples.ts @@ -0,0 +1,159 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TemplateExample } from '@backstage/plugin-scaffolder-node'; +import yaml from 'yaml'; + +export const examples: TemplateExample[] = [ + { + description: + 'Initializes a Gerrit repository of contents in workspace and publish it to Gerrit with default configuration.', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + }, + }, + ], + }), + }, + { + description: 'Initializes a Gerrit repository with a description.', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + description: 'Initialize a gerrit repository', + }, + }, + ], + }), + }, + { + description: + 'Initializes a Gerrit repository with a default Branch, if not set defaults to master', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + defaultBranch: 'staging', + }, + }, + ], + }), + }, + { + description: + 'Initializes a Gerrit repository with an initial commit message, if not set defaults to initial commit', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + gitCommitMessage: 'Initial Commit Message', + }, + }, + ], + }), + }, + { + description: + 'Initializes a Gerrit repository with a repo Author Name, if not set defaults to Scaffolder', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + gitAuthorName: 'John Doe', + }, + }, + ], + }), + }, + { + description: 'Initializes a Gerrit repository with a repo Author Email', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + gitAuthorEmail: 'johndoe@email.com', + }, + }, + ], + }), + }, + { + description: + 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + sourcePath: 'repository/', + }, + }, + ], + }), + }, + { + description: + 'Initializes a Gerrit repository with all proporties being set', + example: yaml.stringify({ + steps: [ + { + id: 'publish', + action: 'publish:gerrit', + name: 'Publish to Gerrit', + input: { + repoUrl: 'gerrit.com?repo=repo&owner=owner', + description: 'Initialize a gerrit repository', + defaultBranch: 'staging', + gitCommitMessage: 'Initial Commit Message', + gitAuthorName: 'John Doe', + gitAuthorEmail: 'johndoe@email.com', + sourcePath: 'repository/', + }, + }, + ], + }), + }, +]; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.ts index 60a0cc4aae..67ed868c4c 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gerrit.ts @@ -26,6 +26,7 @@ import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; import { getRepoSourceDirectory, parseRepoUrl } from './util'; import fetch, { Response, RequestInit } from 'node-fetch'; import { initRepoAndPush } from '../helpers'; +import { examples } from './gerrit.examples'; const createGerritProject = async ( config: GerritIntegrationConfig, @@ -98,6 +99,7 @@ export function createPublishGerritAction(options: { id: 'publish:gerrit', description: 'Initializes a git repository of the content in the workspace, and publishes it to Gerrit.', + examples, schema: { input: { type: 'object',