Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new install plugin from server function #10955

Merged
merged 13 commits into from Oct 24, 2022
7 changes: 7 additions & 0 deletions sdk/go/auto/example_test.go
Expand Up @@ -368,6 +368,13 @@ func ExampleLocalWorkspace_InstallPlugin() {
w.InstallPlugin(ctx, "aws", "v3.2.0")
}

func ExampleLocalWorkspace_InstallPluginFromServer() {
ctx := context.Background()
// create a workspace from a local project
w, _ := NewLocalWorkspace(ctx, WorkDir(filepath.Join(".", "program")))
w.InstallPluginFromServer(ctx, "scaleway", "v1.2.0", "github://api.github.com/lbrlabs")
}

func ExampleNewLocalWorkspace() {
ctx := context.Background()
// WorkDir sets the working directory for the LocalWorkspace. The workspace will look for a default
Expand Down
9 changes: 9 additions & 0 deletions sdk/go/auto/local_workspace.go
Expand Up @@ -381,6 +381,15 @@ func (l *LocalWorkspace) InstallPlugin(ctx context.Context, name string, version
return nil
}

// InstallPluginFromServer acquires the plugin matching the specified name and version from a third party server.
func (l *LocalWorkspace) InstallPluginFromServer(ctx context.Context, name string, version string, server string) error {
stdout, stderr, errCode, err := l.runPulumiCmdSync(ctx, "plugin", "install", "resource", name, version, "--server", server)
jaxxstorm marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return newAutoError(errors.Wrap(err, "failed to install plugin"), stdout, stderr, errCode)
}
return nil
}

// RemovePlugin deletes the plugin matching the specified name and verision.
func (l *LocalWorkspace) RemovePlugin(ctx context.Context, name string, version string) error {
stdout, stderr, errCode, err := l.runPulumiCmdSync(ctx, "plugin", "rm", "resource", name, version, "--yes")
Expand Down
2 changes: 2 additions & 0 deletions sdk/go/auto/workspace.go
Expand Up @@ -92,6 +92,8 @@ type Workspace interface {
ListStacks(context.Context) ([]StackSummary, error)
// InstallPlugin acquires the plugin matching the specified name and version.
InstallPlugin(context.Context, string, string) error
// InstallPluginFromServer acquires the plugin matching the specified name and version.
InstallPluginFromServer(context.Context, string, string, string) error
jaxxstorm marked this conversation as resolved.
Show resolved Hide resolved
// RemovePlugin deletes the plugin matching the specified name and version.
RemovePlugin(context.Context, string, string) error
// ListPlugins lists all installed plugins.
Expand Down
12 changes: 12 additions & 0 deletions sdk/nodejs/automation/localWorkspace.ts
Expand Up @@ -495,6 +495,17 @@ export class LocalWorkspace implements Workspace {
async installPlugin(name: string, version: string, kind = "resource"): Promise<void> {
await this.runPulumiCmd(["plugin", "install", kind, name, version]);
}
/**
* Installs a plugin in the Workspace, from a third party server.
*
* @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"
* @param server the server to install the plugin from
*/
async installPluginFromServer(name: string, version: string, kind = "resource", server: string): Promise<void> {
jaxxstorm marked this conversation as resolved.
Show resolved Hide resolved
await this.runPulumiCmd(["plugin", "install", kind, name, version, "--server", server]);
}
/**
* Removes a plugin from the Workspace matching the specified name and version.
*
Expand All @@ -514,6 +525,7 @@ export class LocalWorkspace implements Workspace {
args.push("--yes");
await this.runPulumiCmd(args);
}

/**
* Returns a list of all plugins installed in the Workspace.
*/
Expand Down
1 change: 1 addition & 0 deletions sdk/nodejs/tests/automation/localWorkspace.spec.ts
Expand Up @@ -57,6 +57,7 @@ describe("LocalWorkspace", () => {
it(`adds/removes/lists plugins successfully`, asyncTest(async () => {
const ws = await LocalWorkspace.create({});
await ws.installPlugin("aws", "v3.0.0");
await ws.installPluginFromServer("scaleway", "v1.2.0", "resource", "github://api.github.com/lbrlabs");
await ws.removePlugin("aws", "3.0.0");
await ws.listPlugins();
}));
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/lib/pulumi/automation/_local_workspace.py
Expand Up @@ -301,6 +301,9 @@ def list_stacks(self) -> List[StackSummary]:

def install_plugin(self, name: str, version: str, kind: str = "resource") -> None:
self._run_pulumi_cmd_sync(["plugin", "install", kind, name, version])

def install_plugin_from_server(self, name: str, version: str, kind: str = "resource", server: str) -> None:
jaxxstorm marked this conversation as resolved.
Show resolved Hide resolved
self._run_pulumi_cmd_sync(["plugin", "install", kind, name, version, "--server", server])

def remove_plugin(
self,
Expand Down