nixos/oci-containers: check if image exists locally before failing

Signed-off-by: budimanjojo <budimanjojo@gmail.com>
This commit is contained in:
budimanjojo 2024-02-19 10:38:26 +07:00
parent 4477ea4df7
commit fd3fa9f2d3
No known key found for this signature in database

View File

@ -252,10 +252,13 @@ let
text = ''
${cfg.backend} rm -f ${name} || true
${optionalString (isValidLogin container.login) ''
# try logging in, if it fails, check if image exists locally
${cfg.backend} login \
${container.login.registry} \
--username ${container.login.username} \
--password-stdin < ${container.login.passwordFile}
--password-stdin < ${container.login.passwordFile} \
|| ${cfg.backend} image inspect ${container.image} >/dev/null \
|| { echo "image doesn't exist locally and login failed" >&2 ; exit 1; }
''}
${optionalString (container.imageFile != null) ''
${cfg.backend} load -i ${container.imageFile}