2021-12-10 12:33:47 +01:00
|
|
|
import { LoggerInstance } from '@oceanprotocol/lib'
|
2021-10-28 11:38:40 +02:00
|
|
|
import axios from 'axios'
|
|
|
|
import { toast } from 'react-toastify'
|
|
|
|
|
2022-09-20 10:30:11 +02:00
|
|
|
export async function getContainerChecksum(
|
2021-10-28 11:38:40 +02:00
|
|
|
image: string,
|
|
|
|
tag: string
|
2022-09-20 10:30:11 +02:00
|
|
|
): Promise<string> {
|
2021-10-28 11:38:40 +02:00
|
|
|
try {
|
|
|
|
const response = await axios.post(
|
|
|
|
`https://dockerhub-proxy.oceanprotocol.com`,
|
2022-09-20 10:30:11 +02:00
|
|
|
{
|
|
|
|
image,
|
|
|
|
tag
|
|
|
|
}
|
2021-10-28 11:38:40 +02:00
|
|
|
)
|
|
|
|
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'
|
2021-10-28 11:38:40 +02:00
|
|
|
)
|
2022-09-20 10:30:11 +02:00
|
|
|
return null
|
2021-10-28 11:38:40 +02:00
|
|
|
}
|
2022-09-20 10:30:11 +02:00
|
|
|
return response.data.result.checksum
|
2021-10-28 11:38:40 +02:00
|
|
|
} catch (error) {
|
2021-12-10 12:33:47 +01:00
|
|
|
LoggerInstance.error(error.message)
|
2021-10-28 11:38:40 +02:00
|
|
|
toast.error(
|
2022-09-20 10:30:11 +02:00
|
|
|
'Could not fetch docker hub image info. Please input the container checksum manually'
|
2021-10-28 11:38:40 +02:00
|
|
|
)
|
2022-09-20 10:30:11 +02:00
|
|
|
return null
|
2021-10-28 11:38:40 +02:00
|
|
|
}
|
|
|
|
}
|