Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Problem Currently, there are two methods of authenticating with Pinecone when using the CLI: - Manually logging in to generate an auth token with `pinecone login`. - Manually configuring an API key for the CLI to use with `pinecone config set-api-key "YOUR_KEY"`. There is also one method of swapping the environment that the CLI is targeting ("production" vs. "staging"): - Manually configuring your environment using `pinecone config set-environment "production"`. We've gotten feedback that it would be helpful to allow configuring both API key and the environment value through environment variables rather than needing to explicitly configure them through commands. ## Solution - Update `SecretsViper` and `ConfigViper` to properly bind to environment variables. In both cases we use `viper.SetEnvPrefix("pinecone")` and `viper.BindEnv()` to bind the associated `KeyName`. You can find details about how Viper works here: - https://pkg.go.dev/github.com/spf13/viper#SetEnvPrefix - https://pkg.go.dev/github.com/spf13/viper#BindEnv - What the above does is allows the specific configuration values to read from `PINECONE_API_KEY` and `PINECONE_ENVIRONMENT` as needed. If a user calls `pinecone config set-environment` or `pinecone config set-api-key`, that value will take precedence over the environment value. - Update `README` to be a bit more explicit about different ways of authenticating with the CLI, and which takes precedence. ## 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 Pull this branch down, use `goreleaser` to build, and try various options for authenticating with the CLI. ``` # build CLI locally goreleaser build --single-target --snapshot --clean # try with environment API key export PINECONE_API_KEY="MY_KEY" ./dist/pinecone_darwin_arm64/pinecone index list # try with config API key ./dist/pinecone_darwin_arm64/pinecone config set-api-key "MY_KEY" ./dist/pinecone_darwin_arm64/pinecone index list # try setting the environment export PINECONE_ENVIRONMENT="staging" ./dist/pinecone_darwin_arm64/pinecone index list # above should fail if you haven't swapped your API key to a staging API key unset PINECONE_ENVIRONMENT # clear things and try with login flow ./dist/pinecone_darwin_arm64/pinecone logout unset PINECONE_API_KEY ./dist/pinecone_darwin_arm64/pinecone login ``` --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1207872106532407
- Loading branch information