Skip to content

Use CloudConnector::AvailableServices for Code Suggestions

What does this MR do and why?

We should refactor the code to utilize CloudConnector::AvailableServices, for both Gitlab.com and Self-managed instances for for Code Suggestoins features (to limit the scope of the change).

Our goal is to decouple how add-ons are bundled with the features/services. We should:

  • Replace AccessService.free_access_for?(...) with CloudConnecor::AvailableServices.find_by_name(...).free_access?
  • Replace AccessService.access_token with CloudConnecor::AvailableServices.find_by_name(...).access_token
  • Replace user.duo_pro_add_on_available? with CloudConnecor::AvailableServices.find_by_name(...).allowed_for?(user)

Similar MR for Duo Chat: !150837 (merged)

Note: we do not remove old interfaces here (e.g. Gitlab::Llm::AiGateway::Client.access_token) so we can refactor CS/Chat/X-Ray/other in parallel. After all replacements are done, we will drop the old interface and related specs.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Run Code Suggestions locally, both imitating SaaS and Self-Managed. Make sure no related errors appeared.

Related to #458932

Edited by Aleksei Lipniagov

Merge request reports