-
Notifications
You must be signed in to change notification settings - Fork 14
Expose internal packages #317
Description
I've been creating a CLI tool for a client which will be used to automate certain workflows. Part of this work involves working with Lagoon. As such I had hoped to use machinery and quickly found that it doesn't expose a lot of the work done by the lagoon CLI tool. Looking here I was delighted to see some packages exported that did a lot of the work.
However, they are unusable in the current form. Some code in the /pkg/ directory references code from the /internal/ directory, so any project trying to use the exported packages from here, can't use the data types as they are protected.
The solution is quite simple but has far reaching consequences. I've forked this project and moved everything from internal to pkg, updated all code references and recompiled. The tool works exactly as it did before but now I can use the packages from my other project.
When I started my project I was copying chunks of code from lagoon-cli unto my own project. Where it called machinery or other code I imported the relevant packages as needed. There are obvious maintainability issue with that but it did work for trivial use cases.
I'm sure there were good reasons to protect the code in question inside the internal directory but reading it, it looks like it's structured as reusable packages. This worked well for me as it could be easily moved. An expansion of this idea could be to expose a few internal function so they can be used, but that's a different discussion.