Skip to content

Fix auth package to handle fetching token on GCE#84

Merged
shydefoo merged 1 commit into
mainfrom
fix-google-client-issue
Apr 20, 2023
Merged

Fix auth package to handle fetching token on GCE#84
shydefoo merged 1 commit into
mainfrom
fix-google-client-issue

Conversation

@shydefoo
Copy link
Copy Markdown
Collaborator

@shydefoo shydefoo commented Apr 19, 2023

Summary

This PR checks if the Creds object created has an empty JSON byte slice before attempting to unmarshal the byte slice to construct a http client.

The use case is to handle cases when the default credentials are not obtained from GOOGLE_APPLICATION_CREDENTIALS, but other sources like the GCE Metadata server. See here for complete explanation.

Without this check, the error panic: unexpected end of JSON input will be thrown.

@shydefoo shydefoo marked this pull request as ready for review April 19, 2023 10:41
@deadlycoconuts
Copy link
Copy Markdown
Collaborator

LGTM! Thanks for investigating this! 🚀

@shydefoo shydefoo merged commit 2eaf397 into main Apr 20, 2023
@shydefoo shydefoo deleted the fix-google-client-issue branch April 20, 2023 02:42
shydefoo added a commit to caraml-dev/merlin that referenced this pull request Apr 20, 2023
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. Run unit tests and ensure that they are passing
2. If your change introduces any API changes, make sure to update the
e2e tests
3. Make sure documentation is updated for your PR!

-->

**What this PR does / why we need it**:
* ~~Needs #378 to be merged.
Currently changed to use `caraml-dev/mlp` so the MR can be tested with
WI. This will be reverted once #378 is merged.~~
* Updates all references to `github.com/gojek/mlp` to
`github.com/caraml-dev/mlp` in `api`. This was done to use the new
version of mlp, else `go get github.com/caraml-dev/mlp@<new_version>`
throws an error.
* Use mlp version @2eaf397 (currently pointing to
[MR](caraml-dev/mlp#84))
* This new version allows merlin to communicate with mlp api without
specifying `GOOGLE_APPLICATION_CREDENTIALS` env var.

**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes #

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required. Enter your extended release note in
the block below.
If the PR requires additional action from users switching to the new
release, include the string "action required".

For more information about release notes, see kubernetes' guide here:
http://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note

```

**Checklist**

- [ ] Added unit test, integration, and/or e2e tests
- [ ] Tested locally
- [ ] Updated documentation
- [ ] Update Swagger spec if the PR introduce API changes
- [ ] Regenerated Golang and Python client if the PR introduce API
changes
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