gefyrahq / gefyra

Blazingly-fast :rocket:, rock-solid, local application development :arrow_right: with Kubernetes.
https://gefyra.dev
Apache License 2.0
692 stars 28 forks source link

[Gefyra Client] Code refactorings #318

Closed Schille closed 1 year ago

Schille commented 1 year ago

The following code refactorings are recommended:

CLI framework Since there are more commands to be added to the CLI in the future, I'd say we should take a step back and refactor the whole _main_.py (https://github.com/gefyrahq/gefyra/blob/main/client/gefyra/main__.py) into a CLI package. Ideally, we'd introduce a useful CLI framework such as Click to improve the CLI experience and tell the code for CLI and API apart. The CLI python package would be excluded for the wheel (for PyPI).

Factory pattern for ClientConfiguration We have a couple of spots in the code creating and modifying the ClientConfiguration after initialization. I don't like the fragmentation and recommend implementing a factory pattern to consolidate the initialization of the object at one place. ref1: https://github.com/gefyrahq/gefyra/blob/main/client/gefyra/configuration.py#L233 ref2: https://github.com/gefyrahq/gefyra/blob/main/client/gefyra/__main__.py#L311 ref3: https://github.com/gefyrahq/gefyra/blob/main/client/gefyra/api/run.py#L78

Strict typing Implement a strict typing and check it with mypy for a better code climate and to uncover bugs related with typing, (return) values and data structures.

If there is more, please let me know.

SteinRobert commented 1 year ago

Resolved with v2