How to associate a resource to your charm
You have published your charm. This document shows you how you can now associate a resource name to your charm.
By default, a charm has no attached resources. You can verify this by running
jdoe@machine:~/blogsystem$ charmcraft resources my-super-charm No resources associated to my-super-charm.
To attach a resource to a charm, open your charm’s
metadata.yaml file and edit the
jdoe@machine:~/blogsystem$ cat metadata.yaml name: my-super-charm summary: My super charm. description: My super duper charm, used for testing. series: - bionic resources: someresource: type: file filename: superdb.bin description: the DB with needed info
You may include as many resources as we want.
When you’re done, rebuild and reupload your charm to Charmhub with the new metadata:
jdoe@machine:~/blogsystem$ charmcraft build Created 'my-super-charm.charm'. jdoe@machine:~/blogsystem$ charmcraft upload my-super-charm.charm Revision 13 of 'my-super-charm' created
Finally, inspect the results:
jdoe@machine:~/blogsystem$ charmcraft resources my-super-charm Name Type Revision Optional someresource file 13 True
As you can see, the resource is associated to revision 13 of the charm. This association to a specific revision of a charm is important is important to keep in mind, as it will matter if you want to attach a resource to a charm at release time—the attachment will work only if the resource has been included in the chosen charm revision’s metadata.
Last updated 5 months ago.