-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[auto/go] Support for remote operations #11168
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changelog[uncommitted] (2022-10-28)Features
|
justinvp
force-pushed
the
justin/remote_go
branch
from
October 28, 2022 01:52
8a98877
to
2abe369
Compare
Frassle
approved these changes
Oct 28, 2022
iwahbe
approved these changes
Oct 28, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
supportsPulumiCmdFlag
is a really great argument for running this through gRPC instead of shelling out to the CLI.
justinvp
force-pushed
the
justin/remote_go
branch
from
October 28, 2022 19:07
2abe369
to
1588e4f
Compare
bors merge |
bors bot
added a commit
that referenced
this pull request
Oct 28, 2022
11168: [auto/go] Support for remote operations r=justinvp a=justinvp This change adds preview support for remote operations in Go's Automation API. Here's an example of using it: ```go package main import ( "context" "fmt" "os" "github.com/pulumi/pulumi/sdk/v3/go/auto" "github.com/pulumi/pulumi/sdk/v3/go/auto/optremotedestroy" "github.com/pulumi/pulumi/sdk/v3/go/auto/optremoteup" ) func main() { // to destroy our program, we can run `go run main.go destroy` var preview, destroy, refresh bool argsWithoutProg := os.Args[1:] destroy := len(argsWithoutProg) > 0 && argsWithoutProg[0] == "destroy" ctx := context.Background() org := "justinvp" projectName := "aws-ts-s3-folder" stackName := auto.FullyQualifiedStackName(org, projectName, "devgo") repo := auto.GitRepo{ URL: "https://github.com/pulumi/examples.git", Branch: "refs/heads/master", ProjectPath: projectName, } env := map[string]auto.EnvVarValue{ "AWS_REGION": {Value: "us-west-2"}, "AWS_ACCESS_KEY_ID": {Value: os.Getenv("AWS_ACCESS_KEY_ID")}, "AWS_SECRET_ACCESS_KEY": {Value: os.Getenv("AWS_SECRET_ACCESS_KEY"), Secret: true}, "AWS_SESSION_TOKEN": {Value: os.Getenv("AWS_SESSION_TOKEN"), Secret: true}, } s, err := auto.UpsertRemoteStackGitSource(ctx, stackName, repo, auto.RemoteEnvVars(env)) if err != nil { fmt.Printf("Failed to create or select stack: %v\n", err) os.Exit(1) } if destroy { stdoutStreamer := optremotedestroy.ProgressStreams(os.Stdout) _, err := s.Destroy(ctx, stdoutStreamer) if err != nil { fmt.Printf("Failed to destroy stack: %v", err) } fmt.Println("Stack successfully destroyed") os.Exit(0) } stdoutStreamer := optremoteup.ProgressStreams(os.Stdout) res, err := s.Up(ctx, stdoutStreamer) if err != nil { fmt.Printf("Failed to update stack: %v\n\n", err) os.Exit(1) } fmt.Println("Update succeeded!") url, ok := res.Outputs["websiteUrl"].Value.(string) if !ok { fmt.Println("Failed to unmarshall output URL") os.Exit(1) } fmt.Printf("URL: %s\n", url) } ``` I will add sanity tests subsequently. 11170: [auto/nodejs] Support for remote operations r=justinvp a=justinvp This change adds preview support for remote operations in Node.js's Automation API. Here's an example of using it: ```ts import * as process from "process"; import { RemoteWorkspace, fullyQualifiedStackName } from "`@pulumi/pulumi/automation";` const args = process.argv.slice(2); const destroy = args.length > 0 && args[0] === "destroy"; const org = "justinvp"; const projectName = "aws-ts-s3-folder"; const stackName = fullyQualifiedStackName(org, projectName, "devnode"); (async function() { const stack = await RemoteWorkspace.createOrSelectStack({ stackName, url: "https://github.com/pulumi/examples.git", branch: "refs/heads/master", projectPath: projectName, }, { envVars: { AWS_REGION: "us-west-2", AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ?? "", AWS_SECRET_ACCESS_KEY: { secret: process.env.AWS_SECRET_ACCESS_KEY ?? "" }, AWS_SESSION_TOKEN: { secret: process.env.AWS_SESSION_TOKEN ?? "" }, }, }); if (destroy) { await stack.destroy({ onOutput: out => process.stdout.write(out) }); console.log("Stack successfully destroyed"); process.exit(0); } const upRes = await stack.up({ onOutput: out => process.stdout.write(out) }); console.log("Update succeeded!"); console.log(`url: ${upRes.outputs.websiteUrl.value}`); })(); ``` I will add sanity tests subsequently. Co-authored-by: Justin Van Patten <jvp@justinvp.com>
justinvp
force-pushed
the
justin/remote_go
branch
from
October 28, 2022 19:56
1588e4f
to
fd1f94f
Compare
Canceled. |
bors merge |
Build succeeded: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds preview support for remote operations in Go's Automation API.
Here's an example of using it:
I will add sanity tests subsequently.