This commit is contained in:
Andras Bacsai
2022-07-25 18:43:53 +00:00
parent 9168cd1dc6
commit cf140ff4cf
3 changed files with 21 additions and 18 deletions

View File

@@ -1,4 +1,18 @@
import { executeDockerCmd } from './common';
export function formatLabelsOnDocker(data) {
return data.trim().split('\n').map(a => JSON.parse(a)).map((container) => {
const labels = container.Labels.split(',')
let jsonLabels = {}
labels.forEach(l => {
const name = l.split('=')[0]
const value = l.split('=')[1]
jsonLabels = { ...jsonLabels, ...{ [name]: value } }
})
container.Labels = jsonLabels;
return container
})
}
export async function checkContainer({ dockerId, container, remove = false }: { dockerId: string, container: string, remove?: boolean }): Promise<boolean> {
let containerFound = false;
try {