-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for apphosting:secrets:describe, alias for functions:secr…
…ets:get to align with gcloud (#6948) * initial commit * initial commit 2 * fix * comments
- Loading branch information
Showing
8 changed files
with
81 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
import { logger } from "../logger"; | ||
import { requireAuth } from "../requireAuth"; | ||
import { listSecretVersions } from "../gcp/secretManager"; | ||
import * as secretManager from "../gcp/secretManager"; | ||
import { requirePermissions } from "../requirePermissions"; | ||
|
||
const Table = require("cli-table"); | ||
|
||
export const command = new Command("apphosting:secrets:describe <secretName>") | ||
.description("Get metadata for secret and its versions.") | ||
.before(requireAuth) | ||
.before(secretManager.ensureApi) | ||
.before(requirePermissions, ["secretmanager.secrets.get"]) | ||
.action(async (secretName: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const versions = await listSecretVersions(projectId, secretName); | ||
|
||
const table = new Table({ | ||
head: ["Name", "Version", "Status", "Create Time"], | ||
style: { head: ["yellow"] }, | ||
}); | ||
for (const version of versions) { | ||
table.push([secretName, version.versionId, version.state, version.createTime]); | ||
} | ||
logger.info(table.toString()); | ||
return { secrets: versions }; | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { requireAuth } from "../requireAuth"; | ||
import { Command } from "../command"; | ||
import { requirePermissions } from "../requirePermissions"; | ||
import * as secretManager from "../gcp/secretManager"; | ||
import * as secrets from "../functions/secrets"; | ||
|
||
export const command = new Command("functions:secrets:describe <KEY>") | ||
.description( | ||
"Get metadata for secret and its versions. Alias for functions:secrets:get to align with gcloud", | ||
) | ||
.before(requireAuth) | ||
.before(secretManager.ensureApi) | ||
.before(requirePermissions, ["secretmanager.secrets.get"]) | ||
.action(secrets.describeSecret); |
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,29 +1,12 @@ | ||
const Table = require("cli-table"); | ||
|
||
import { requireAuth } from "../requireAuth"; | ||
import { Command } from "../command"; | ||
import { logger } from "../logger"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
import { listSecretVersions } from "../gcp/secretManager"; | ||
import { requirePermissions } from "../requirePermissions"; | ||
import * as secretManager from "../gcp/secretManager"; | ||
import * as secrets from "../functions/secrets"; | ||
|
||
export const command = new Command("functions:secrets:get <KEY>") | ||
.description("Get metadata for secret and its versions") | ||
.before(requireAuth) | ||
.before(secretManager.ensureApi) | ||
.before(requirePermissions, ["secretmanager.secrets.get"]) | ||
.action(async (key: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const versions = await listSecretVersions(projectId, key); | ||
|
||
const table = new Table({ | ||
head: ["Version", "State"], | ||
style: { head: ["yellow"] }, | ||
}); | ||
for (const version of versions) { | ||
table.push([version.versionId, version.state]); | ||
} | ||
logger.info(table.toString()); | ||
}); | ||
.action(secrets.describeSecret); |
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
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
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