Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions web/packages/shared/services/databases/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,34 @@
* limitations under the License.
*/

export type DbType = 'redshift' | 'rds' | 'gcp' | 'self-hosted';
export type DbType =
| 'self-hosted'
| 'rds'
| 'rdsproxy'
| 'redshift'
| 'redshift-serverless'
| 'gcp'
| 'azure'
| 'elasticache'
| 'memorydb'
| 'keyspace'
| 'cassandra'
| 'dynamodb'
| 'opensearch';

export type DbProtocol =
| 'postgres'
| 'mysql'
| 'mongodb'
| 'oracle'
| 'redis'
| 'cockroachdb'
| 'sqlserver'
| 'redis';
| 'snowflake'
| 'cassandra'
| 'elasticsearch'
| 'opensearch'
| 'dynamodb';

const formatProtocol = (input: DbProtocol) => {
switch (input) {
Expand All @@ -35,6 +55,14 @@ const formatProtocol = (input: DbProtocol) => {
return 'SQL Server';
case 'redis':
return 'Redis';
case 'oracle':
return 'Oracle';
case 'cockroachdb':
return 'CockroachDB';
case 'cassandra':
return 'Cassandra';
case 'elasticsearch':
return 'Elasticsearch';
default:
return input;
}
Expand All @@ -43,19 +71,48 @@ const formatProtocol = (input: DbProtocol) => {
export const formatDatabaseInfo = (type: DbType, protocol: DbProtocol) => {
const output = { type, protocol, title: '' };

switch (protocol) {
case 'snowflake':
output.title = 'Snowflake';
return output;
}
switch (type) {
case 'rds':
output.title = `RDS ${formatProtocol(protocol)}`;
output.title = `Amazon RDS ${formatProtocol(protocol)}`;
return output;
case 'rdsproxy':
output.title = `Amazon RDS Proxy ${formatProtocol(protocol)}`;
return output;
case 'redshift':
output.title = 'Redshift';
output.title = 'Amazon Redshift';
return output;
case 'redshift-serverless':
output.title = 'Amazon Redshift Serverless';
return output;
case 'elasticache':
output.title = 'Amazon ElastiCache';
return output;
case 'memorydb':
output.title = 'Amazon MemoryDB';
return output;
case 'keyspace':
output.title = 'Amazon Keyspaces';
return output;
case 'dynamodb':
output.title = 'Amazon DynamoDB';
return output;
case 'opensearch':
output.title = 'Amazon OpenSearch';
return output;
case 'self-hosted':
output.title = `Self-hosted ${formatProtocol(protocol)}`;
return output;
case 'gcp':
output.title = `Cloud SQL ${formatProtocol(protocol)}`;
return output;
case 'azure':
output.title = `Azure ${formatProtocol(protocol)}`;
return output;
default:
output.title = `${type} ${formatProtocol(protocol)}`;
return output;
Expand Down
35 changes: 24 additions & 11 deletions web/packages/teleport/src/services/databases/databases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('correct formatting of database fetch response', async () => {
{
name: 'aurora',
description: 'PostgreSQL 11.6: AWS Aurora',
type: 'RDS PostgreSQL',
type: 'Amazon RDS PostgreSQL',
protocol: 'postgres',
names: [],
users: [],
Expand Down Expand Up @@ -64,16 +64,29 @@ test('null response from database fetch', async () => {

describe('correct formatting of all type and protocol combos', () => {
test.each`
type | protocol | combined
${'self-hosted'} | ${'mysql'} | ${'Self-hosted MySQL/MariaDB'}
${'rds'} | ${'mysql'} | ${'RDS MySQL/MariaDB'}
${'self-hosted'} | ${'postgres'} | ${'Self-hosted PostgreSQL'}
${'rds'} | ${'postgres'} | ${'RDS PostgreSQL'}
${'gcp'} | ${'postgres'} | ${'Cloud SQL PostgreSQL'}
${'redshift'} | ${'postgres'} | ${'Redshift'}
${'self-hosted'} | ${'sqlserver'} | ${'Self-hosted SQL Server'}
${'self-hosted'} | ${'redis'} | ${'Self-hosted Redis'}
${'some other type'} | ${'some other protocol'} | ${'some other type some other protocol'}
type | protocol | combined
${'self-hosted'} | ${'mysql'} | ${'Self-hosted MySQL/MariaDB'}
${'rds'} | ${'mysql'} | ${'Amazon RDS MySQL/MariaDB'}
${'self-hosted'} | ${'postgres'} | ${'Self-hosted PostgreSQL'}
${'rds'} | ${'postgres'} | ${'Amazon RDS PostgreSQL'}
${'rdsproxy'} | ${'sqlserver'} | ${'Amazon RDS Proxy SQL Server'}
${'gcp'} | ${'postgres'} | ${'Cloud SQL PostgreSQL'}
${'redshift'} | ${'postgres'} | ${'Amazon Redshift'}
${'redshift-serverless'} | ${'postgres'} | ${'Amazon Redshift Serverless'}
${'dynamodb'} | ${'dynamodb'} | ${'Amazon DynamoDB'}
${'elasticache'} | ${'redis'} | ${'Amazon ElastiCache'}
${'memorydb'} | ${'redis'} | ${'Amazon MemoryDB'}
${'opensearch'} | ${'opensearch'} | ${'Amazon OpenSearch'}
${'keyspace'} | ${'cassandra'} | ${'Amazon Keyspaces'}
${'self-hosted'} | ${'sqlserver'} | ${'Self-hosted SQL Server'}
${'self-hosted'} | ${'redis'} | ${'Self-hosted Redis'}
${'self-hosted'} | ${'mongodb'} | ${'Self-hosted MongoDB'}
${'self-hosted'} | ${'cassandra'} | ${'Self-hosted Cassandra'}
${'self-hosted'} | ${'cockroachdb'} | ${'Self-hosted CockroachDB'}
${'self-hosted'} | ${'oracle'} | ${'Self-hosted Oracle'}
${'self-hosted'} | ${'snowflake'} | ${'Snowflake'}
${'self-hosted'} | ${'elasticsearch'} | ${'Self-hosted Elasticsearch'}
${'some other type'} | ${'some other protocol'} | ${'some other type some other protocol'}
`(
'should combine type: $type and protocol: $protocol correctly',
async ({ type, protocol, combined }) => {
Expand Down