MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

secret-manager/addSecretVersion.js:17–46  ·  view source on GitHub ↗
(parent = 'projects/my-project/secrets/my-secret')

Source from the content-addressed store, hash-verified

15'use strict';
16
17async 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
48const args = process.argv.slice(2);
49main(...args).catch(console.error);

Callers 1

Calls 1

addSecretVersionFunction · 0.85

Tested by

no test coverage detected