Skip to main content

Helper for dealing with OCI Image resources in the charm operator framework

Project description

OCI Image Resource helper

This is a helper for working with OCI image resources in the charm operator framework.


Add this to your charm by including oci-image in your requirements.txt file.

The OCIImageResource class will wrap the framework resource for the given resource name, and calling fetch on it will either return the image info or raise an OCIImageResourceError if it can't fetch or parse the image info. The exception will have a status attribute you can use directly, or a status_message attribute if you just want that.

Example usage:

from ops.charm import CharmBase
from ops.main import main
from oci_image import OCIImageResource, OCIImageResourceError

class MyCharm(CharmBase):
    def __init__(self, *args):
        self.image = OCIImageResource(self, 'resource-name')
        self.framework.observe(self.on.start, self._on_start)

    def _on_start(self, event):
            image_info = self.image.fetch()
        except OCIImageResourceError as e:
            self.model.unit.status = e.status

        self.model.pod.set_spec({'containers': [{
            'name': 'my-charm',
            'imageDetails': image_info,

if __name__ == "__main__":


Tests can be run with tox.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oci-image-1.0.0.tar.gz (2.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page