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

Handling Versioning #228

Closed
edgar-durand opened this issue Nov 22, 2023 · 4 comments
Closed

Handling Versioning #228

edgar-durand opened this issue Nov 22, 2023 · 4 comments

Comments

@edgar-durand
Copy link
Contributor

edgar-durand commented Nov 22, 2023

Hello, I just found this awesome library and integrated it in my nestjs api (nestjs/config) with GCP secret manager, it works great, but I am needing to use versions for the secrets, it would be possible to add that feature. I am more than willing to create the PR for it, in case you want it, here is the change I need:

read-value.js

async function readValue({
  client,
  file,
  ignoreSecrets,
  prefix,
  project,
  schema,
}) {
  let { env, secret: schemaSecret, version } = schema;
...
const value = await readSecret({ client, project, secret, version });

...

async function readSecret({
  client,
  isRetry = false,
  project,
  secret,
  version,
}) {
  version ??= 'latest';
  try {
    const name = `projects/${project}/secrets/${secret}/versions/${version}`;

README.md

## How are secrets with multiple versions handled?

The greatest, non-disabled version of the secret will be used by default.
For using a specific version set `version: 'your-version'` in the schema.

```js
const config = await gcpConfig.load({
  project: process.env.GCP_PROJECT,

  schema: {
    foo: {
      version: 1, // Specific version. It is up to you to make sure this version exists or it is enabled.
      secret: 'foo',
    },
  },
});
@phil-booth-qatalog
Copy link
Contributor

Good idea! Yep, we'd totally take a PR for this if you have time to work on it! 👍

@edgar-durand
Copy link
Contributor Author

sure thing, grant me access to create the PR, this is my github account: edgarduranddiaz@gmail.com

@phil-booth-qatalog
Copy link
Contributor

phil-booth-qatalog commented Nov 23, 2023

grant me access to create the PR

I think there should be no need to grant access?

If you fork the repo here:

https://github.com/qatalog/gcp-config-node/fork

...and then make changes in your fork, it should let you open a pull request from there.

(I just tested this works from my personal account, which also doesn't have permissions in this repo)

@edgar-durand
Copy link
Contributor Author

PR open #230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants