Hadron / carthage

Carthage is an Infrastructure as Code (IAC) framework
Other
8 stars 4 forks source link

AttributeError: 'WebserverImage' object has no attribute 'base_image' could refer me to oci_container_image #39

Open kdienes opened 1 year ago

kdienes commented 1 year ago

If I don't do:

            add_provider(oci_container_image, 'image:tag')

somewhere, I (correctly) get an error:

File "/home/admin/project/carthage/carthage/podman/base.py", line 412, in pull_base_image if isinstance(self.base_image, OciImage): ^^^^^^^^^^^^^^^ AttributeError: 'WebserverImage' object has no attribute 'base_image'

It'd be helpful if this error told me directly that I was missing an oci_container_image, and maybe it should do that at model time?

hartmans commented 4 months ago

I agree that we could give a better error in pull_base_image. I don't know that giving an error in model time would be correct because it's possible that whathever injector your model is instantiated into will provide that dependency. I.E. you could always do

base_injector.add_provider(oci_container_image, ...)

before instantiating your layout.

This is mostly a note to myself that I've thought about this and it is unrelated to base_image vs oci_container_image and when you can set base_image in a class vs when it gets overridden , and we can just improve the error message.