Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
It's really just a farely widely scoped refactor, moving all of the code
cmd/kubeseal/main.go
into thepkg/kubeseal
. I've tried to keep the code changes mapped closely to the original. So theseal
function fromcmd/kubeseal/main.go
is now called viakubeseal.Seal
.Also I've tried to separate the cli skeleton from the code where possible. It was previouslt pretty intertwined, but now the functions in the
kubeseal
are mostly pure, and don't rely on global variables. Any CLI arguments needed by the functions are passed in from thecmd/kubeseal/main.go
file.To avoid having large amounts of arguments to certain functions (e.g.
Seal
) I've introduced some 'Instruction' structs. These act largely as DTO's to contain all of the values needed by the functions. I think this makes the functions easier to consume, as the instructions are quite explicit.Benefits
It will allow custom tooling to be built around
kubeseal
without having to rely on external system calls and dependencies.The main driver for myself wanting this, is to make the process of managing secrets a bit simpler for dev teams (or maybe just less scary, for those unfamiliar with k8s). My aim is to build a small wrapper around kubeseal, which will pull secrets from a centralised store (AWS secrets manager, onepassword, bitwarden, vault etc), and will then create a set of sealed secrets files based on the secrets in the store, which can then be committed to the repositories.
I think this actually makes certain components easier to test in isolation which could be an improvement.
Possible drawbacks
In theory I don't really see any drawbacks for this as there aren't any behavioural changes. The library pkg is used from the main command, as well as being exposed, so there shouldn't be any duplication.
The main drawback I think is that this is a pretty large amount of change, and could potentially introduce bugs.
Applicable issues
Additional information
Pretty new to this library and tool, so any suggestions or pointers on the architecture here are more than welcome!
All the tests are passing, and i've compiled the tool locally and tested some scenarios against the latest helm chart running in a kind cluster.