From 3d01cca9d54afe7e22ba4f2082bfa81ad8c2d984 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 19 Jan 2021 19:17:58 +0100 Subject: [PATCH] chore: remove dead code now that's a needless check for the protocol --- .../src/scaffolder/stages/prepare/bitbucket.ts | 10 ++-------- .../src/scaffolder/stages/prepare/github.ts | 9 ++------- .../src/scaffolder/stages/prepare/gitlab.ts | 9 ++------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts index 5aafb2730f..8a66176b9c 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts @@ -18,7 +18,7 @@ import fs from 'fs-extra'; import path from 'path'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { parseLocationAnnotation } from '../helpers'; -import { InputError, Git } from '@backstage/backend-common'; +import { Git } from '@backstage/backend-common'; import { PreparerBase, PreparerOptions } from './types'; import { BitbucketIntegrationConfig } from '@backstage/integration'; import parseGitUrl from 'git-url-parse'; @@ -42,15 +42,9 @@ export class BitbucketPreparer implements PreparerBase { template: TemplateEntityV1alpha1, opts: PreparerOptions, ): Promise { - const { protocol, location } = parseLocationAnnotation(template); + const { location } = parseLocationAnnotation(template); const workingDirectory = opts.workingDirectory ?? os.tmpdir(); const logger = opts.logger; - - if (!['bitbucket', 'url'].includes(protocol)) { - throw new InputError( - `Wrong location protocol: ${protocol}, should be 'url'`, - ); - } const templateId = template.metadata.name; const repo = parseGitUrl(location); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts index e0d669c211..38eb9d408d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts @@ -18,7 +18,7 @@ import fs from 'fs-extra'; import path from 'path'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { parseLocationAnnotation } from '../helpers'; -import { InputError, Git } from '@backstage/backend-common'; +import { Git } from '@backstage/backend-common'; import { PreparerBase, PreparerOptions } from './types'; import parseGitUrl from 'git-url-parse'; import { GitHubIntegrationConfig } from '@backstage/integration'; @@ -34,15 +34,10 @@ export class GithubPreparer implements PreparerBase { template: TemplateEntityV1alpha1, opts: PreparerOptions, ): Promise { - const { protocol, location } = parseLocationAnnotation(template); + const { location } = parseLocationAnnotation(template); const workingDirectory = opts.workingDirectory ?? os.tmpdir(); const logger = opts.logger; - if (!['github', 'url'].includes(protocol)) { - throw new InputError( - `Wrong location protocol: ${protocol}, should be 'url'`, - ); - } const templateId = template.metadata.name; const parsedGitLocation = parseGitUrl(location); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts index 0bdecab794..9945a741c6 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { InputError, Git } from '@backstage/backend-common'; +import { Git } from '@backstage/backend-common'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { GitLabIntegrationConfig } from '@backstage/integration'; import fs from 'fs-extra'; @@ -34,15 +34,10 @@ export class GitlabPreparer implements PreparerBase { template: TemplateEntityV1alpha1, opts: PreparerOptions, ): Promise { - const { protocol, location } = parseLocationAnnotation(template); + const { location } = parseLocationAnnotation(template); const logger = opts.logger; const workingDirectory = opts.workingDirectory ?? os.tmpdir(); - if (!['gitlab', 'gitlab/api', 'url'].includes(protocol)) { - throw new InputError( - `Wrong location protocol: ${protocol}, should be 'url'`, - ); - } const templateId = template.metadata.name; const parsedGitLocation = parseGitUrl(location);