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

chore: move fetching credentials to util class and minor cleanups #291

Closed
wants to merge 2 commits into from

Conversation

pratik151192
Copy link
Contributor

@pratik151192 pratik151192 commented Jun 28, 2023

Re-used some redundant code. Also wanted to get a feel of the PR/Git ecosystem on the team :)

@pratik151192
Copy link
Contributor Author

I realize my second commit message should have been of the form "Fixing spacing and spotlessJava check issues"; however, we should squash and merge this so it shouldn't matter anyway. One question:

@cprice404
Copy link
Contributor

I realize my second commit message should have been of the form "Fixing spacing and spotlessJava check issues"; however, we should squash and merge this so it shouldn't matter anyway. One question:

* I am not sure how we run the Git workflows locally? I did run the Gradle tools through my IntelliJ which spit out errors associated with spotless checks but didn't find a way to literally run this file on my local https://github.com/momentohq/client-sdk-java/actions/runs/5406490424/workflow?pr=291

Yeah there's not really a way to run the workflows locally, at least not an easy one that I've found.

One approach we can use if the workflow gets too complex is to just put all of the logic into some shell scripts in a scripts directory, and then have the workflow call those, and the developer can also run them before commit if they like.

Thanks for the PR! I will defer to Nate on reviewing the changes since he's done most of the work in this repo.

@@ -14,7 +14,7 @@ _Read this in other languages_: [日本語](README.ja.md)
```bash
MOMENTO_AUTH_TOKEN=<YOUR AUTH TOKEN> ./gradlew basic
```
Example Code: [BasicExmaple.java](lib/src/main/java/momento/client/example/BasicExample.java)
Example Code: [BasicExample.java](lib/src/main/java/momento/client/example/BasicExample.java)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch :)

} catch (SdkException e) {
logger.error("Unable to load credential from environment variable " + AUTH_TOKEN_ENV_VAR, e);
throw e;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

If this was production code this would be an awesome change. However, for the stuff in these example files, we are expecting that users may want to copy/paste code from one of these files directly into their app. So we are trying to avoid them having to navigate through multiple files in the project in their IDE. Or like, if they didn't clone the repo and they are just looking at the code on github, then they'd have to figure out where the util code lived and open two browser tabs to copy all the code they need.

So I think for examples we probably have a preference for "self-sufficient" over DRY. Let me know if you have different thoughts!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that makes total sense. I did see this class called ExampleUtils class which had the utility methods of printing the start and end banners so thought it'd be okay. I will like it to be consistent and get rid of that util as well in that case and make every example class it's own standalone with no helpers. We can also rework on this PR https://github.com/momentohq/client-sdk-java/pull/294/files and have a separate example altogether that uses secrets manager.

Let me know if that makes sense and I can abandon these two PRs and create a fresh one that's more like BasicExampleWithSecretsManager in the examples directory; and also remove any util classes even if it's for the banner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! you nailed it. What happened with that ExampleUtils class is that in Nate's original PR where he created it, he had done exactly what you did with the auth, and I made this same comment. So he unrolled the auth stuff but left the banners, which I didn't care as much about. Personally I have no objection to you rolling those back too.

And yes, we should set up a separate example project to house the secrets manager thing :) that way the gradle build for these basic examples doesn't have a dependency on secrets manager, in case people are copying our gradle project for the examples. We'll need to break up the examples dir into some subdirs for different kinds of examples, which is a thing we did very recently for the node.js SDK and probably needs to happen to all of the SDKs over time. :)

@pratik151192 pratik151192 deleted the add-auth-util branch June 30, 2023 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants