[WIP][DO_NOT_MERGE] add an upstream image field to builds

I'd combine those two `if`'s into one, especially that you're also doing additional check for each of them.