Implementation for Atlas Service Discovery Programmatic Access#267
Implementation for Atlas Service Discovery Programmatic Access#267xingfan-git wants to merge 10 commits intonextfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements MongoDB Atlas Service Discovery functionality by adding programmatic access to Atlas APIs. It introduces a new plugin module for the service-mongo-atlas service that handles both OAuth 2.0 and HTTP Digest authentication methods for Atlas API operations.
Key changes include:
- Addition of Atlas HTTP client for API communication with authentication support
- Credential caching system for Atlas organizations with OAuth token management
- Atlas administration client for managing projects, clusters, database users, and IP access lists
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts | HTTP client for Atlas API requests with OAuth and Digest authentication |
| src/plugins/service-mongo-atlas/utils/AtlasCredentialCache.ts | Credential storage and management for Atlas organizations |
| src/plugins/service-mongo-atlas/utils/AtlasAuthManager.ts | Authentication manager for OAuth token handling and credential management |
| src/plugins/service-mongo-atlas/utils/AtlasAdministrationClient.ts | Administration client for Atlas resource management operations |
| package.json | Added digest-fetch dependency for HTTP Digest authentication |
| l10n/bundle.l10n.json | Added localization strings for Atlas-related error messages |
| // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
| const client = new DigestClient(publicKey, privateKey) as DigestFetchClient; |
There was a problem hiding this comment.
The eslint-disable comment and type assertion suggest potential type safety issues. Consider creating proper type definitions for DigestClient instead of disabling the safety check and using type assertions.
| clientId, | ||
| clientSecret, | ||
| }, | ||
| digest: undefined, // Clear any existing digest credentials |
There was a problem hiding this comment.
Explicitly setting digest to undefined when setting OAuth credentials could be simplified by restructuring the credential object or using a more explicit credential switching mechanism to avoid potential confusion.
| value: string; | ||
| }>; | ||
| withDefaultAlertsSettings?: boolean; | ||
| } |
There was a problem hiding this comment.
The AtlasProject interface is missing proper return type annotations. According to the coding guidelines, TypeScript interfaces should be used for object shapes and all properties should have explicit types.
|
@tnaum-ms |
| } | ||
|
|
||
| // Add 60 second buffer to avoid edge cases | ||
| return Date.now() < oauth.tokenExpiry - 60000; |
There was a problem hiding this comment.
The 60-second buffer (60000ms) is a magic number. Consider extracting this as a named constant like TOKEN_EXPIRY_BUFFER_MS = 60000 to improve code readability and maintainability.
Linked Issue: