leverage
leverage copied to clipboard
Enhancement | Design/Architectural Improvements
Describe the Feature
We should take this notes in consideration to reduce the complexity and readability of the source code in general, which should bring the benefit of optimizing the times and costs involved on new developments.
Describe Ideal Solution
1. Extract all the docker/container logic related from LeverageContainer
into its own class.
That would mean, move the methods:
- start
- exec
- run
- create_container
- docker_logs
- etc..
into the new class. More or less, it would be an interface to the docker library we use.
Unit tests would become way easier to write because the interface should be totally mockable.
LeverageContainer
would still be in charge of loading the correct en vars, region, config files and the base logic of the CLI.
2. Don't force an entrypoint
Leave it empty and use it only on the required scenarios. That would simplify a lot the code base, by avoiding the use and abuse of the context managers to switch it.
3. Container.py should be split in N files
Inside leverage/containers/
. One file per binary/container representation. That should improve readability.
4. Create a mixin with all the AWS credentials logic
It would be used by the AWS, Terraform and Kubectl containers, and any new command in the future. Logic shouldn't be repeated. It would be as simple as inheriting the mixin, so your env vars and methods to authenticate against AWS would be guaranteed.
Adding value
Potential complexity analyzer we could use to measure the code improvements: https://pypi.org/project/wily/