@zuke/gcloud
`@zuke/gcloud` — typed Google Cloud tooling for Zuke builds: the `gcloud`
@zuke/gcloud on JSR ↗ 16 symbols
Symbols
type AccessTokenProvider = unknown Supplies a Google Cloud OAuth access token for a REST call.
function gcloudAccessToken(run?: GcloudRunner): Promise<string> The default AccessTokenProvider: the trimmed stdout of gcloud auth print-access-token, run with --quiet so the token never streams to the build log. run defaults to "./gcloud.ts".GcloudTasks .run and is injectable for tests.
type GcloudRunner = unknown Runs a gcloud command — the seam gcloudAccessToken resolves the token through. Defaults to "./gcloud.ts".GcloudTasks .run; injectable so the default provider is unit-testable without invoking gcloud.
class GcloudSettings extends SubcommandSettings Settings for a gcloud invocation.
| Member | Signature | Doc |
|---|---|---|
containerImagesAddTag | containerImagesAddTag(source: string, ...destinations: string[]): this | Add tags to a container image across registries: gcloud container images add-tag <source> <destination…>. Each argument is a discrete argv token, so an image reference can't inject flags. Runs with --quiet (the re-tag is non-interactive automation; add-tag otherwise prompts for confirmation). |
sqlInstancesDescribe | sqlInstancesDescribe(instance: string): this | Describe a Cloud SQL instance: gcloud sql instances describe <instance>. Add .format("json") to get a machine-readable body to parse from the command's stdout. |
sqlOperationsWait | sqlOperationsWait(operation: string): this | Block until a Cloud SQL operation completes: gcloud sql operations wait <operation> — the typed form of the poll-an-operation shell loop. |
project | project(id: string): this | Target Google Cloud project (--project). |
account | account(email: string): this | Account to run as (--account). |
configuration | configuration(name: string): this | Named gcloud configuration to use (--configuration). |
format | format(value: string): this | Output format, e.g. json, yaml, value(name) (--format). |
verbosity | verbosity(level: string): this | Logging verbosity: debug, info, warning, error, … (--verbosity). |
noPrompt | noPrompt(): this | Disable interactive prompts, accepting defaults (gcloud's --quiet). Named noPrompt to avoid clashing with the base .quiet(), which suppresses Zuke's own output streaming. |
const GcloudTasks: GcloudTasksApi Typed task functions for the gcloud CLI.
interface GcloudTasksApi The shape of GcloudTasks.
| Member | Signature | Doc |
|---|---|---|
run | run(configure?: Configure<GcloudSettings>): Promise<CommandOutput> | Run a gcloud command. |
interface GcpRestOptions Common options for a Google REST call: the bearer token and an injectable fetch.
| Member | Signature | Doc |
|---|---|---|
token | token: string | The OAuth access token (see "./auth.ts".gcloudAccessToken). |
fetch? | fetch?: fetch | The fetch implementation; defaults to the global. Overridable for tests. |
interface GcsListOptions Options for GcsTasksApi.list: the auth/transport plus an object-name prefix.
| Member | Signature | Doc |
|---|---|---|
prefix? | prefix?: string | Keep only objects whose name starts with this prefix. |
interface GcsOptions Auth + transport options common to every GcsTasks call.
| Member | Signature | Doc |
|---|---|---|
token? | token?: string | A pre-resolved OAuth token; when omitted, tokenProvider supplies one. |
tokenProvider? | tokenProvider?: AccessTokenProvider | Resolves the token when token is omitted (default: "./auth.ts".gcloudAccessToken). |
fetch? | fetch?: fetch | The fetch implementation; defaults to the global. Overridable for tests. |
const GcsTasks: GcsTasksApi Typed Google Cloud Storage JSON operations.
interface GcsTasksApi The shape of GcsTasks.
| Member | Signature | Doc |
|---|---|---|
readJson | readJson(bucket: string, object: string, options?: GcsOptions): Promise<T> | Read object object from bucket and parse its body as JSON. |
writeJson | writeJson(bucket: string, object: string, data: unknown, options?: GcsOptions): Promise<void> | Write data (JSON-serialised) as object object in bucket. |
list | list(bucket: string, options?: GcsListOptions): Promise<string[]> | List object names in bucket (optionally filtered by prefix). |
function resolveAccessToken(options: unknown): Promise<string> Resolve a bearer token from an explicit token or, when it is omitted, the tokenProvider (defaulting to gcloudAccessToken). Shared by the REST task groups so every call resolves auth the same way.
interface SecretManagerAccessOptions Options for SecretManagerTasksApi.access: the common options plus a version.
| Member | Signature | Doc |
|---|---|---|
version? | version?: string | The version to access; defaults to "latest". |
interface SecretManagerOptions Auth + transport + project options common to every SecretManagerTasks call.
| Member | Signature | Doc |
|---|---|---|
project? | project?: string | The Google Cloud project id; when omitted, resolved from the environment. |
token? | token?: string | A pre-resolved OAuth token; when omitted, tokenProvider supplies one. |
tokenProvider? | tokenProvider?: AccessTokenProvider | Resolves the token when token is omitted (default: "./auth.ts".gcloudAccessToken). |
fetch? | fetch?: fetch | The fetch implementation; defaults to the global. Overridable for tests. |
readEnv? | readEnv?: unknown | Reads an environment variable for project resolution; defaults to Deno.env.get. |
const SecretManagerTasks: SecretManagerTasksApi Typed Google Secret Manager operations.
interface SecretManagerTasksApi The shape of SecretManagerTasks.
| Member | Signature | Doc |
|---|---|---|
access | access(name: string, options?: SecretManagerAccessOptions): Promise<string> | Access secret name's payload as a string (version defaults to "latest"). |
addVersion | addVersion(name: string, value: string, options?: SecretManagerOptions): Promise<string> | Add a new version holding value to secret name, creating the secret first if it does not exist (an already-exists 409 is ignored) — the write-before-create idempotency a deploy relies on. Returns the new version's resource name. |