/** * gcloud.ts, the gcloud driver for the OAuth (Path B) setup flow. * * Every subprocess call goes through the injected `GoogleCommandPort` (see * `types.ts`) so this module is fully testable without a real gcloud install, * a real Google account, or a real Cloud project. The one real * implementation, `createProcessCommandPort()`, lives in this module's `node` * entry and is the only place that touches `Bun.spawn`. * * Every exported function returns a typed discriminated result and never * throws for an expected failure (gcloud missing, malformed JSON, an empty * project list, and so on). The functions that create or enable things are * idempotent: re-running the flow after a partial success does not create a * second Cloud project or re-enable an already-enabled service. */ export interface GcloudDetected { readonly ok: true; readonly path: string; readonly version: string; } export interface GcloudNotFound { readonly ok: false; readonly problem: string; readonly fix: string; } export type GcloudDetection = GcloudDetected | GcloudNotFound; /** Subset of the command port surface this module depends on. */ import type { GoogleCommandPort } from './types.js'; /** * Where the no-root tarball install pulls the Google Cloud CLI from. * Exported so the node adapter and the runbook name the same URL. */ export declare const GCLOUD_DEFAULT_DOWNLOAD_URL = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz"; /** Default per-command wall clock for the gcloud driver. */ export declare const GCLOUD_DEFAULT_TIMEOUT_MS = 60000; /** Is `gcloud` reachable on PATH, or at the `$HOME/google-cloud-sdk/bin/gcloud` fallback? */ export declare function detectGcloud(port: GoogleCommandPort, homeDirectory: string): Promise; export interface InstallOptions { readonly homeDirectory: string; readonly downloadUrl?: string; } export interface InstallAlreadyInstalled { readonly ok: true; readonly outcome: 'already-installed'; readonly path: string; } export interface InstallInstalled { readonly ok: true; readonly outcome: 'installed'; readonly path: string; } export interface InstallFailed { readonly ok: false; readonly problem: string; readonly fix: string; } export type InstallResult = InstallAlreadyInstalled | InstallInstalled | InstallFailed; /** * No-root tarball install into the home directory. Idempotent: if the binary * already exists at the fallback path, this returns `already-installed` * without downloading anything again. */ export declare function installGcloud(port: GoogleCommandPort, options: InstallOptions): Promise; export interface AuthAccount { readonly ok: true; readonly account: string; } export interface AuthNoActiveAccount { readonly ok: false; readonly problem: string; readonly fix: string; } export type AuthCheckResult = AuthAccount | AuthNoActiveAccount; /** `gcloud auth list --format=json`, parsed. Never logs the account it finds. */ export declare function checkAuthenticated(port: GoogleCommandPort, gcloudPath: string): Promise; export interface GcloudProject { readonly projectId: string; readonly name?: string; } export interface ListProjectsOk { readonly ok: true; readonly projects: readonly GcloudProject[]; } export interface ListProjectsFailed { readonly ok: false; readonly problem: string; readonly fix: string; } export type ListProjectsResult = ListProjectsOk | ListProjectsFailed; /** `gcloud projects list --format=json`, parsed. */ export declare function listProjects(port: GoogleCommandPort, gcloudPath: string): Promise; export interface SelectOrCreateOptions { readonly preferredPrefix: string; } export interface ProjectReused { readonly ok: true; readonly outcome: 'reused'; readonly projectId: string; } export interface ProjectCreated { readonly ok: true; readonly outcome: 'created'; readonly projectId: string; } export interface ProjectSelectFailed { readonly ok: false; readonly problem: string; readonly fix: string; } export type SelectOrCreateResult = ProjectReused | ProjectCreated | ProjectSelectFailed; /** * Idempotent project selection: reuse an existing project whose id starts * with `preferredPrefix`, or create one with a random suffix. Re-running * this after a project already exists never creates a second one. */ export declare function selectOrCreateProject(port: GoogleCommandPort, gcloudPath: string, options: SelectOrCreateOptions): Promise; export interface EnabledServicesOk { readonly ok: true; readonly services: readonly string[]; } export interface EnabledServicesFailed { readonly ok: false; readonly problem: string; readonly fix: string; } export type EnabledServicesResult = EnabledServicesOk | EnabledServicesFailed; /** `gcloud services list --enabled --format=json`, parsed. */ export declare function enabledServices(port: GoogleCommandPort, gcloudPath: string, projectId: string): Promise; export interface EnableServicesOk { readonly ok: true; readonly enabled: readonly string[]; readonly alreadyEnabled: readonly string[]; } export interface EnableServicesFailed { readonly ok: false; readonly problem: string; readonly fix: string; } export type EnableServicesResult = EnableServicesOk | EnableServicesFailed; /** * Idempotent service enablement: diffs against `enabledServices` first and * only enables what is missing, reporting which services were already on. */ export declare function enableServices(port: GoogleCommandPort, gcloudPath: string, projectId: string, services: readonly string[]): Promise; //# sourceMappingURL=gcloud.d.ts.map