2020-09-18 02:17:34 +02:00
|
|
|
// Copyright 2016-2020, Pulumi Corporation.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
import { ConfigMap, ConfigValue } from "./config";
|
|
|
|
import { ProjectSettings } from "./projectSettings";
|
2020-09-09 01:20:10 +02:00
|
|
|
import { StackSettings } from "./stackSettings";
|
|
|
|
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @alpha
|
|
|
|
*/
|
2020-09-14 05:28:24 +02:00
|
|
|
export interface Workspace {
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* The working directory to run Pulumi CLI commands
|
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
readonly workDir: string;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* The directory override for CLI metadata if set.
|
2020-10-08 04:00:03 +02:00
|
|
|
* This customizes the location of $PULUMI_HOME where metadata is stored and plugins are installed.
|
2020-10-07 09:25:36 +02:00
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
readonly pulumiHome?: string;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* The secrets provider to use for encryption and decryption of stack secrets.
|
|
|
|
* See: https://www.pulumi.com/docs/intro/concepts/config/#available-encryption-providers
|
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
readonly secretsProvider?: string;
|
2021-03-23 07:04:36 +01:00
|
|
|
/**
|
|
|
|
* The version of the underlying Pulumi CLI/Engine.
|
|
|
|
*/
|
2021-03-23 23:09:50 +01:00
|
|
|
readonly pulumiVersion: string;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
2020-10-08 04:00:03 +02:00
|
|
|
* 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.
|
2020-10-07 09:25:36 +02:00
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
program?: PulumiFn;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Environment values scoped to the current workspace. These will be supplied to every Pulumi command.
|
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
envVars: { [key: string]: string };
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns the settings object for the current project if any.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
projectSettings(): Promise<ProjectSettings>;
|
2020-10-07 09:25:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Overwrites the settings object in the current project.
|
|
|
|
* There can only be a single project per workspace. Fails is new project name does not match old.
|
|
|
|
*
|
|
|
|
* @param settings The settings object to save.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
saveProjectSettings(settings: ProjectSettings): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns the settings object for the stack matching the specified stack name if any.
|
|
|
|
*
|
|
|
|
* @param stackName The name of the stack.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
stackSettings(stackName: string): Promise<StackSettings>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* overwrites the settings object for the stack matching the specified stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The name of the stack to operate on.
|
|
|
|
* @param settings The settings object to save.
|
|
|
|
*/
|
|
|
|
saveStackSettings(stackName: string, settings: StackSettings): Promise<void>;
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2020-09-19 23:40:23 +02:00
|
|
|
serializeArgsForOp(stackName: string): Promise<string[]>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2020-09-19 23:40:23 +02:00
|
|
|
postCommandCallback(stackName: string): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns the value associated with the specified stack name and key,
|
|
|
|
* scoped to the Workspace.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to read config from
|
|
|
|
* @param key The key to use for the config lookup
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
getConfig(stackName: string, key: string): Promise<ConfigValue>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns the config map for the specified stack name, scoped to the current Workspace.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to read config from
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
getAllConfig(stackName: string): Promise<ConfigMap>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Sets the specified key-value pair on the provided stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to operate on
|
|
|
|
* @param key The config key to set
|
|
|
|
* @param value The value to set
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
setConfig(stackName: string, key: string, value: ConfigValue): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Sets all values in the provided config map for the specified stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to operate on
|
|
|
|
* @param config The `ConfigMap` to upsert against the existing config.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
setAllConfig(stackName: string, config: ConfigMap): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Removes the specified key-value pair on the provided stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to operate on
|
|
|
|
* @param key The config key to remove
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
removeConfig(stackName: string, key: string): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Removes all values in the provided key list for the specified stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to operate on
|
|
|
|
* @param keys The list of keys to remove from the underlying config
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
removeAllConfig(stackName: string, keys: string[]): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Gets and sets the config map used with the last update for Stack matching stack name.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to refresh
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
refreshConfig(stackName: string): Promise<ConfigMap>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns the currently authenticated user.
|
|
|
|
*/
|
2020-10-06 18:30:47 +02:00
|
|
|
whoAmI(): Promise<WhoAmIResult>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns a summary of the currently selected stack, if any.
|
|
|
|
*/
|
2020-09-19 23:07:02 +02:00
|
|
|
stack(): Promise<StackSummary | undefined>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Creates and sets a new stack with the stack name, failing if one already exists.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to create.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
createStack(stackName: string): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Selects and sets an existing stack matching the stack name, failing if none exists.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to select.
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
selectStack(stackName: string): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Deletes the stack and all associated configuration and history.
|
|
|
|
*
|
|
|
|
* @param stackName The stack to remove
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
removeStack(stackName: string): Promise<void>;
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* Returns all Stacks created under the current Project.
|
|
|
|
* This queries underlying backend and may return stacks not present in the Workspace (as Pulumi.<stack>.yaml files).
|
|
|
|
*/
|
2020-09-18 02:17:34 +02:00
|
|
|
listStacks(): Promise<StackSummary[]>;
|
2020-10-09 18:03:03 +02:00
|
|
|
/**
|
|
|
|
* 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 e.g. "resource"
|
|
|
|
*/
|
|
|
|
installPlugin(name: string, version: string, kind?: string): Promise<void>;
|
|
|
|
/**
|
|
|
|
* 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 e.g. "resource"
|
|
|
|
*/
|
|
|
|
removePlugin(name?: string, versionRange?: string, kind?: string): Promise<void>;
|
|
|
|
/**
|
|
|
|
* Returns a list of all plugins installed in the Workspace.
|
|
|
|
*/
|
|
|
|
listPlugins(): Promise<PluginInfo[]>;
|
2021-01-05 01:45:57 +01:00
|
|
|
/**
|
|
|
|
* 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<Deployment>;
|
|
|
|
/**
|
|
|
|
* 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<void>;
|
2020-09-14 05:28:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* A summary of the status of a given stack.
|
|
|
|
*/
|
2020-10-08 03:31:55 +02:00
|
|
|
export interface StackSummary {
|
|
|
|
name: string;
|
|
|
|
current: boolean;
|
|
|
|
lastUpdate?: string;
|
|
|
|
updateInProgress: boolean;
|
|
|
|
resourceCount?: number;
|
|
|
|
url?: string;
|
|
|
|
}
|
2020-09-22 08:10:43 +02:00
|
|
|
|
2021-01-05 01:45:57 +01:00
|
|
|
/**
|
|
|
|
* Deployment encapsulates the state of a stack deployment.
|
|
|
|
*/
|
|
|
|
export interface Deployment {
|
|
|
|
/**
|
|
|
|
* Version indicates the schema of the encoded deployment.
|
|
|
|
*/
|
|
|
|
version: number;
|
|
|
|
/**
|
|
|
|
* The pulumi deployment.
|
|
|
|
*/
|
|
|
|
// TODO: Expand type to encapsulate deployment.
|
|
|
|
deployment: any;
|
|
|
|
}
|
|
|
|
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* A Pulumi program as an inline function (in process).
|
|
|
|
*/
|
2020-10-02 23:29:47 +02:00
|
|
|
export type PulumiFn = () => Promise<Record<string, any> | void>;
|
2020-10-06 18:30:47 +02:00
|
|
|
|
2020-10-07 09:25:36 +02:00
|
|
|
/**
|
|
|
|
* The currently logged-in Pulumi identity.
|
|
|
|
*/
|
2020-10-06 18:30:47 +02:00
|
|
|
export interface WhoAmIResult {
|
|
|
|
user: string;
|
|
|
|
}
|
2020-10-09 18:03:03 +02:00
|
|
|
|
|
|
|
export interface PluginInfo {
|
|
|
|
name: string;
|
|
|
|
path: string;
|
|
|
|
kind: PluginKind;
|
|
|
|
version?: string;
|
|
|
|
size: number;
|
|
|
|
installTime: Date;
|
|
|
|
lastUsedTime: Date;
|
|
|
|
serverURL: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type PluginKind = "analyzer" | "language" | "resource";
|