Development charms covering "config"

I’m looking for some code covering the very most trivial concept of managing charm development for charm “configuration”.

Its really not easy to find documentation on how to manage configuration options for charms with python in the references.

I think that this concept would deserve some very clear documentation with example code - or have I just missed to find this?

1 Like

Are you looking at the charmhelpers docs Erik?

1 Like

I’m not sure everyone knows what this is, would you mind expanding? Also, I found the config link you gave to be very straight forward and informative. Can you elaborate further on what you feel it is missing?

Thanks!

I’m after some code snippets and best practice examples.

A good start would be:

  1. A chapter covering “Charm configuration” in the documentation,
  2. Examples on how a new developer should differentiate between juju configuration “on file”, vs “in memory”
  3. Code examples in juju, like for example.
serverjar = config('server-jar')

render(
    source='minecraft.service',
    target='/etc/systemd/system/minecraft.service',
    owner='root',
    perms=0o775,
    context={
        'server_jar': serverjar
    }
)
  1. A best practice reactive code example that covers how to deal with a restart/reload of a custom service to deal with when configuration changes vs installation. Something I have some problems getting my head around a good way to manage with a good strategy. Dealing with install/start/restart/reload is quite a common thing for many services - yet there are no good examples in the documentation for this yet. Personally, I had to roam around in your repos to find examples and I’m not super happy about those I found.

Thanx @seffyroff thats the best so far indeed.

The comments in the code example are the best - but I would really be helped from this being covered more in-depth in the documentation rather than in the comments in the example code?

Many other concepts have a dedicated chapter in the docs and how config works is a fundamental piece of juju I would say which also lowers the bar for entry.

1 Like

I’d say there’s a tutorial that needs writing that couples the Charmhelpers API with some practical examples.

I’m almost at the point where I’d like to write one myself for a charm I’m currently ‘almost’ done authoring, but it’s the little detailed Python syntax bits that’s slowing me down from getting it done, and I’m reluctant to ask what I see as basic Python questions here, where I perceive the expectation is that a minimum knowledge level for charm authoring is just a touch above my own Python skills :confused:

1 Like