Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: instantiate viper and swagger client in root command instead of using singletons #76

Open
BrunoRosendo opened this issue Aug 11, 2022 · 2 comments
Assignees

Comments

@BrunoRosendo
Copy link
Member

BrunoRosendo commented Aug 11, 2022

Currently, some tests are having problems because the client and viper were used as singletons. It'd be better to instantiate them once in newRootCmd() and pass them to the commands that need them, facilitating the way unit tests are done as well.

@BrunoRosendo
Copy link
Member Author

BrunoRosendo commented Sep 1, 2022

The problem with this approach is that the api client uses viper to get the server URL. This means we'll have to pass the viper instance through every command to then pass it to the client, which probably defeats the point of the issue.

We should find another solution for the api client. Maybe we could instantiate the api client in root and pass the client to all the commands

@BrunoRosendo BrunoRosendo self-assigned this Sep 1, 2022
BrunoRosendo added a commit to BrunoRosendo/reana-client-go that referenced this issue Sep 1, 2022
@BrunoRosendo
Copy link
Member Author

Draft PR #119 showcases how this could look like and initiates a discussion on whether it's worth it or not

BrunoRosendo added a commit to BrunoRosendo/reana-client-go that referenced this issue Sep 2, 2022
BrunoRosendo added a commit to BrunoRosendo/reana-client-go that referenced this issue Sep 2, 2022
BrunoRosendo added a commit to BrunoRosendo/reana-client-go that referenced this issue Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant