#Is it possible to check if a container image exists?
1 messages · Page 1 of 1 (latest)
It looks like you could call Sync right after the From func and just recover() if you do get an error. Its not the most "dagger-esque" way to do it, but it does work:
func (m *Module) Tester(ctx context.Context) string {
func() {
_, err := dag.Container().From("asdf").Sync(ctx)
if err != nil {
println(err)
recover()
}
_, err = dag.Container().From("ubuntu").Sync(ctx)
if err != nil {
println(err)
recover()
}
}()
return "hello world"
}
Output with --progress=plain shows both containers being tried, ubuntu loading, and the normal return happening.
we're using crane through a dagger module to test if a specific image tag exists: https://daggerverse.dev/mod/github.com/vbehar/daggerverse/crane@34d69624010b7b7c90a38e9119346fbd3950187b#Crane.imageTagExists
crane is a very nice tool
@proud anchor @oblique mist Thanks for the suggestions! Staying in Dagger the recover() approach could work. I noticed the CLI output logs the error messages, which might not be desirable. I'll checkout the crane tool experiment with it some, thanks!