The goal of this refactor is to allow the "get cached image" logic to be imported by another tool (the Terraform provider for envbuilder). This can be done as a separate task (prereq) or in conjunction with the provider implementation. Part of [Envbuilder Terraform Provider RFC](https://www.notion.so/coderhq/Envbuilder-Terraform-Provider-f87da056b0e740d9b2ca3a1827bda4f7?pvs=4).