(parent = 'projects/my-project/secrets/my-secret')
| 15 | 'use strict'; |
| 16 | |
| 17 | async function main(parent = 'projects/my-project/secrets/my-secret') { |
| 18 | // [START secretmanager_add_secret_version] |
| 19 | /** |
| 20 | * TODO(developer): Uncomment these variables before running the sample. |
| 21 | */ |
| 22 | // const parent = 'projects/my-project/secrets/my-secret'; |
| 23 | |
| 24 | // Imports the Secret Manager library |
| 25 | const {SecretManagerServiceClient} = require('@google-cloud/secret-manager'); |
| 26 | |
| 27 | // Instantiates a client |
| 28 | const client = new SecretManagerServiceClient(); |
| 29 | |
| 30 | // Payload is the plaintext data to store in the secret |
| 31 | const payload = Buffer.from('my super secret data', 'utf8'); |
| 32 | |
| 33 | async function addSecretVersion() { |
| 34 | const [version] = await client.addSecretVersion({ |
| 35 | parent: parent, |
| 36 | payload: { |
| 37 | data: payload, |
| 38 | }, |
| 39 | }); |
| 40 | |
| 41 | console.log(`Added secret version ${version.name}`); |
| 42 | } |
| 43 | |
| 44 | addSecretVersion(); |
| 45 | // [END secretmanager_add_secret_version] |
| 46 | } |
| 47 | |
| 48 | const args = process.argv.slice(2); |
| 49 | main(...args).catch(console.error); |
no test coverage detected