import { ConfigMap, ConfigValue } from "./config"; import { ProjectSettings } from "./projectSettings"; import { OutputMap, Stack } from "./stack"; import { StackSettings } from "./stackSettings"; import { Deployment, PluginInfo, PulumiFn, StackSummary, WhoAmIResult, Workspace } from "./workspace"; /** * LocalWorkspace is a default implementation of the Workspace interface. * A Workspace is the execution context containing a single Pulumi project, a program, * and multiple stacks. Workspaces are used to manage the execution environment, * providing various utilities such as plugin installation, environment configuration * ($PULUMI_HOME), and creation, deletion, and listing of Stacks. * LocalWorkspace relies on Pulumi.yaml and Pulumi..yaml as the intermediate format * for Project and Stack settings. Modifying ProjectSettings will * alter the Workspace Pulumi.yaml file, and setting config on a Stack will modify the Pulumi..yaml file. * This is identical to the behavior of Pulumi CLI driven workspaces. * * @alpha */ export declare class LocalWorkspace implements Workspace { /** * The working directory to run Pulumi CLI commands */ readonly workDir: string; /** * The directory override for CLI metadata if set. * This customizes the location of $PULUMI_HOME where metadata is stored and plugins are installed. */ readonly pulumiHome?: string; /** * The secrets provider to use for encryption and decryption of stack secrets. * See: https://www.pulumi.com/docs/intro/concepts/config/#available-encryption-providers */ readonly secretsProvider?: string; /** * The inline program `PulumiFn` to be used for Preview/Update operations if any. * If none is specified, the stack will refer to ProjectSettings for this information. */ program?: PulumiFn; /** * Environment values scoped to the current workspace. These will be supplied to every Pulumi command. */ envVars: { [key: string]: string; }; private _pulumiVersion?; /** * The version of the underlying Pulumi CLI/Engine. */ get pulumiVersion(): string; private ready; /** * Creates a workspace using the specified options. Used for maximal control and customization * of the underlying environment before any stacks are created or selected. * * @param opts Options used to configure the Workspace */ static create(opts: LocalWorkspaceOptions): Promise; /** * Creates a Stack with a LocalWorkspace utilizing the local Pulumi CLI program from the specified workDir. * This is a way to create drivers on top of pre-existing Pulumi programs. This Workspace will pick up * any available Settings files (Pulumi.yaml, Pulumi..yaml). * * @param args A set of arguments to initialize a Stack with a pre-configured Pulumi CLI program that already exists on disk. * @param opts Additional customizations to be applied to the Workspace. */ static createStack(args: LocalProgramArgs, opts?: LocalWorkspaceOptions): Promise; /** * Creates a Stack with a LocalWorkspace utilizing the specified inline (in process) Pulumi program. * This program is fully debuggable and runs in process. If no Project option is specified, default project settings * will be created on behalf of the user. Similarly, unless a `workDir` option is specified, the working directory * will default to a new temporary directory provided by the OS. * * @param args A set of arguments to initialize a Stack with and inline `PulumiFn` program that runs in process. * @param opts Additional customizations to be applied to the Workspace. */ static createStack(args: InlineProgramArgs, opts?: LocalWorkspaceOptions): Promise; /** * Selects a Stack with a LocalWorkspace utilizing the local Pulumi CLI program from the specified workDir. * This is a way to create drivers on top of pre-existing Pulumi programs. This Workspace will pick up * any available Settings files (Pulumi.yaml, Pulumi..yaml). * * @param args A set of arguments to initialize a Stack with a pre-configured Pulumi CLI program that already exists on disk. * @param opts Additional customizations to be applied to the Workspace. */ static selectStack(args: LocalProgramArgs, opts?: LocalWorkspaceOptions): Promise; /** * Selects an existing Stack with a LocalWorkspace utilizing the specified inline (in process) Pulumi program. * This program is fully debuggable and runs in process. If no Project option is specified, default project settings * will be created on behalf of the user. Similarly, unless a `workDir` option is specified, the working directory * will default to a new temporary directory provided by the OS. * * @param args A set of arguments to initialize a Stack with and inline `PulumiFn` program that runs in process. * @param opts Additional customizations to be applied to the Workspace. */ static selectStack(args: InlineProgramArgs, opts?: LocalWorkspaceOptions): Promise; /** * Creates or selects an existing Stack with a LocalWorkspace utilizing the specified inline (in process) Pulumi CLI program. * This program is fully debuggable and runs in process. If no Project option is specified, default project settings * will be created on behalf of the user. Similarly, unless a `workDir` option is specified, the working directory * will default to a new temporary directory provided by the OS. * * @param args A set of arguments to initialize a Stack with a pre-configured Pulumi CLI program that already exists on disk. * @param opts Additional customizations to be applied to the Workspace. */ static createOrSelectStack(args: LocalProgramArgs, opts?: LocalWorkspaceOptions): Promise; /** * Creates or selects an existing Stack with a LocalWorkspace utilizing the specified inline Pulumi CLI program. * This program is fully debuggable and runs in process. If no Project option is specified, default project settings will be created * on behalf of the user. Similarly, unless a `workDir` option is specified, the working directory will default * to a new temporary directory provided by the OS. * * @param args A set of arguments to initialize a Stack with and inline `PulumiFn` program that runs in process. * @param opts Additional customizations to be applied to the Workspace. */ static createOrSelectStack(args: InlineProgramArgs, opts?: LocalWorkspaceOptions): Promise; private static localSourceStackHelper; private static inlineSourceStackHelper; private constructor(); /** * Returns the settings object for the current project if any * LocalWorkspace reads settings from the Pulumi.yaml in the workspace. * A workspace can contain only a single project at a time. */ projectSettings(): Promise; /** * Overwrites the settings object in the current project. * There can only be a single project per workspace. Fails if new project name does not match old. * LocalWorkspace writes this value to a Pulumi.yaml file in Workspace.WorkDir(). * * @param settings The settings object to save to the Workspace. */ saveProjectSettings(settings: ProjectSettings): Promise; /** * Returns the settings object for the stack matching the specified stack name if any. * LocalWorkspace reads this from a Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to retrieve settings from. */ stackSettings(stackName: string): Promise; /** * Overwrites the settings object for the stack matching the specified stack name. * LocalWorkspace writes this value to a Pulumi..yaml file in Workspace.WorkDir() * * @param stackName The stack to operate on. * @param settings The settings object to save. */ saveStackSettings(stackName: string, settings: StackSettings): Promise; /** * Creates and sets a new stack with the stack name, failing if one already exists. * * @param stackName The stack to create. */ createStack(stackName: string): Promise; /** * Selects and sets an existing stack matching the stack name, failing if none exists. * * @param stackName The stack to select. */ selectStack(stackName: string): Promise; /** * Deletes the stack and all associated configuration and history. * * @param stackName The stack to remove */ removeStack(stackName: string): Promise; /** * Returns the value associated with the specified stack name and key, * scoped to the current workspace. LocalWorkspace reads this config from the matching Pulumi.stack.yaml file. * * @param stackName The stack to read config from * @param key The key to use for the config lookup */ getConfig(stackName: string, key: string): Promise; /** * Returns the config map for the specified stack name, scoped to the current workspace. * LocalWorkspace reads this config from the matching Pulumi.stack.yaml file. * * @param stackName The stack to read config from */ getAllConfig(stackName: string): Promise; /** * Sets the specified key-value pair on the provided stack name. * LocalWorkspace writes this value to the matching Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to operate on * @param key The config key to set * @param value The value to set */ setConfig(stackName: string, key: string, value: ConfigValue): Promise; /** * Sets all values in the provided config map for the specified stack name. * LocalWorkspace writes the config to the matching Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to operate on * @param config The `ConfigMap` to upsert against the existing config. */ setAllConfig(stackName: string, config: ConfigMap): Promise; /** * Removes the specified key-value pair on the provided stack name. * It will remove any matching values in the Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to operate on * @param key The config key to remove */ removeConfig(stackName: string, key: string): Promise; /** * * Removes all values in the provided key list for the specified stack name * It will remove any matching values in the Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to operate on * @param keys The list of keys to remove from the underlying config */ removeAllConfig(stackName: string, keys: string[]): Promise; /** * Gets and sets the config map used with the last update for Stack matching stack name. * It will overwrite all configuration in the Pulumi..yaml file in Workspace.WorkDir(). * * @param stackName The stack to refresh */ refreshConfig(stackName: string): Promise; /** * Returns the currently authenticated user. */ whoAmI(): Promise; /** * Returns a summary of the currently selected stack, if any. */ stack(): Promise; /** * Returns all Stacks created under the current Project. * This queries underlying backend and may return stacks not present in the Workspace (as Pulumi..yaml files). */ listStacks(): Promise; /** * Installs a plugin in the Workspace, for example to use cloud providers like AWS or GCP. * * @param name the name of the plugin. * @param version the version of the plugin e.g. "v1.0.0". * @param kind the kind of plugin, defaults to "resource" */ installPlugin(name: string, version: string, kind?: string): Promise; /** * Removes a plugin from the Workspace matching the specified name and version. * * @param name the optional name of the plugin. * @param versionRange optional semver range to check when removing plugins matching the given name * e.g. "1.0.0", ">1.0.0". * @param kind he kind of plugin, defaults to "resource". */ removePlugin(name?: string, versionRange?: string, kind?: string): Promise; /** * Returns a list of all plugins installed in the Workspace. */ listPlugins(): Promise; /** * exportStack exports the deployment state of the stack. * This can be combined with Workspace.importStack to edit a stack's state (such as recovery from failed deployments). * * @param stackName the name of the stack. */ exportStack(stackName: string): Promise; /** * importStack imports the specified deployment state into a pre-existing stack. * This can be combined with Workspace.exportStack to edit a stack's state (such as recovery from failed deployments). * * @param stackName the name of the stack. * @param state the stack state to import. */ importStack(stackName: string, state: Deployment): Promise; /** * Gets the current set of Stack outputs from the last Stack.up(). * @param stackName the name of the stack. */ stackOutputs(stackName: string): Promise; /** * serializeArgsForOp is hook to provide additional args to every CLI commands before they are executed. * Provided with stack name, * returns a list of args to append to an invoked command ["--config=...", ] * LocalWorkspace does not utilize this extensibility point. */ serializeArgsForOp(_: string): Promise; /** * postCommandCallback is a hook executed after every command. Called with the stack name. * An extensibility point to perform workspace cleanup (CLI operations may create/modify a Pulumi.stack.yaml) * LocalWorkspace does not utilize this extensibility point. */ postCommandCallback(_: string): Promise; private getPulumiVersion; private runPulumiCmd; } /** * Description of a stack backed by an inline (in process) Pulumi program. */ export interface InlineProgramArgs { /** * The name of the associated Stack */ stackName: string; /** * The name of the associated project */ projectName: string; /** * The inline (in process) Pulumi program to use with Update and Preview operations. */ program: PulumiFn; } /** * Description of a stack backed by pre-existing local Pulumi CLI program. */ export interface LocalProgramArgs { stackName: string; workDir: string; } /** * Extensibility options to configure a LocalWorkspace; e.g: settings to seed * and environment variables to pass through to every command. */ export interface LocalWorkspaceOptions { /** * The directory to run Pulumi commands and read settings (Pulumi.yaml and Pulumi..yaml)l. */ workDir?: string; /** * The directory to override for CLI metadata */ pulumiHome?: string; /** * The inline program `PulumiFn` to be used for Preview/Update operations if any. * If none is specified, the stack will refer to ProjectSettings for this information. */ program?: PulumiFn; /** * Environment values scoped to the current workspace. These will be supplied to every Pulumi command. */ envVars?: { [key: string]: string; }; /** * The secrets provider to use for encryption and decryption of stack secrets. * See: https://www.pulumi.com/docs/intro/concepts/config/#available-encryption-providers */ secretsProvider?: string; /** * The settings object for the current project. */ projectSettings?: ProjectSettings; /** * A map of Stack names and corresponding settings objects. */ stackSettings?: { [key: string]: StackSettings; }; }