-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure
apiKey
, additionalHeaders
, and host
through environme…
…nt variables (#22) ## Problem There was a request to add additional configuration validation to the Go client as you could make requests with an empty `apiKey`. An empty check and early error return were added in a previous PR when passing `apiKey` directly: https://github.com/pinecone-io/go-pinecone/pull/18/files#diff-37c3a14781b4b6e74bcc0cfc8b2462ee2ae243a720a42669256248a3cb005f01R442-R444 We're also lacking the ability to specify an api key or headers through environment variables like the Python client, which can be a nice UX tweak for options in how you configure the client. Additionally, there's no way to specify a control plane host override, which is useful in situations where we need to hit a staging URL. ## Solution - Refactor `buildClientOptions()` into a method on the `NewClientParams` struct rather than a function which receives the struct. - Add ability to specify `PINECONE_API_KEY`, `PINECONE_ADDITIONAL_HEADERS`, and `PINECONE_CONTROLLER_HOST` through environment variables. I kept the naming aligned with Python for now. - For these values, if the corresponding field has been passed through `NewClientParams` directly, the passed value will override anything set in the environment. - Add unit tests to validate override behavior, and headers being added as expected. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan CI and new unit tests. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1207208972408325 - https://app.asana.com/0/0/1207208968992757
- Loading branch information
1 parent
cbb7f75
commit c7eda0a
Showing
6 changed files
with
322 additions
and
176 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
API_KEY="<Project API Key>" | ||
PINECONE_API_KEY="<Project API Key>" | ||
TEST_POD_INDEX_NAME="<Pod based Index name>" | ||
TEST_SERVERLESS_INDEX_NAME="<Serverless based Index name>" |
This file contains 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
This file contains 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
Oops, something went wrong.