-
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.
Merge pull request #91 from deploystackio/feat/do-service-db-fix
fix(do): DigitalOcean services vs. managed DB fix
- Loading branch information
Showing
4 changed files
with
108 additions
and
78 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,24 +1,16 @@ | ||
import { DockerImageInfo } from '../parsers/base-parser'; | ||
import { getImageUrl } from './getImageUrl'; | ||
import { constructImageString } from './constructImageString'; | ||
import { digitalOceanDatabaseConfig } from '../config/digitalocean/database-types'; | ||
import { digitalOceanDatabaseConfig, DatabaseConfig } from '../config/digitalocean/database-types'; | ||
|
||
export interface DatabaseInfo { | ||
engine: string; | ||
version: string; | ||
} | ||
|
||
export function getDigitalOceanDatabaseType(image: DockerImageInfo): DatabaseInfo | null { | ||
export function getDigitalOceanDatabaseType(image: DockerImageInfo): DatabaseConfig | 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 dbConfig; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
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,41 @@ | ||
import { DockerImageInfo } from '../parsers/base-parser'; | ||
|
||
export function normalizeDigitalOceanImageInfo(dockerImageInfo: DockerImageInfo): { | ||
registry: string; | ||
repository: string; | ||
} { | ||
// Get fully qualified name from registry | ||
const registryPath = dockerImageInfo.registry || 'docker.io'; | ||
const repositoryPath = dockerImageInfo.repository; | ||
|
||
// For docker.io/library/[name] format | ||
if (registryPath === 'docker.io' && repositoryPath.startsWith('library/')) { | ||
return { | ||
registry: 'library', | ||
repository: repositoryPath.replace('library/', '') | ||
}; | ||
} | ||
|
||
// For docker.io/[owner]/[name] format | ||
if (registryPath === 'docker.io') { | ||
// Check if it's a direct image name without owner (official image) | ||
if (!repositoryPath.includes('/')) { | ||
return { | ||
registry: 'library', | ||
repository: repositoryPath | ||
}; | ||
} | ||
|
||
const parts = repositoryPath.split('/'); | ||
return { | ||
registry: parts[0], | ||
repository: parts[1] || parts[0] | ||
}; | ||
} | ||
|
||
// For other registries, keep as is | ||
return { | ||
registry: dockerImageInfo.registry || 'library', | ||
repository: dockerImageInfo.repository | ||
}; | ||
} |