Merge pull request #2429 from taras/tm/scaffold-repo-visibility

Add the ability to configure repository visibility via config
This commit is contained in:
Patrik Oldsberg
2020-09-16 16:52:22 +02:00
committed by GitHub
7 changed files with 298 additions and 134 deletions
@@ -47,6 +47,13 @@ lighthouse:
auth:
providers: {}
scaffolder:
github:
token:
$secret:
env: GITHUB_ACCESS_TOKEN
visibility: public # or 'internal' or 'private'
catalog:
locations:
# Backstage example components
@@ -7,12 +7,16 @@ import {
GithubPublisher,
CreateReactAppTemplater,
Templaters,
RepoVisilityOptions,
} from '@backstage/plugin-scaffolder-backend';
import { Octokit } from '@octokit/rest';
import type { PluginEnvironment } from '../types';
import Docker from 'dockerode';
export default async function createPlugin({ logger }: PluginEnvironment) {
export default async function createPlugin({
logger,
config,
}: PluginEnvironment) {
const cookiecutterTemplater = new CookieCutter();
const craTemplater = new CreateReactAppTemplater();
const templaters = new Templaters();
@@ -26,8 +30,17 @@ export default async function createPlugin({ logger }: PluginEnvironment) {
preparers.register('file', filePreparer);
preparers.register('github', githubPreparer);
const githubClient = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN });
const publisher = new GithubPublisher({ client: githubClient });
const githubToken = config.getString('scaffolder.github.token');
const repoVisibility = config.getString(
'scaffolder.github.visibility',
) as RepoVisilityOptions;
const githubClient = new Octokit({ auth: githubToken });
const publisher = new GithubPublisher({
client: githubClient,
token: githubToken,
repoVisibility,
});
const dockerClient = new Docker();
return await createRouter({