-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(do): added DigitalOcean Database Support
- Loading branch information
Piotr Hajdas
authored and
Piotr Hajdas
committed
Dec 24, 2024
1 parent
feb2389
commit 9f90f5a
Showing
4 changed files
with
82 additions
and
89 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
interface DatabaseConfig { | ||
engine: string; | ||
versions: string[]; | ||
description: string; | ||
} | ||
|
||
interface DigitalOceanDatabaseConfig { | ||
databases: { | ||
[key: string]: DatabaseConfig; | ||
}; | ||
} | ||
|
||
export const digitalOceanDatabaseConfig: DigitalOceanDatabaseConfig = { | ||
databases: { | ||
'docker.io/library/mysql': { | ||
engine: 'MYSQL', | ||
versions: ['8'], | ||
description: 'MySQL database service - requires managed database service due to TCP protocol' | ||
}, | ||
'docker.io/library/mariadb': { | ||
engine: 'MYSQL', | ||
versions: ['8'], | ||
description: 'MariaDB database service - maps to MySQL managed database due to compatibility' | ||
}, | ||
'docker.io/library/postgres': { | ||
engine: 'PG', | ||
versions: ['13', '14', '15'], | ||
description: 'PostgreSQL database service - requires managed database service due to TCP protocol' | ||
}, | ||
'docker.io/library/redis': { | ||
engine: 'REDIS', | ||
versions: ['6', '7'], | ||
description: 'Redis database service - requires managed database service due to TCP protocol' | ||
}, | ||
'docker.io/library/mongodb': { | ||
engine: 'MONGODB', | ||
versions: ['6.0', '7.0'], | ||
description: 'MongoDB database service - requires managed database service due to TCP protocol' | ||
} | ||
} | ||
}; | ||
|
||
export type { DatabaseConfig, DigitalOceanDatabaseConfig }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { DockerImageInfo } from '../parsers/base-parser'; | ||
import { getImageUrl } from './getImageUrl'; | ||
import { constructImageString } from './constructImageString'; | ||
import { digitalOceanDatabaseConfig } from '../config/digitalocean/database-types'; | ||
|
||
export interface DatabaseInfo { | ||
engine: string; | ||
version: string; | ||
} | ||
|
||
export function getDigitalOceanDatabaseType(image: DockerImageInfo): DatabaseInfo | null { | ||
const normalizedImage = getImageUrl(constructImageString(image)); | ||
|
||
for (const [configImage, dbConfig] of Object.entries(digitalOceanDatabaseConfig.databases)) { | ||
if (normalizedImage.includes(configImage)) { | ||
return { | ||
engine: dbConfig.engine, | ||
version: dbConfig.versions[0] | ||
}; | ||
} | ||
} | ||
|
||
return null; | ||
} |