Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Extract ScmService to be used by both APIs #19098

Merged
merged 6 commits into from
Nov 22, 2023
Merged

Conversation

AlexTugarev
Copy link
Member

@AlexTugarev AlexTugarev commented Nov 21, 2023

Description

This PR extracts (actually consolidates) an internal ScmService to be used by the API services (gRPC and WS).

This also implements the SCMService from #19075.

Summary generated by Copilot

🤖[deprecated] Generated by Copilot at 563b5eb

Refactored the server-side code to use a new ScmService class for all source control management operations, and exposed it to the public API via a new ScmServiceAPI class. Removed unused or redundant code and improved error handling and dependency injection. Updated the GitpodServerImpl class to use the new ScmService class.

Related Issue(s)

Fixes #

How to test

This PR refactors code paths used for

  • listing suggested repos in New Workspace & New Project modals
  • reading current scopes for Git Integrations

This UI parts should have the same behavior as before.

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@AlexTugarev AlexTugarev changed the title At/scm-service [server] Extract ScmService to be used by both APIs Nov 21, 2023
Base automatically changed from at/scm.proto to main November 21, 2023 11:41
// (AT) when it comes to token renewal, the awaited http requests may
// cause "parallel" calls to repeat the renewal, which will fail.
// Caching for pending operations should solve this issue.
const key = `${host}-${user.id}`;
const key = `${host}-${userId}`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈 Caching tokens for the sake of deduplication of renewal requests?! EXP-950

@@ -891,13 +891,6 @@ export interface GuessGitTokenScopesParams {
host: string;
repoUrl: string;
gitCommand: string;
currentToken: GitToken;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this on purpose. 'Should avoid sending sensitive information if not needed.
Here we'd be in the position to obtain the token from DB to perform the write permissions check if required.

@AlexTugarev AlexTugarev marked this pull request as ready for review November 21, 2023 12:08
@AlexTugarev AlexTugarev requested a review from a team as a code owner November 21, 2023 12:08
@akosyakov
Copy link
Member

@AlexTugarev if you can fill in how to test section to what to pay attention in the dashboard it would help.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked through the code generally look good, i left questions please have a look.

Testing now. I triggered preview envs, waiting...

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did following tests:

  • created a new project
  • during creation check that I see suggested repositories and can search them
  • use a repository which is not suggested for the project
  • then created a workspace for such project, checked that i still can see and search suggested repositories with a project repository
  • in the workspace try git push
  • seen that it failed and showed me that public_repo permission is missing
  • then to User -> Preferences and updated permissions, close UI and reopen to confirmed that it applied
  • after that went back to thw worksapce and did git push againt, it worked

@AlexTugarev anything else to test?

I pre approved, please take time to add tests and address comments as you find it fit.

Should I test #19101 already in the same way? Or better to wait till this PR is merged and another is rebased?

@AlexTugarev AlexTugarev marked this pull request as draft November 21, 2023 13:54
@AlexTugarev AlexTugarev force-pushed the at/scm-service branch 2 times, most recently from 254a607 to 54798af Compare November 21, 2023 17:20
@AlexTugarev AlexTugarev changed the base branch from main to at/scm-rename November 21, 2023 17:20
Base automatically changed from at/scm-rename to main November 22, 2023 10:17
@AlexTugarev AlexTugarev marked this pull request as ready for review November 22, 2023 11:20
@AlexTugarev
Copy link
Member Author

/unhold

@roboquat roboquat merged commit 612b919 into main Nov 22, 2023
16 checks passed
@roboquat roboquat deleted the at/scm-service branch November 22, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants