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 diff --git a/plugins/scaffolder-backend/config.d.ts b/plugins/scaffolder-backend/config.d.ts new file mode 100644 index 0000000000..877d40ca4e --- /dev/null +++ b/plugins/scaffolder-backend/config.d.ts @@ -0,0 +1,31 @@ +/* + * 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?: { + [key: string]: string; + }; + 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);