Possible to set default for oci-image resource?

We define an oci-image resource in metadata.yaml like

resources:
  container_image:
    type: oci-image
    description: Container image

We can then deploy our charm like

juju deploy . --resource container_image=busybox

We then end up with a resource file at /var/lib/juju/agents/<unit name>/resources/container_image/content.yaml containing

{'password': '', 'registrypath': 'busybox', 'username': ''}

Is there a keyword, like default, that I can put under the resource in metadata.yaml to bypass the need for providing it at deploy time?

Note: I’m using juju version 2.7.0 and developing with the new python operator framework

1 Like

The need to specify the OCI image is only necessary when deploying local charms. Charms from the store will include the image definition as a resource which is attached to the charm when uploaded to the store and the charm is published.

Juju resources don’t support default values. If the resource type were a zip file instead of an OCI image, you would still need to specify the resource value when deploying a local copy of the charm.

I suggest using a bundle which does support specifying all resources to be associated with a deployed charm. You can add your preferred image path in there.

1 Like

hi @lucid

We can attach the resource to the charm like this:

$ charm attach cs:~kelvin.liu/mariadb-0 mysql_image=mariadb

More charm tool commands: Charm tools

1 Like

Thanks team! That context has made sense of it.

Can you use the same syntax when doing “charm push”? So for OCI Images it would be:

charm push foo --resource foo-image=footag