Preheat the oven to 200°C/gas mark 6. Boil the potatoes for 10 minutes until tender. Drain and leave to cool.
Meanwhile, heat the oil in a large skillet or shallow casserole dish and add the onion. Fry for 6-8 minutes, or until soft. Add the garlic and continue to cook for a further couple of minutes. Add the chorizo and fry for 4-5 minutes, or until the chorizo is starting to crisp and releasing its oil.
Add the potatoes and rosemary and continue to fry for a further 5 minutes, or until the potatoes begin to crisp up. Stir through the tomatoes, then make four wells in the mixture. Crack an egg into each of the wells. Sprinkle the top with chilli flakes, if using, then transfer to the oven. Bake for 6-8 minutes until the eggs have set. Remove from the oven and serve.