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

36 lines
854 B
TypeScript
Raw Normal View History

import { LoggerInstance } from '@oceanprotocol/lib'
import axios from 'axios'
import { toast } from 'react-toastify'
2022-09-20 10:30:11 +02:00
export async function getContainerChecksum(
image: string,
tag: string
2022-09-20 10:30:11 +02:00
): Promise<string> {
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-09-20 10:30:11 +02:00
'Could not fetch docker hub image info. Please input the container checksum manually'
)
2022-09-20 10:30:11 +02:00
return null
}
2022-09-20 10:30:11 +02:00
return response.data.result.checksum
} catch (error) {
LoggerInstance.error(error.message)
toast.error(
2022-09-20 10:30:11 +02:00
'Could not fetch docker hub image info. Please input the container checksum manually'
)
2022-09-20 10:30:11 +02:00
return null
}
}