ref: Separate main.go into a cli builder#49
Merged
Callisto13 merged 1 commit intomainfrom Jun 27, 2022
Merged
Conversation
6f83a24 to
8b93064
Compare
d719c32 to
10e340d
Compare
10e340d to
a247d39
Compare
This commit looks fairly busy, but there is very little new logic. I have broken up the huge `main.go` into individual command files under `pkg/command`. New code can be found in `pkg/flags`, `pkg/defaults` and `pkg/config`. 95% of the content of `pkg/command` is lifted straight from what was originally in `main.go`, the only difference is how the app is constructed. Each command now loads flag values from the context into a Config object which can be used by the command action. Each command action is a function which will be individually unit tested. Previously we were testing all the permutations in integration tests, which was just too much of a pain to do. Now we should be able to use a mocked client. There are a couple of other things that I would like to do: - Add tests around the action funcs - Have another layer between the actions and the client - Have a dialFunc which is passed into the action func. This will be helpful when we add TLS and auth so we don't have to repeat the set up of creds for each command But I am leaving that for now.
a247d39 to
dfdd65b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #24
Closes #42
This commit looks fairly busy, but there is very little new logic.
I have broken up the huge
main.gointo individual command files underpkg/command. New code can be found inpkg/flags,pkg/defaultsandpkg/config. 95% of the content ofpkg/commandis lifted straightfrom what was originally in
main.go, the only difference is how theapp is constructed.
Each command now loads flag values from the context into a Config object
which can be used by the command action. Each command action is a
function which will be individually unit tested. Previously we were
testing all the permutations in integration tests, which was just too
much of a pain to do. Now we should be able to use a mocked client.
There are a couple of other things that I would like to do:
helpful when we add TLS and auth so we don't have to repeat the set up
of creds for each command ref: Move Dial into a separate package #52
But I am leaving that for now.