From 767c06ae9e7e25a07160847ee45b41f53503df5a Mon Sep 17 00:00:00 2001 From: keshan Date: Tue, 15 Dec 2020 10:01:16 +0530 Subject: [PATCH 1/3] Introduced config schema for plugins/scaffolder-backend --- plugins/scaffolder-backend/config.d.ts | 32 +++++++++++++++++++ plugins/scaffolder-backend/package.json | 6 ++-- .../scaffolder/stages/publish/publishers.ts | 6 ++-- 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 plugins/scaffolder-backend/config.d.ts diff --git a/plugins/scaffolder-backend/config.d.ts b/plugins/scaffolder-backend/config.d.ts new file mode 100644 index 0000000000..d9adc4769b --- /dev/null +++ b/plugins/scaffolder-backend/config.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2020 Spotify AB + * + * 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. + */ + +export interface Config { + /** Configuration options for the scaffolder plugin */ + scaffolder?: { + github?: { + token: string; + visibility: 'public' | 'internal' | 'private'; + }; + gitlab?: { + api: { [key: string]: string }; + }; + azure?: { + baseUrl: string; + api: { [key: string]: string }; + }; + }; +} diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index e6fc3cd87a..edf0a46a25 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -67,6 +67,8 @@ "yaml": "^1.10.0" }, "files": [ - "dist" - ] + "dist", + "config.d.ts" + ], + "configSchema": "config.d.ts" } diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts index db383aaf7f..961fc45cae 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts @@ -102,12 +102,12 @@ export class Publishers implements PublisherBuilder { } } - const gitLabConfig = config.getOptionalConfig('scaffolder.gitlab.api'); + const gitLabConfig = config.getOptionalConfig('scaffolder.gitlab'); if (gitLabConfig) { try { - const gitLabToken = gitLabConfig.getString('token'); + const gitLabToken = gitLabConfig.getConfig('api').getString('token'); const gitLabClient = new Gitlab({ - host: gitLabConfig.getOptionalString('baseUrl'), + host: gitLabConfig.getConfig('api').getOptionalString('baseUrl'), token: gitLabToken, }); const gitLabPublisher = new GitlabPublisher(gitLabClient, gitLabToken); From 94c65a9d444c45eaf86af665231911623159a452 Mon Sep 17 00:00:00 2001 From: keshan Date: Tue, 15 Dec 2020 10:08:56 +0530 Subject: [PATCH 2/3] included changeset --- .changeset/weak-sloths-prove.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/weak-sloths-prove.md diff --git a/.changeset/weak-sloths-prove.md b/.changeset/weak-sloths-prove.md new file mode 100644 index 0000000000..bfecb385c8 --- /dev/null +++ b/.changeset/weak-sloths-prove.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Added configuration schema for the commonly used properties From f3b60114e73a844f0b50f446fcd70938de5b090f Mon Sep 17 00:00:00 2001 From: keshan Date: Tue, 15 Dec 2020 11:27:14 +0530 Subject: [PATCH 3/3] updated scaffolder config.d to avoid config failure --- plugins/scaffolder-backend/config.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend/config.d.ts b/plugins/scaffolder-backend/config.d.ts index d9adc4769b..877d40ca4e 100644 --- a/plugins/scaffolder-backend/config.d.ts +++ b/plugins/scaffolder-backend/config.d.ts @@ -18,8 +18,7 @@ export interface Config { /** Configuration options for the scaffolder plugin */ scaffolder?: { github?: { - token: string; - visibility: 'public' | 'internal' | 'private'; + [key: string]: string; }; gitlab?: { api: { [key: string]: string };