From ee0c883def626d6c04e6c60b5f84e8792a8300de Mon Sep 17 00:00:00 2001 From: Alex Tugarev Date: Wed, 15 Nov 2023 15:40:22 +0000 Subject: [PATCH] [server] make unused getProviderRepositoriesForUser a no-op --- .../gitpod-protocol/src/gitpod-service.ts | 1 + .../src/workspace/gitpod-server-impl.ts | 50 +++---------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 6705b60a63f6fd..81e87a0b82e645 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -188,6 +188,7 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, getOnboardingState(): Promise; // Projects + /** @deprecated no-op */ getProviderRepositoriesForUser( params: GetProviderRepositoriesParams, cancellationToken?: CancellationToken, diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index d19cdc47acf722..7211eb42408577 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -147,9 +147,6 @@ import { LinkedInService } from "../linkedin-service"; import { SnapshotService, WaitForSnapshotOptions } from "./snapshot-service"; import { IncrementalWorkspaceService } from "../prebuilds/incremental-workspace-service"; import { PrebuildManager } from "../prebuilds/prebuild-manager"; -import { GitHubAppSupport } from "../github/github-app-support"; -import { GitLabAppSupport } from "../gitlab/gitlab-app-support"; -import { BitbucketAppSupport } from "../bitbucket/bitbucket-app-support"; import { StripeService } from "../billing/stripe-service"; import { BillingServiceClient, @@ -195,10 +192,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { @inject(ContextParser) private contextParser: ContextParser, @inject(HostContextProvider) private readonly hostContextProvider: HostContextProvider, - @inject(GitHubAppSupport) private readonly githubAppSupport: GitHubAppSupport, - @inject(GitLabAppSupport) private readonly gitLabAppSupport: GitLabAppSupport, - @inject(BitbucketAppSupport) private readonly bitbucketAppSupport: BitbucketAppSupport, - @inject(PrebuildManager) private readonly prebuildManager: PrebuildManager, @inject(IncrementalWorkspaceService) private readonly incrementalPrebuildsService: IncrementalWorkspaceService, @inject(ConfigProvider) private readonly configProvider: ConfigProvider, @@ -1263,7 +1256,10 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { ); } - // Projects + /** + * + * @deprecated + */ async getProviderRepositoriesForUser( ctx: TraceContext, params: GetProviderRepositoriesParams, @@ -1271,42 +1267,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { ): Promise { traceAPIParams(ctx, { params }); - const user = await this.checkAndBlockUser("getProviderRepositoriesForUser"); - - const repositories: ProviderRepository[] = []; - const providerHost = params.provider; - const provider = (await this.getAuthProviders(ctx)).find((ap) => ap.host === providerHost); - - if (providerHost === "github.com" && this.config.githubApp?.enabled) { - repositories.push(...(await this.githubAppSupport.getProviderRepositoriesForUser({ user, ...params }))); - } else if (provider?.authProviderType === "GitHub") { - const hostContext = this.hostContextProvider.get(providerHost); - if (hostContext?.services) { - repositories.push( - ...(await hostContext.services.repositoryService.getRepositoriesForAutomatedPrebuilds(user, {})), - ); - } - } else if (providerHost === "bitbucket.org" && provider) { - repositories.push(...(await this.bitbucketAppSupport.getProviderRepositoriesForUser({ user, provider }))); - } else if (provider?.authProviderType === "BitbucketServer") { - const hostContext = this.hostContextProvider.get(providerHost); - if (hostContext?.services) { - repositories.push( - ...(await hostContext.services.repositoryService.getRepositoriesForAutomatedPrebuilds(user, { - searchString: params.searchString, - cancellationToken, - limit: params.limit, - maxPages: params.maxPages, - })), - ); - } - } else if (provider?.authProviderType === "GitLab") { - repositories.push(...(await this.gitLabAppSupport.getProviderRepositoriesForUser({ user, provider }))); - } else { - log.info({ userId: user.id }, `Unsupported provider: "${params.provider}"`, { params }); - } - - return repositories; + await this.checkAndBlockUser("getProviderRepositoriesForUser"); + return []; } async triggerPrebuild(