@zuke/gcloud

← API reference

`@zuke/gcloud` — typed Google Cloud tooling for Zuke builds: the `gcloud`

Symbols

# AccessTokenProvider type
type AccessTokenProvider = unknown

Supplies a Google Cloud OAuth access token for a REST call.

# gcloudAccessToken function
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.

# GcloudRunner type
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.

# GcloudSettings class
class GcloudSettings extends SubcommandSettings

Settings for a gcloud invocation.

MemberSignatureDoc
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.
# GcloudTasks const
const GcloudTasks: GcloudTasksApi

Typed task functions for the gcloud CLI.

# GcloudTasksApi interface
interface GcloudTasksApi

The shape of GcloudTasks.

MemberSignatureDoc
run run(configure?: Configure<GcloudSettings>): Promise<CommandOutput> Run a gcloud command.
# GcpRestOptions interface
interface GcpRestOptions

Common options for a Google REST call: the bearer token and an injectable fetch.

MemberSignatureDoc
token token: string The OAuth access token (see "./auth.ts".gcloudAccessToken).
fetch? fetch?: fetch The fetch implementation; defaults to the global. Overridable for tests.
# GcsListOptions interface
interface GcsListOptions

Options for GcsTasksApi.list: the auth/transport plus an object-name prefix.

MemberSignatureDoc
prefix? prefix?: string Keep only objects whose name starts with this prefix.
# GcsOptions interface
interface GcsOptions

Auth + transport options common to every GcsTasks call.

MemberSignatureDoc
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.
# GcsTasks const
const GcsTasks: GcsTasksApi

Typed Google Cloud Storage JSON operations.

# GcsTasksApi interface
interface GcsTasksApi

The shape of GcsTasks.

MemberSignatureDoc
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).
# resolveAccessToken function
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.

# SecretManagerAccessOptions interface
interface SecretManagerAccessOptions

Options for SecretManagerTasksApi.access: the common options plus a version.

MemberSignatureDoc
version? version?: string The version to access; defaults to "latest".
# SecretManagerOptions interface
interface SecretManagerOptions

Auth + transport + project options common to every SecretManagerTasks call.

MemberSignatureDoc
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.
# SecretManagerTasks const
const SecretManagerTasks: SecretManagerTasksApi

Typed Google Secret Manager operations.

# SecretManagerTasksApi interface
interface SecretManagerTasksApi

The shape of SecretManagerTasks.

MemberSignatureDoc
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.