Open jdkandersson opened 1 year ago
@gregory-schiano any thoughts?
I like this idea, as indeed it'll be easier to unit test and also reduces the coupling with the framework. But I have the feeling that it won't be very easy as the charm code depends a lot on ops and pebble abstracting them to decouple the charm business logic could be a bit tough. Could worth a try on a simple charm !
Yeh sounds good, I'll keep an eye out for opportunities to test this in PRs and maybe write an experimental PR for Indico if I get the chance
Charms have an interface class that derives from the
CharmBase
class. Many charms currently write most of their logic within that class rather than separate at least some of it to a separate module. The standard would be to only include code relevant to managing the interface with juju to the class inheriting fromCharmBase
and put the other code into separate modules and functions. This would simplify testing and also generalise logic in the case of having to switch frameworks again in the future. This would also help with migrating charms from previous frameworks.