1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
market/src/@utils/docker.ts

47 lines
1.2 KiB
TypeScript
Raw Normal View History

import { LoggerInstance } from '@oceanprotocol/lib'
import axios from 'axios'
import { toast } from 'react-toastify'
2022-09-28 14:47:43 +02:00
export interface dockerContainerInfo {
exists: boolean
checksum: string
}
2022-10-10 14:59:32 +02:00
export async function getContainerChecksum(
image: string,
tag: string
2022-09-28 14:47:43 +02:00
): Promise<dockerContainerInfo> {
const containerInfo: dockerContainerInfo = {
exists: false,
checksum: null
}
try {
const response = await axios.post(
`https://dockerhub-proxy.oceanprotocol.com`,
2022-09-20 10:30:11 +02:00
{
image,
tag
}
)
if (
!response ||
response.status !== 200 ||
response.data.status !== 'success'
) {
toast.error(
2022-10-10 14:59:32 +02:00
'Could not fetch docker hub image informations. If you have it hosted in a 3rd party repository please fill in the container checksum manually.'
2022-09-28 14:47:43 +02:00
)
return containerInfo
}
containerInfo.exists = true
containerInfo.checksum = response.data.result.checksum
return containerInfo
} catch (error) {
LoggerInstance.error(error.message)
toast.error(
2022-10-10 14:59:32 +02:00
'Could not fetch docker hub image informations. If you have it hosted in a 3rd party repository please fill in the container checksum manually.'
)
2022-09-28 14:47:43 +02:00
return containerInfo
}
}