Best practice on hooks for educational purpose


#1

I’ve started to dig in on educational material for juju charming.

I’ve created two charms (bash + python) - serving as the intended starting point for the material - probably a tutorial.

Here is the draft: https://github.com/erik78se/Tutorial-Build-a-quick-charm/blob/master/quick-charm.md

The focus is on “hooks”.

I want to discuss how the implementation of these “hooks only” charms could be made more “typical” and “best practice” to good charming.

The challenge is to keep it extremely minimal to assist in the learning process. Possibly leading into the reactive framework further down, but not to the expense of adding too much complexity.

I would like to fire off a discussion around how to actually implement the hooks to be:

  • Minimal
  • Best practice or at least typical.
  • “Just enough” introduction to other concepts outside of “hooks”. Hook contexts, configuration validation, juju eventloop etc.
  • Ideally, making the code also “OS agnostic” - not relying on Ubuntu to get juju basic concepts going.

https://jujucharms.com/new/u/erik-lonroth/tiny-python
https://jujucharms.com/new/u/erik-lonroth/tiny-bash

If done right, I hope we can help people getting even easier into juju charming.

So, what are your thoughts! Fork and code.

Some other tutorials helpful in learning of juju charming:
https://discourse.jujucharms.com/t/tutorial-charm-development-beginner-part-1/
https://discourse.jujucharms.com/t/tutorial-understanding-kubernetes-charms/
https://discourse.jujucharms.com/t/tutorial-charms-with-layer-snap-intermediate/


#2

Thanks for your great tutorial and detailed explaination, which is really helpful! There are some minor suggestions regarding your tutorial in GitHub link. :slight_smile:

a. In the part Remove the application
The following command causes an error as ‘Unrecognized command’

$ juju remove application tiny-python

It might be like this:

$ juju remove-application tiny-python

b. In the part Modifying the ‘install’ hook
Before modifying Install script, is it necessary to specify the exact path of install? like ~/tiny_python/hooks/install .
(There is a tree above demonstrating the path though :D)


#3

Thanx, I’ve fixed the “remove-application” part. Thanx for contributing to it!


#4

I have now also added a few things on how to get out of problems with juju resolved…

I will add you to a list of contributors if you like?


#6

That’s great!
yes, please. :smiley: