Commit graph

521 commits

Author SHA1 Message Date
evanboyle 7e6a08dbe1 example update 2020-07-28 17:40:25 -07:00
evanboyle 34a86f54be godoc improvements 2020-07-28 17:32:38 -07:00
evanboyle 8a707e27e3 godoc pt. 1 2020-07-27 22:26:39 -07:00
evanboyle 4f653683ce validate project name 2020-07-27 18:51:29 -07:00
evanboyle 114e3c2aff provide defaults for pului.yaml for inline source 2020-07-27 18:22:01 -07:00
Lee Briggs bad67d3242
switch os/user with luser
We make several calls to `os/user`, which uses CGO and means
cross-compilation is not possible. This replaces `os/user` with the
`luser` package, which is a drop-in replacement which does not use `CGO`
2020-07-27 14:44:08 -07:00
evanboyle 45ed471a7d handle and detect runtime errors for inline source 2020-07-26 13:43:33 -07:00
evanboyle 41d6767e32 host error handling, inline concurrent update detection 2020-07-26 12:52:59 -07:00
evanboyle 15b8f03dc3 enable e2e up/pre/ref/dest/rm test for inline source 2020-07-25 15:08:10 -07:00
evanboyle ae76944b77 use ts seeds for random test names 2020-07-25 13:28:57 -07:00
evanboyle b21f4e0f7b inline preview 2020-07-24 10:54:18 -07:00
evanboyle b0468d4166 init inline prototype 2020-07-24 01:31:54 -07:00
evanboyle 0d3203c96d add ability to specify git URL instead of local source 2020-07-22 14:28:03 -07:00
evanboyle 6e7ce72db6 update error formatting 2020-07-21 18:44:53 -07:00
evanboyle e789ae9700 update test 2020-07-21 18:41:36 -07:00
evanboyle acc719e7c1 IsUnexpectedEngineError() 2020-07-21 18:39:35 -07:00
evanboyle be42f75d2c add some comments based on findings 2020-07-21 18:27:31 -07:00
evanboyle 0500aae0e0 IsRuntimeError() 2020-07-21 18:17:38 -07:00
evanboyle c360e4d3f1 Merge branch 'master' of https://github.com/pulumi/pulumi into evan/auto 2020-07-21 16:52:08 -07:00
evanboyle ff81dd8961 IsCompilationError 2020-07-21 16:21:47 -07:00
evanboyle f6bc545809 clean up test 2020-07-17 20:08:45 -07:00
evanboyle cf4e02d517 init error strategy 2020-07-17 20:04:37 -07:00
evanboyle 99d769b903 typo 2020-07-17 11:15:58 -07:00
evanboyle 5faf54cedd lint 2020-07-17 10:59:13 -07:00
evanboyle 5b9f1b60d4 tighten up the interface 2020-07-17 10:14:30 -07:00
Paul Stack 6d09fe32df
Add the ability to copy configs between stacks (#4971) 2020-07-17 11:14:10 +01:00
Pat Gavlin 418e2291a2
Protect against engine event mutation. (#5003)
Certain operations in `engine/diff` mutate engine events during display.
This mutation can occur concurrently with the serialization of the event
for persistence, which causes a panic in the CLI. These changes fix the
offending code and add code that copies each engine event before
persisteing it in order to guard against future issues.
2020-07-16 23:52:31 -07:00
evanboyle 96b9c74bda refresh, e2e test 2020-07-16 19:17:07 -07:00
evanboyle 7ac704125e pulumi stack rm 2020-07-16 18:50:34 -07:00
evanboyle 102dbad5ea destroy 2020-07-16 08:47:04 -07:00
evanboyle 30f0962529 preview 2020-07-16 00:34:13 -07:00
evanboyle c09a1cb351 capture last event from history for UpResult 2020-07-15 23:34:34 -07:00
evanboyle 13746f9c82 set config and secrets upon stack initialization 2020-07-14 23:35:26 -07:00
evanboyle ea6cd84dce add utils to round trip pulumi.yaml and pulumi.stack.yaml 2020-07-14 23:13:45 -07:00
evanboyle ae465a19c9 expose GetUser GetOutputs 2020-07-10 00:55:07 -07:00
evanboyle e08e362a85 init/select stack, improvements 2020-07-09 22:30:52 -07:00
Pat Gavlin 2119601023
Implement PropertyPath.Add. (#4976)
This function adds a property value to another property at a given path,
creating containing properties as required. If the property cannot be
added because of a mismatch between the value types required by the path
and the values present in the destination, the add will fail. If a value
already exists at the given path, the add will succeed.

Related to #1635.
2020-07-07 14:45:36 -07:00
evanboyle 2504db3cd2 prototype 2020-07-07 14:25:11 -07:00
Paul Stack 57b91d553e
Adding the ability to specify a version as a ResourceOption (#4945) 2020-07-07 20:20:01 +01:00
Levi Blackstone 8961f5b0ca
Rename RetrieveTemplate function to RetrieveGitFolder (#4912)
The new name better reflects the functionality for external
consumers of this package.
2020-06-26 15:01:51 -06:00
Evan Boyle 2351fc66cf
Go SDK interfaces should declare impl of Ptr types where appropriate (#4911) 2020-06-26 11:25:53 -07:00
Pat Gavlin 3e6e28af36
Fix lint errors. (#4856)
These errors appear when using golangci-lint 1.27.0.
2020-06-18 14:17:11 -07:00
Levi Blackstone 19a113de7a
Handle invalid UTF-8 characters before RPC calls (#4816)
Several users reported cases where error messages would
cause a panic if they contained accented characters. I wasn't
able to reproduce this failure locally, but tracked down the
panic to logging gRPC calls. The Message field is typed as
a string, which requires all of the characters to be valid UTF-8.

This change runs each log string through the strings.ToValidUTF8
function, which will replace any invalid characters with the
"unknown" character. This should prevent the the logger from
panicking.
2020-06-17 13:30:59 -06:00
Praneet Loke 2513709089
Use the GH webhook payload to parse PR details when CI system is GH Actions (#4817)
* Read the file and parse it. Also use the PR Head SHA instead of the GITHUB_REF if the build type is pull_request.

* Update changelog
2020-06-15 12:49:09 -07:00
Evan Boyle fa69a31c97
Set default namespace for go config for config-less get/try/require (#4802) 2020-06-12 16:35:06 -07:00
Evan Boyle 3d2df8992f
Use appropriate types for go config methods (#4800) 2020-06-10 18:24:05 -07:00
Justin Van Patten b77ec919d4
Install and use dependencies automatically for new Python projects (#4775)
Automatically create a virtual environment and install dependencies in it with `pulumi new` and `pulumi policy new` for Python templates.

This will save a new `virtualenv` runtime option in `Pulumi.yaml` (`PulumiPolicy.yaml` for policy packs):

```yaml
runtime:
  name: python
  options:
    virtualenv: venv
```

`virtualenv` is the path to a virtual environment that Pulumi will use when running `python` commands.

Existing projects are unaffected and can opt-in to using this by setting `virtualenv`, otherwise, they'll continue to work as-is.
2020-06-09 16:42:53 -07:00
Praneet Loke 407896730c
Add GitHub Actions detection and update the Pulumi CI escape hatch with more CI vars (#4758)
* Add GitHub Actions detection. Update the Pulumi CI escape hatch with more CI vars.
2020-06-08 17:24:12 -07:00
Lee Zen 0dac22c360
Escape the path to ensure we fetch plugins correctly (#4733) 2020-05-29 14:59:25 -07:00
Chris Smith f613b6917b
Download plugins from get.pulumi.com (#4692)
* Remove long-since deprecated --cloud-url flag

* Download plugins from get.pulumi.com

* Update CHANGELOG.md

* Use more straight forward TrimSuffix
2020-05-25 09:16:57 -07:00
Justin Van Patten 6b0a845cc1
Support publishing Python policy packs (#4644)
Adds support for publishing Python policy packs to the service, and downloading/using such policy packs when applied to stacks in an organization.
2020-05-22 15:01:15 -07:00
Pat Gavlin e677c7d6dc
[sdk/go] Add support for untagged outputs. (#4640)
With these changes, a resource struct may tag a field with the empty
string. If such a field is present, any resource outputs that were not
unmarshalled into other fields will be unmarshalled into this field,
which must be a `MapOutput`.

Fixes #4629.
2020-05-14 14:43:20 -06:00
Lee Briggs 8c314ec39a
Add brew make targets to sdk makefiles 2020-05-13 20:42:01 -07:00
Paul Stack 48f906e026
Allow pulumi stack export to decrypt secrets (#4046) 2020-05-11 19:16:30 +01:00
Levi Blackstone b445206101
Add ResourceOutput type to Go SDK (#4575) 2020-05-05 21:13:58 -06:00
Pat Gavlin 9b1b9cca24
Makefile: properly encode dependencies (#4541)
This allows for the use of `make -j`, which speeds up a full build
dramatically at the cost of rather incomprehensible logs.
2020-05-04 14:26:52 -07:00
Luke Hoban edf8bf5c30
Support map-typed inputs in Go SDK RegisterResource (#4521)
Adds support for RegisterResource to accept map-typed implementations if Input as well as the existing struct-typed implementations. Currently these must be fully untyped - but both map[string]pulumi.Input and map[string]interface{} are allowed. In the future, it's plausible that a mode where the data itself is a map, but the ElementType implementation returns a struct could be supported, with the struct used to provide type information over the untyped map.
2020-04-30 11:56:47 -07:00
Levi Blackstone d1ba572e1d
Fix infinite recursion bug for Go SDK (#4516)
gatherDependencySet was not checking for Resources
in the dependency set, which could lead to infinite
recursion.
2020-04-28 18:10:07 -06:00
Komal Ali 9cf635ad5a pr changes 2020-04-23 11:16:36 -07:00
Komal Ali cc96df7485 update channel options in go 2020-04-23 11:16:36 -07:00
Justin Van Patten 7f27618e2d
Avoid replace on second update with import applied (#4403)
After importing some resources, and running a second update with the
import still applied, an unexpected replace would occur. This wouldn't
happen for the vast majority of resources, but for some it would.

It turns out that the resources that trigger this are ones that use a
different format of identifier for the import input than they do for the
ID property.

Before this change, we would trigger an import-replacement when an
existing resource's ID property didn't match the import property, which
would be the case for the small set of resources where the input
identifier is different than the ID property.

To avoid this, we now store the `importID` in the statefile, and
compare that to the import property instead of comparing the ID.
2020-04-15 18:52:40 -07:00
Justin Van Patten 33119659e0
Treat config values that start with '0' as strings (#4393)
When setting structured config values using `--path`, we automatically
treat values that can be converted into an integer via `strconv.Atoi` as
an integer, rather than as a string.

However, this ends up converting values like "0123456" into the integer
123456, stripping the leading 0, which isn't desirable for values like
commit SHAs, etc., where you want to keep the 0 (and keep it a string).

This change makes it so that values starting with 0 are not implicitly
converted to an integer; instead such values will remain a string.
2020-04-14 12:40:22 -07:00
stack72 d1c76808af Small linting error after merging feature 2.0 branch 2020-04-14 09:55:18 +01:00
stack72 74df34be75 Re-enabling dockerfile latest, docs and homebrew publishing
These had previously been disabled due to the beta releases. Also
fixes an import path for finding an executable
2020-04-14 09:40:11 +01:00
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls (#3750)

* Switch away from native grpc impl. (#3728)

* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)

* Only retry as long as we get unavailable back.  Anything else continues. (#3769)

* Handle all errors for now. (#3781)


* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes (#4288)

Adjust C# generation

* Replace IDeployment with a sealed class (#4318)

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty (#4320)

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen (#4379)
2020-04-14 09:30:25 +01:00
Evan Boyle 4261b27a5e
fix propagation of secrets for resource inputs/outputs in go sdk (#4387) 2020-04-13 22:48:36 -07:00
Evan Boyle 9d2f40b686
fix unknown status for secrets wrapping unknowns (#4377)
* fix unknown status for secrets wrapping unknowns

* changelog

* add test for secret computed values
2020-04-13 22:47:08 +01:00
Evan Boyle 4bbddafe6c
update remote path for policy pack template tests (#4381) 2020-04-13 14:02:17 -07:00
Evan Boyle fe7877177c
fix stack reference helpers to handle nil values (#4370) 2020-04-12 08:44:08 -07:00
Evan Boyle 779c4144f9
Properly propagate unknowns in go SDK marshaling operations (#4369) 2020-04-11 22:20:03 -07:00
Evan Boyle c3b2439094
Automate execution of go mod download for pulumi new Go templates (#4353) 2020-04-09 16:16:10 -07:00
Evan Boyle cfea357cda
Add runtime.options.binary to Pulumi.yaml to make prebuilt go binaries opt-in (#4338) 2020-04-09 12:21:26 -07:00
Evan Boyle 7382de6b5f
Add Go SDK stack output helpers for String and ID (#4341) 2020-04-09 07:52:34 -07:00
Evan Boyle f50fd69c10
Define merge behavior for go resource options (#4316) 2020-04-07 14:19:33 -07:00
Evan Boyle ab659aa0c1
Reimplement getRequiredPlugins for go sdk (#4297) 2020-04-06 12:30:40 -07:00
Luke Hoban 9e37741916
[Go] Ensure Apply handles nil output values (#4268)
Fixes #4247.
2020-04-01 17:39:01 -07:00
Evan Boyle 8a8f424628
disable go plugin acquisition (#4257) 2020-03-31 23:00:35 -07:00
Luke Hoban dd9ed3c938
Support grpc-js plugin servers (#4253)
In order to support grpc-js gRPC servers, we need to slightly loosen
our checks on plugin readiness.  This change was already in the 2.x
branch, but porting back so that 1.x CLIs can also be compatible.

Fixes #4252.
2020-03-31 14:18:09 -07:00
stack72 a1af9289c3 Move BuildUtil class to sdk
This was still in pkg and wasn't accessible from the scripts location.
This code should be in the go/common location of sdk so that it can be
accessed from within our build scripts

Without this change, we were not able to get access to the Version number
for Python and none of our Python builds have been publishing binaries
2020-03-31 12:07:24 +01:00
Justin Van Patten e6be38e285
PaC: Add initial config support for policy packs (#4233)
The initial config represents any config that was specified programmatically to the Policy Pack, for Policy Packs that support programmatic configuration like AWSGuard.
2020-03-30 12:52:05 -07:00
Tasia Halim 4afaf37b3a fixed bug 2020-03-27 10:25:06 -07:00
Evan Boyle 80f1989600
Removing the need for vendoring (#4167) 2020-03-25 15:57:46 -07:00
Evan Boyle 2408d34c71
Add missing builtin MapArray to the Go SDK (#4144) 2020-03-20 16:51:33 -07:00
Evan Boyle c28c602247
capture std err when getting required plugins for go (#4141)
* capture std err when getting required plugins for go
2020-03-20 14:59:12 -07:00
evanboyle 163444bce6 disable logging test 2020-03-19 14:45:03 -07:00
evanboyle fa47d867fd fix go sdk makefile to run tests 2020-03-19 14:10:48 -07:00
evanboyle a2b368827f fix internal logging usage 2020-03-19 11:45:10 -07:00
evanboyle 31d8f79f35 fix klog initialization 2020-03-19 10:01:10 -07:00
evanboyle 4e44854308 replace glog with klog 2020-03-19 08:56:44 -07:00
evanboyle ec686bbaf6 Merge branch 'master' of https://github.com/pulumi/pulumi into evan/gomod 2020-03-18 17:57:58 -07:00
evanboyle 29dfd65632 fix resource test data path 2020-03-18 17:36:28 -07:00
evanboyle bc4e5bf31c run common tests as a part of go sdk make 2020-03-18 17:32:27 -07:00
evanboyle d3f5bbce48 go fmt 2020-03-18 17:27:02 -07:00
evanboyle 67f6b72caa Revert "move sdk/go/pulumi-language-go -> pkg/cmd/pulumi-language-go"
This reverts commit 7ea547a14d.
2020-03-18 17:14:41 -07:00
evanboyle 6933745342 move pkg/tools -> sdk/go/common/tools 2020-03-18 15:56:58 -07:00
evanboyle a4ec3ec81b move pkg/testing -> sdk/go/common/testing, leave behind pkg/testing/integration 2020-03-18 15:55:41 -07:00
evanboyle 0e9c5989bb move pkg/util/gitutil -> sdk/go/common/util/gitutil 2020-03-18 15:52:09 -07:00
evanboyle df722e974a move pkg/util/archive -> sdk/go/common/util/archive 2020-03-18 15:50:04 -07:00
evanboyle 30e1a5917e move pkg/util/fsutil -> sdk/go/common/util/fsutil 2020-03-18 15:48:38 -07:00
evanboyle 33e23bdf0c move pkg/util/retry -> sdk/go/common/util/retry 2020-03-18 15:47:01 -07:00
evanboyle c1440e48d4 move pkg/util/result -> sdk/go/common/util 2020-03-18 15:45:42 -07:00
evanboyle fa348ceb1b move pkg/util/ciutil -> sdk/go/common/util/ciutil 2020-03-18 15:43:31 -07:00
evanboyle c1d3a8524b move pkg/util/cmdutil -> sdk/go/common/util/cmdutil 2020-03-18 15:39:00 -07:00
evanboyle 7ff46cb4fa move pkg/util/rpcutil -> sdk/go/common/util/rpcutil 2020-03-18 15:37:13 -07:00
evanboyle c3f6ae2451 move pkg/util/logging -> sdk/go/common/util/logging 2020-03-18 15:34:58 -07:00
evanboyle cdfb8608c9 move pkg/encoding -> sdk/go/common/encoding 2020-03-18 15:28:19 -07:00
evanboyle 30df499838 move pkg/version -> sdk/go/common/version 2020-03-18 15:25:25 -07:00
evanboyle 8df534a71e move pkg/diag -> sdk/go/common/diag 2020-03-18 15:09:29 -07:00
evanboyle f754b486b8 move pkg/resource/config -> sdk/go/common/resource/config 2020-03-18 15:03:37 -07:00
evanboyle 67cb405c93 move pkg/apitype -> sdk/common/apitype 2020-03-18 15:00:30 -07:00
evanboyle 70f386a967 move pkg/tokens -> sdk/go/common/tokens 2020-03-18 14:49:56 -07:00
evanboyle 4fe4d48ec5 move pkg/util/mapper -> sdk/go/common/util/mapper 2020-03-18 14:47:37 -07:00
evanboyle 8a87090068 move pkg/util/httputil -> sdk/go/common/util/httputil 2020-03-18 14:45:00 -07:00
evanboyle fccf301d14 move pkg/util/contract -> sdk/go/common/util/contract 2020-03-18 14:40:07 -07:00
evanboyle 8fb3f428b0 move pkg/workspace -> sdk/go/common/workspace 2020-03-18 14:35:53 -07:00
evanboyle dfab571aac move pkg/resource/plugin -> sdk/go/common/resource/plugin 2020-03-18 14:26:24 -07:00
evanboyle fba783caf9 move pkg/resource -> sdk/go/common/resource, but leave nested resource packages 2020-03-18 13:36:19 -07:00
evanboyle 7ea547a14d move sdk/go/pulumi-language-go -> pkg/cmd/pulumi-language-go 2020-03-18 12:49:56 -07:00
Evan Boyle 8b46e71887
Go plugin acquisition (#4060)
These changes implement `GetRequiredPlugins` for Go using a registry
mechanism and an alternate entry point for `pulumi.Run`. Packages that
require plugins are expected to register themselves with the Pulumi SDK.
When `pulumi.Run` is used and the `PULUMI_PLUGINS` envvar is truthy, the
program will dump a JSON-encoded description of its required plugins to
stdout. The language host then uses this description to respond to
2020-03-18 12:41:45 -07:00
Levi Blackstone ee62f38ab9
Add ArrayMap builtin types to Go SDK (#4086)
Add support for maps of arrays of builtin types.
These types are of the form map[string][]builtin.
2020-03-16 20:41:08 -06:00
Levi Blackstone ad1c884aad
Fix lint issue (#4088)
Linter was complaining about possibly nil dereferences,
but these are already checked with an assertion.
2020-03-16 16:45:02 -06:00
Tasia Halim b6e5d2737d
Update Go logging to use LogArgs (#4078) 2020-03-13 13:30:05 -07:00
Tasia Halim ef6f0d4de4
Expose engine logging to Go SDK (#4069)
* expose engine logging to Go SDK

* added comments
2020-03-12 16:00:59 -07:00
Paul Stack 2a24470135
Merge pull request #4030 from pulumi/stack72/allow-go-run-windows
Windows requires applications to have exe extension
2020-03-09 17:36:10 +02:00
Evan Boyle 81b6afa3c7
Revert "GetRequiredPlugins for Go (#3830)" (#4034)
This reverts commit 3a2890c0cd.
2020-03-06 17:50:18 -08:00
Pat Gavlin 3a2890c0cd
GetRequiredPlugins for Go (#3830)
These changes implement `GetRequiredPlugins` for Go using a registry
mechanism and an alternate entry point for `pulumi.Run`. Packages that
require plugins are expected to register themselves with the Pulumi SDK.
When `pulumi.Run` is used and the `PULUMI_PLUGINS` envvar is truthy, the
program will dump a JSON-encoded description of its required plugins to
stdout. The language host then uses this description to respond to
`GetRequiredPlugins`.
2020-03-06 14:30:43 -08:00
Evan Boyle e75dca1207
fix reflect panic (#4027) 2020-03-06 11:01:21 -08:00
stack72 7f86842c68 Windows requires applications to have exe extension
We need to ensure that if the pulumi application is prebuild on
Windows then it will have the exe extension otherwise it's not
a valid windows program

https://github.com/golang/go/wiki/WindowsCrossCompiling
2020-03-06 19:58:57 +02:00
Evan Boyle 3b8ffd5731
Go SDK fix panic when dest is struct and input is ptr (#3986) 2020-03-03 09:07:06 -08:00
Tasia Halim c96271b7a3
Support transformations in Go (#3978)
* started transformations for go sdk

* added first basic test

* added second test with child

* added RegisterStackTransformation

* added a couple tests to lifecycle_test

* update CHANGELOG and test

* included TODO for #3846
2020-03-02 13:59:11 -08:00
Evan Boyle cd0025edb5
properly check for nil input or nil input pointer (#4010) 2020-03-02 12:48:30 -08:00
James Nugent 60eeff3265
Merge pull request #3990 from pulumi/jen20/main-dockerfile-for-proto
Update gRPC library used in Go SDKs and regenerate code with latest tools
2020-02-29 12:46:46 +00:00
Evan Boyle 3627f4ce70
ignore internal properties when unmarshaling (#3996) 2020-02-28 10:01:35 -08:00
James Nugent 652bc7ab75 Upgrade Go gRPC library in go.mod 2020-02-28 11:52:22 +00:00
James Nugent 666c5d5cdc Remove use of github.com/pkg/errors from Go SDK
In preparation for publishing a separate module of the Go SDK for Pulumi
on which providers can depend, we should reduce the dependency footprint
so as to cause end users as few issues as possible with transitive
dependency versioning.

This commit removes all use of `github.com/pkg/errors` from the Go SDK
to that end, replacing it with the standard `errors` package and `fmt`
for error formatting where appropriate. We use the new (as of Go 1.13)
"%w" syntax for wrapping errors, so this code is no longer compatible
with Go 1.12.
2020-02-26 16:27:07 +00:00
Evan Boyle 930adc0504
Add support for secrets in Go SDK (#3938) 2020-02-25 17:45:36 -08:00
Pat Gavlin 0aa208a306
Add comments to Go output resolution (#3975) 2020-02-25 13:26:43 -08:00
Evan Boyle cea807a244
Go aliases (#3853) 2020-02-06 12:02:13 -08:00
Evan Boyle 411f1a179a
Support stack references in Go SDK (#3829) 2020-02-06 10:00:46 -08:00
Pat Gavlin a64616a0f9 Fix three bugs in the Go SDK
- Do not set top-level properties that were not provided
- Check for nil after awaiting inputs
- Check for interface-typed values, which can be produced by `Any`
- Pass a settable value to `awaitInputs` in `Any`
2020-01-27 09:14:23 -08:00
Pat Gavlin 47b7eaf484
Make primitive input types implement pointer types (#3806)
For example, pulumi.String also implements pulumi.StringPtr. This is
consistent with the output of the code generator, and makes optional
inputs much more ergonomic.
2020-01-25 12:19:00 -08:00
Pat Gavlin 2f554d5cdc
Fix an assert in the Go SDK. (#3794)
This assert is not correct in the case of pointer input types, in
particular `pulumi.stringPtr`. Though these types are not assignable,
they are convertible.
2020-01-23 13:07:47 -08:00
Pat Gavlin f9548b3095
Add coverage for pulumi.Fprintf. (#3782)
Just what it says on the tin.
2020-01-21 13:27:46 -08:00
Pat Gavlin 4611cbe645
Add more test coverage for builtins. (#3775)
- Test builtin Apply methods
- Test type-specific ToOutput methods
- Test pointer, array, and map indexers
2020-01-21 09:52:57 -08:00
Pat Gavlin f168bdc1c2
Redesign the Go SDK resource/input/output system. (#3506)
The redesign is focused around providing better static typings and
improved ease-of-use for the Go SDK. Most of the redesign revolves
around three pivots:
- Strongly-typed inputs, especially for nested types
- Struct-based resource and invoke APIs
- Ease-of-use of Apply

1. Strongly-typed inputs

Input is the type of a generic input value for a Pulumi resource.
This type is used in conjunction with Output to provide polymorphism
over strongly-typed input values.

The intended pattern for nested Pulumi value types is to define an
input interface and a plain, input, and output variant of the value
type that implement the input interface.

For example, given a nested Pulumi value type with the following shape:

```
type Nested struct {
    Foo int
    Bar string
}
```

We would define the following:

```
var nestedType = reflect.TypeOf((*Nested)(nil)).Elem()

type NestedInput interface {
    pulumi.Input

    ToNestedOutput() NestedOutput
    ToNestedOutputWithContext(context.Context) NestedOutput
}

type Nested struct {
    Foo int `pulumi:"foo"`
    Bar string `pulumi:"bar"`
}

type NestedInputValue struct {
    Foo pulumi.IntInput `pulumi:"foo"`
    Bar pulumi.StringInput `pulumi:"bar"`
}

func (NestedInputValue) ElementType() reflect.Type {
    return nestedType
}

func (v NestedInputValue) ToNestedOutput() NestedOutput {
    return pulumi.ToOutput(v).(NestedOutput)
}

func (v NestedInputValue) ToNestedOutputWithContext(ctx context.Context) NestedOutput {
    return pulumi.ToOutputWithContext(ctx, v).(NestedOutput)
}

type NestedOutput struct { *pulumi.OutputState }

func (NestedOutput) ElementType() reflect.Type {
    return nestedType
}

func (o NestedOutput) ToNestedOutput() NestedOutput {
    return o
}

func (o NestedOutput) ToNestedOutputWithContext(ctx context.Context) NestedOutput {
    return o
}

func (o NestedOutput) Foo() pulumi.IntOutput {
    return o.Apply(func (v Nested) int {
        return v.Foo
    }).(pulumi.IntOutput)
}

func (o NestedOutput) Bar() pulumi.StringOutput {
    return o.Apply(func (v Nested) string {
        return v.Bar
    }).(pulumi.StringOutput)
}
```

The SDK provides input and output types for primitives, arrays, and
maps.

2. Struct-based APIs

Instead of providing expected output properties in the input map passed
to {Read,Register}Resource and returning the outputs as a map, the user
now passes a pointer to a struct that implements one of the Resource
interfaces and has appropriately typed and tagged fields that represent
its output properties.

For example, given a custom resource with an int-typed output "foo" and
a string-typed output "bar", we would define the following
CustomResource type:

```
type MyResource struct {
    pulumi.CustomResourceState

    Foo pulumi.IntOutput    `pulumi:"foo"`
    Bar pulumi.StringOutput `pulumi:"bar"`
}
```

And invoke RegisterResource like so:

```
var resource MyResource
err := ctx.RegisterResource(tok, name, props, &resource, opts...)
```

Invoke arguments and results are also provided via structs, but use
plain-old Go types for their fields:

```
type MyInvokeArgs struct {
    Foo int `pulumi:"foo"`
}

type MyInvokeResult struct {
    Bar string `pulumi:"bar"`
}

var result MyInvokeResult
err := ctx.Invoke(tok, MyInvokeArgs{Foo: 42}, &result, opts...)
```

3. Ease-of-use of Apply

All `Apply` methods now accept an interface{} as the callback type.
The provided callback value must have one of the following signatures:

	func (v T) U
	func (v T) (U, error)
	func (ctx context.Context, v T) U
	func (ctx context.Context, v T) (U, error)

T must be assignable from the ElementType of the Output. If U is a type
that has a registered Output type, the result of the Apply will be the
corresponding Output type. Otherwise, the result of the Apply will be
AnyOutput.

Fixes https://github.com/pulumi/pulumi/issues/2149.
Fixes https://github.com/pulumi/pulumi/issues/3488.
Fixes https://github.com/pulumi/pulumi/issues/3487.
Fixes https://github.com/pulumi/pulumi-aws/issues/248.
Fixes https://github.com/pulumi/pulumi/issues/3492.
Fixes https://github.com/pulumi/pulumi/issues/3491.
Fixes https://github.com/pulumi/pulumi/issues/3562.
2020-01-18 10:08:37 -05:00
Justin Van Patten 10a960ea4b
PaC: Support Config/getProject/getStack/isDryRun (#3612)
Add support for using `Config`, `getProject()`, `getStack()`, and
`isDryRun()` from Policy Packs.
2019-12-16 22:51:02 +00:00
Evan Boyle 1ca50d4b89
Propagate parent and providers for go SDK calls (#3563) 2019-11-26 13:23:34 -08:00
Evan Boyle c83e4f9ca6
Fix go SDK ReadResource (#3581) 2019-11-25 15:31:12 -08:00
Evan Boyle a47103b49d
fix go sdk delete before replace implementation (#3572) 2019-11-25 14:10:06 -08:00
Evan Boyle 8547ede659
Add Go support for config.*Object (#3526) 2019-11-18 18:53:27 -08:00
Evan Boyle 3ac8dd5285
Add support to the go sdk for IgnoreChanges (#3514) 2019-11-18 16:47:19 -08:00
Evan Boyle 5ae4149af5
Add support for "go run" style execution (#3503) 2019-11-14 09:25:55 -08:00
Pat Gavlin a7f61a59b0
Reimplement Output for Go. (#3496)
- Use a mutex + condition variable instead of a channel for
  synchronizaiton in order to allow multiple calls to resolve/reject
- Properly handle outputs that are resolved to other outputs, especially
  if those outputs are not of exactly type Output
- Remove the Value() methods that allowed prompt access to output values
- Add variants of `Apply` that take a context parameter
- Ensure that resource outputs properly incorporate their resource as
  a dependency
- Make `Output` a plain struct. Uninitialized outputs will be treated as
   resolved and unknown. This makes conversions between output
   types more ergonomic.

Contributes to #3492.
2019-11-12 14:20:06 -08:00
CyrusNajmabadi df06b8fc9b
Add publishing to nuget support (#3416) 2019-10-29 20:14:49 -07:00
Pat Gavlin 82204230e1
Improve tracing support. (#3238)
* Fix some tracing issues.

- Add endpoints for `startUpdate` and `postEngineEventsBatch` so that
  spans for these invocations have proper names
- Inject a tracing span when walking a plan so that resource operations
  are properly parented
- When handling gRPC calls, inject a tracing span into the call's
  metadata if no span is already present so that resource monitor and
  engine spans are properly parented
- Do not trace client gRPC invocations of the empty method so that these
  calls (which are used to determine server availability) do not muddy
  the trace. Note that I tried parenting these spans appropriately, but
  doing so broke the trace entirely.

With these changes, the only unparented span in a typical Pulumi
invocation is a single call to `getUser`. This span is unparented
because that call does not have a context available. Plumbing a context
into that particular call is surprisingly tricky, as it is often called
by other context-less functions.

* Make tracing support more flexible.

- Add support for writing trace data to a local file using Appdash
- Add support for viewing Appdash traces via the CLI
2019-09-16 14:16:43 -07:00
Pat Gavlin 2ab814fd09
Do not resolve missing outputs to inputs in preview. (#3014)
This can cause `apply`s to run on values that may change during an
update, which can lead to unexpected behavior.

Fixes #2433.
2019-08-05 12:44:04 -07:00
Pat Gavlin 1af7449f1a
Remove references to pulumi/glog. (#3009)
This package's flags conflict with those in google/glog. Replace all
references to this package with references to
pulumi/pulumi/pkg/util/logging, and change that package to explicitly
call `flag.CommandLine.Parse` with an empty slice.

This should make it much easier to consume these packages in downstream
repos that have direct or indirect dependencies on google/glog.
2019-07-31 13:23:33 -05:00
James Nugent 7f6a6501ef Depend on pulumi fork of glog.
This removes the need for a replace directive in every downstream `go.mod`.
2019-07-25 16:10:53 -05:00
Paul Stack 02ffff8840
Addition of Custom Timeouts (#2885)
* Plumbing the custom timeouts from the engine to the providers

* Plumbing the CustomTimeouts through to the engine and adding test to show this

* Change the provider proto to include individual timeouts

* Plumbing the CustomTimeouts from the engine through to the Provider RPC interface

* Change how the CustomTimeouts are sent across RPC

These errors were spotted in testing. We can now see that the timeout
information is arriving in the RegisterResourceRequest

```
req=&pulumirpc.RegisterResourceRequest{
           Type:                    "aws:s3/bucket:Bucket",
           Name:                    "my-bucket",
           Parent:                  "urn:pulumi:dev::aws-vpc::pulumi:pulumi:Stack::aws-vpc-dev",
           Custom:                  true,
           Object:                  &structpb.Struct{},
           Protect:                 false,
           Dependencies:            nil,
           Provider:                "",
           PropertyDependencies:    {},
           DeleteBeforeReplace:     false,
           Version:                 "",
           IgnoreChanges:           nil,
           AcceptSecrets:           true,
           AdditionalSecretOutputs: nil,
           Aliases:                 nil,
           CustomTimeouts:          &pulumirpc.RegisterResourceRequest_CustomTimeouts{
               Create:               300,
               Update:               400,
               Delete:               500,
               XXX_NoUnkeyedLiteral: struct {}{},
               XXX_unrecognized:     nil,
               XXX_sizecache:        0,
           },
           XXX_NoUnkeyedLiteral: struct {}{},
           XXX_unrecognized:     nil,
           XXX_sizecache:        0,
       }
```

* Changing the design to use strings

* CHANGELOG entry to include the CustomTimeouts work

* Changing custom timeouts to be passed around the engine as converted value

We don't want to pass around strings - the user can provide it but we want
to make the engine aware of the timeout in seconds as a float64
2019-07-16 00:26:28 +03:00
Pat Gavlin e1a52693dc
Add support for importing existing resources. (#2893)
A resource can be imported by setting the `import` property in the
resource options bag when instantiating a resource. In order to
successfully import a resource, its desired configuration (i.e. its
inputs) must not differ from its actual configuration (i.e. its state)
as calculated by the resource's provider.

There are a few interesting state transitions hiding here when importing
a resource:
1. No prior resource exists in the checkpoint file. In this case, the
   resource is simply imported.
2. An external resource exists in the checkpoint file. In this case, the
   resource is imported and the old external state is discarded.
3. A non-external resource exists in the checkpoint file and its ID is
   different from the ID to import. In this case, the new resource is
   imported and the old resource is deleted.
4. A non-external resource exists in the checkpoint file, but the ID is
   the same as the ID to import. In this case, the import ID is ignored
   and the resource is treated as it would be in all cases except for
   changes that would replace the resource. In that case, the step
   generator issues an error that indicates that the import ID should be
   removed: were we to move forward with the replace, the new state of
   the stack would fall under case (3), which is almost certainly not
   what the user intends.

Fixes #1662.
2019-07-12 11:12:01 -07:00
Justin Van Patten fedfc9b6b4
pulumi update => pulumi up (#2702)
We changed the `pulumi update` command to be `pulumi up` a while back
(`update` is an alias of `up`). This change just makes it so we refer to
the actual command, `pulumi up`, instead of the older `pulumi update`.
2019-05-06 14:00:18 -07:00
Pat Gavlin 6e90ab0341
Add support for explicit delete-before-replace (#2415)
These changes add a new flag to the various `ResourceOptions` types that
indicates that a resource should be deleted before it is replaced, even
if the provider does not require this behavior. The usual
delete-before-replace cascade semantics apply.

Fixes #1620.
2019-01-31 14:27:53 -08:00
Pat Gavlin 35c60d61eb
Follow up on #2369 (#2397)
- Add support for per-property dependencies to the Go SDK
- Add tests for first-class secret rejection in the checkpoint and RPC
  layers and language SDKs
2019-01-28 17:38:16 -08:00
Pat Gavlin 1ecdc83a33 Implement more precise delete-before-replace semantics. (#2369)
This implements the new algorithm for deciding which resources must be
deleted due to a delete-before-replace operation.

We need to compute the set of resources that may be replaced by a
change to the resource under consideration. We do this by taking the
complete set of transitive dependents on the resource under
consideration and removing any resources that would not be replaced by
changes to their dependencies. We determine whether or not a resource
may be replaced by substituting unknowns for input properties that may
change due to deletion of the resources their value depends on and
calling the resource provider's Diff method.

This is perhaps clearer when described by example. Consider the
following dependency graph:

  A
__|__
B   C
|  _|_
D  E F

In this graph, all of B, C, D, E, and F transitively depend on A. It may
be the case, however, that changes to the specific properties of any of
those resources R that would occur if a resource on the path to A were
deleted and recreated may not cause R to be replaced. For example, the
edge from B to A may be a simple dependsOn edge such that a change to
B does not actually influence any of B's input properties. In that case,
neither B nor D would need to be deleted before A could be deleted.

In order to make the above algorithm a reality, the resource monitor
interface has been updated to include a map that associates an input
property key with the list of resources that input property depends on.
Older clients of the resource monitor will leave this map empty, in
which case all input properties will be treated as depending on all
dependencies of the resource. This is probably overly conservative, but
it is less conservative than what we currently implement, and is
certainly correct.
2019-01-28 09:46:30 -08:00
Matt Ellis b5450d41af Use Infof instead of Infoln when we have format strings 2018-11-08 14:11:52 -08:00
Matt Ellis 6c7092ff65 Pass -count=1 to disable result caching on go 1.10 and above 2018-11-08 14:11:52 -08:00
Matt Ellis 992b048dbf Adopt golangci-lint and address issues
We run the same suite of changes that we did on gometalinter. This
ended up catching a few new issues, some of which were addressed and
some of which were baselined.
2018-11-08 14:11:47 -08:00
Pat Gavlin 6f37445782
Fix a few issues in the Go language provider (#2113)
1. Add support for first-class providers
2. Make `pulumi.ResourceState` conform to the `pulumi.Resource` interface
3. Wait for inputs to resolve inside RPC goroutines rather than doing so
   before starting the goroutines

Note that (2) involves a breaking change to `pulumi.ResourceState` that
will require adjusting `tfgen`'s code generation.

Fixes https://github.com/pulumi/pulumi-terraform/issues/256
Contributes to #1713
2018-11-01 21:27:35 -07:00
joeduffy 162157c1a7 Add a Dockerfile for the Pulumi CLI
This introduces a Dockerfile for the Pulumi CLI. This makes it
easier to develop and test the engine in a self-contained environment,
in addition to being suitable for running the actual CLI itself.

For instance,

    $ docker run pulumi/pulumi -e "PULUMI_ACCESS_TOKEN=x" up

will run the Pulumi program mounted under the /app volume. This will
be used in some upcoming CI/CD scenarios.

This uses multi-stage builds, and Debian Stretch as the base, for
relatively fast and lean build times and resulting images. We are
intentional about restoring dep packages independent of the actual
source code so that we don't end up needlessly re-depping, which can
consume quite a bit of time. After fixing
https://github.com/pulumi/pulumi/issues/1986, we should explore an
Alpine base image option.

I made the decision to keep this image scoped to just the Go builds.
Therefore, none of the actual SDK packages themselves are built, just
the engine, CLI, and language plugins for Node.js, Python, and Go.
It's possible to create a mega-container that has all of these full
environments so that we can rebuild them too, but for now I figured
it was better to rely on package management for them.

Another alternative would have been to install released binaries,
rather than building them. To keep the useful flow for development,
however, I decided to go the build route for now. If we build at the
same hashes, the resulting binaries "should" be ~identical anyhow.

I've created a pulumi/pulumi Docker Hub repo that we can publish this
into. For now, there is no CI publishing of the image.

This fixes pulumi/pulumi#1991.
2018-09-29 11:48:21 -07:00
Nate Jones 0ea261baf4 Pass environment through to go language programs (#1965)
This allows those programs to use authentication credentials that are
in the environment to perform extra work.
2018-09-20 15:17:18 -07:00
Nate Jones 88efd73282 Search for Go project executables in more places than just $PATH (#1955)
* Search for Go project executables in more places than just $PATH

This searches the following in preferred order:

1. Local directory
2. $GOPATH/bin
3. In $PATH

* Check if program is not a directory before executing
2018-09-19 15:22:33 -07:00
Nate Jones 10449c2991 Implement RegisterResourceOutputs so that outputs in Go work (#1954)
Fixes #1519
2018-09-18 15:32:30 -07:00
Matt Ellis c8b1872332
Merge pull request #1698 from pulumi/ellismg/fix-1581
Allow eliding name in pulumi.Config .ctor
2018-08-08 14:16:20 -07:00
Thomas Schersach 62463ab3bc Added dist target for make, will help with Homebrew (#1731)
* Added dist target for make, will help with Homebrew

* Try to install go dependencies before building

* Make sure dep ensure is called before trying to build SDKs

* Removed dep ensure from dist initial step
2018-08-08 13:00:42 -07:00
Matt Ellis 153729683a Allow eliding name in pulumi.Config .ctor
When this argument is not provided, we'll default to the value of
pulumi.getProject(). This is what you want for application level code
anyway and it matches the CLI behavior where if you don't qualify a
key with a package we use the name of the current project.

Fixes #1581
2018-08-06 16:03:54 -07:00
Pat Gavlin e6849a283f Appease linters.
- Fix a couple self-assignment issues in the Go language support
- Disable `megacheck` for `fh.SetModTime`, which we use for go1.9
  compat.
2018-06-11 14:32:27 -07:00
Joe Duffy fbb054e742
Protect against nil responses (#1484) 2018-06-11 07:43:41 -07:00
joeduffy 5460520b53 Fix a *facepalm* 2018-06-10 12:36:14 -07:00
joeduffy 906d2fd2e0 Support string type aliases 2018-06-10 12:09:45 -07:00
joeduffy f1aec12df2 Avoid aliasing *Output when possible 2018-06-10 11:54:11 -07:00
joeduffy 48ddf5b3b0 Fix a few things
1) Use a state block for *Outputs, just to protect against dereferencing
   and aliasing.  These are mutable due to concurrency.

2) Dig into *Output type aliases, like *URNOutput, et. al, during
   RPC marshaling.
2018-06-10 11:45:24 -07:00
joeduffy b19ecd6602 Add a basic Go configuration integration test 2018-06-10 09:24:57 -07:00
joeduffy b28f643164 Add integration test support for Go
This adds integration test support framework for Go.

It also adds a test case for the basic empty Pulumi Go program.
2018-06-10 09:17:19 -07:00
joeduffy b10b7d9b8a Implement ReadResource RPC functionality 2018-06-10 08:51:30 -07:00
joeduffy b0556c4416 Fix lint warnings on documentation 2018-06-10 08:08:02 -07:00
joeduffy 150ed84636 Implement context invoke function 2018-06-10 08:05:49 -07:00
joeduffy da0667ef45 Add config package
This change adds a config package.  This is syntactic sugar atop the
underlying config functionality in the pulumi.Context, but mirrors what
we do in our other Node.js and Python SDKs more closely.

This includes three families of functions:

    - config.Get*: returns the value or its default if missing.
    - config.Require*: returns the value or panics if missing.
    - config.Try*: returns the value or an error if missing.

In all cases, there are simple Get/Require/Try functions, that just
deal in terms of strings, in addition to type specific functions,
GetT/RequireT/TryT, for the most common Ts that you might need.
2018-06-10 07:24:38 -07:00
joeduffy cf1cb2d61f Get lint clean 2018-06-09 17:23:12 -07:00
joeduffy 20af051caf Implement unknown outputs
This commit implements unknown outputs in the same style as our Node.js
language provider.  That is to say, during previews, it's possible that
certain outputs will not have known values.  In those cases, we want to
flow sufficient information through the resolution of values, so that we
may skip applies.  We also return this fact from the direct accessors.
2018-06-09 16:59:53 -07:00
joeduffy 5a71ab9d12 Add Makefile machinery for Go provider 2018-06-09 16:16:35 -07:00
joeduffy 25b1a0c9c3 Wire up RegisterResource to unmarshalOutputs 2018-06-09 16:16:07 -07:00
joeduffy 6e52490706 Fix a bunch of lint warnings 2018-06-09 11:33:45 -07:00
joeduffy 2e8bbcc9dd Add output marshaling and improve input marsalling
This change primarily does two things:

* Adds output marshaling.

* Adds tests for roundtripping inputs to outputs.

It also

* Fixes a bug in the verification of asset archives.

* Change input types to simply `interface{}` and `map[string]interface{}`.
  There is no need for wrapper types.  This is more idiomatic.

* Reject output properties upon marshaling failure.

* Don't support time.Time as a marshaling concept.  This was getting too
  cute.  It's not clear what its marshaling format ought to be.
2018-06-09 09:11:35 -07:00
joeduffy c3b13348d0 Improve strong typing
This improves the strong typing of output properties, by leveraging the
cast library to support numeric conversions to and from many types,
without hitting interface{}-cast panics.  Also adds strongly typed
applies and adds a number of additional tests for these functions.
2018-06-08 12:57:59 -07:00
joeduffy 74a896bb7a Add strongly typed outputs
This change adds some convenience functions and types, to make strongly
typed outputs more pleasant to interact with.  It also includes tests
for output generally, in addition to these new functions and types.
2018-06-08 10:36:10 -07:00
joeduffy 7d8995991b Support Pulumi programs written in Go
This adds rudimentary support for Pulumi programs written in Go.  It
is not complete yet but the basic resource registration works.

Note that, stylistically speaking, Go is a bit different from our other
languages.  This made it a bit easier to build this initial prototype,
since what we want is actually a rather thin veneer atop our existing
RPC interfaces.  The lack of generics, however, adds some friction and
is something I'm continuing to hammer on; this will most likely lead to
little specialized types (e.g. StringOutput) once the dust settles.

There are two primary components:

1) A new language host, `pulumi-language-go`, which is responsible for
   communicating with the engine through the usual gRPC interfaces.
   Because Go programs are pre-compiled, it very simply loads a binary
   with the same name as the project.

2) A client SDK library that Pulumi programs bind against.  This exports
   the core resource types -- including assets -- properties -- including
   output properties -- and configuration.

Most remaining TODOs are marked as such in the code, and this will not
be merged until they have been addressed, and some better tests written.
2018-06-08 10:36:10 -07:00
joeduffy 200fecbbaa Implement initial Lumi-as-a-library
This is the initial step towards redefining Lumi as a library that runs
atop vanilla Node.js/V8, rather than as its own runtime.

This change is woefully incomplete but this includes some of the more
stable pieces of my current work-in-progress.

The new structure is that within the sdk/ directory we will have a client
library per language.  This client library contains the object model for
Lumi (resources, properties, assets, config, etc), in addition to the
"language runtime host" components required to interoperate with the
Lumi resource monitor.  This resource monitor is effectively what we call
"Lumi" today, in that it's the thing orchestrating plans and deployments.

Inside the sdk/ directory, you will find nodejs/, the Node.js client
library, alongside proto/, the definitions for RPC interop between the
different pieces of the system.  This includes existing RPC definitions
for resource providers, etc., in addition to the new ones for hosting
different language runtimes from within Lumi.

These new interfaces are surprisingly simple.  There is effectively a
bidirectional RPC channel between the Lumi resource monitor, represented
by the lumirpc.ResourceMonitor interface, and each language runtime,
represented by the lumirpc.LanguageRuntime interface.

The overall orchestration goes as follows:

1) Lumi decides it needs to run a program written in language X, so
   it dynamically loads the language runtime plugin for language X.

2) Lumi passes that runtime a loopback address to its ResourceMonitor
   service, while language X will publish a connection back to its
   LanguageRuntime service, which Lumi will talk to.

3) Lumi then invokes LanguageRuntime.Run, passing information like
   the desired working directory, program name, arguments, and optional
   configuration variables to make available to the program.

4) The language X runtime receives this, unpacks it and sets up the
   necessary context, and then invokes the program.  The program then
   calls into Lumi object model abstractions that internally communicate
   back to Lumi using the ResourceMonitor interface.

5) The key here is ResourceMonitor.NewResource, which Lumi uses to
   serialize state about newly allocated resources.  Lumi receives these
   and registers them as part of the plan, doing the usual diffing, etc.,
   to decide how to proceed.  This interface is perhaps one of the
   most subtle parts of the new design, as it necessitates the use of
   promises internally to allow parallel evaluation of the resource plan,
   letting dataflow determine the available concurrency.

6) The program exits, and Lumi continues on its merry way.  If the program
   fails, the RunResponse will include information about the failure.

Due to (5), all properties on resources are now instances of a new
Property<T> type.  A Property<T> is just a thin wrapper over a T, but it
encodes the special properties of Lumi resource properties.  Namely, it
is possible to create one out of a T, other Property<T>, Promise<T>, or
to freshly allocate one.  In all cases, the Property<T> does not "settle"
until its final state is known.  This cannot occur before the deployment
actually completes, and so in general it's not safe to depend on concrete
resolutions of values (unlike ordinary Promise<T>s which are usually
expected to resolve).  As a result, all derived computations are meant to
use the `then` function (as in `someValue.then(v => v+x)`).

Although this change includes tests that may be run in isolation to test
the various RPC interactions, we are nowhere near finished.  The remaining
work primarily boils down to three things:

    1) Wiring all of this up to the Lumi code.

    2) Fixing the handful of known loose ends required to make this work,
       primarily around the serialization of properties (waiting on
       unresolved ones, serializing assets properly, etc).

    3) Implementing lambda closure serialization as a native extension.

This ongoing work is part of pulumi/pulumi-fabric#311.
2017-09-04 11:35:20 -07:00
joeduffy 5fb014e53c Explicitly track default properties
This changes the RPC interfaces between Lumi and provider ever so
slightly, so that we can track default properties explicitly.  This
is required to perform accurate diffing between inputs provided by
the developer, inputs provided by the system, and outputs.  This is
particularly important for default values that may be indeterminite,
such as those we use in the bridge to auto-generate unique IDs.
Otherwise, we fail to reapply defaults correctly, and trick the
provider into thinking that properties changed when they did not.

This is a small step towards pulumi/lumi#306, in which we will defer
even more responsibility for diffing semantics to the providers.
2017-07-31 18:26:15 -07:00
joeduffy 00442b73b4 Alter the way unknown properties are serialized
This change serializes unknown properties anywhere in the entire
property structure, including deeply embedded inside object maps, etc.

This is now done in such a way that we can recover both the computed
nature of the serialized property, along with its expected eventual
type, on the other side of the RPC boundary.

This will let us have perfect fidelity with the new bridge's view on
computed properties, rather than special casing them on "one side".
2017-07-21 14:00:30 -07:00
joeduffy 4e02105355 Pass old state to the provider's API 2017-07-21 14:00:30 -07:00
joeduffy ae92e68902 Return state as part of Create and Update¬
As part of the bridge bringup, I've discoverd that the property state
returned from Creates does *not* always equal the state that is then
read from calls to Get.  (I suspect this is a bug and that they should
be equivalent, but I doubt it's fruitfal to try and track down all
occurrences of this; I bet it's widespread).  To cope with this, we will
return state from Create and Update, instead of issuing a call to Get.
This was a design we considered to start with and frankly didn't have
a super strong reason to do it the current way, other than that it seemed
elegant to place all of the Get logic in one place.

Note that providers may choose to return nil, in which case we will read
state from the provider in the usual Get style.
2017-07-21 14:00:29 -07:00
joeduffy 06ad983541 Add a ReadLocations engine-side RPC function
This adds a ReadLocations RPC function to the engine interface, alongside
the singular ReadLocation.  The plural function takes a single token that
represents a module or class and we will then return all of the module
or class (static) properties that are currently known.
2017-07-01 13:26:49 -07:00
joeduffy d7093188f0 Introduce an interface to read config
This change adds an engine gRPC interface, and associated implementation,
so that plugins may do interesting things that require "phoning home".
Previously, the engine would fire up plugins and talk to them directly,
but there was no way for a plugin to ask the engine to do anything.

The motivation here is so that plugins can read evaluator state, such
as config information, but this change also allows richer logging
functionality than previously possible.  We will still auto-log any
stdout/stderr writes; however, explicit errors, warnings, informational,
and even debug messages may be written over the Log API.
2017-06-20 19:45:07 -07:00
joeduffy d044720045 Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.

The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.

The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine.  It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.

There are two other sources, however.  First, a nullSource, which simply
refuses to create new objects.  This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment.  Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.

Boatloads of code is now changed and updated in the various CLI commands.

This further chugs along towards pulumi/lumi#90.  The end is in sight.
2017-06-13 07:10:13 -07:00
joeduffy d79c41f620 Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.

In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways.  Namely,
operations against Latent<T>s generally produce new Latent<U>s.

During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values.  An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange.  As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values.  My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.

For now, using an unresolved Latent<T> in a conditional will lead
to an error.  See pulumi/lumi#67.  Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support.  That is a missing 1/3.

Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values.  Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-06-01 08:32:12 -07:00
joeduffy dafeb77dff Rename Coconut to Lumi
This is part of pulumi/coconut#147.

After it has landed, I will rename the repo on GitHub.
2017-05-18 11:38:28 -07:00
joeduffy 47ef3f673b Rename PreviewUpdate (again)
Unfortunately, this wasn't a great name.  The old one stunk, but the
new one was misleading at best.  The thing is, this isn't about performing
an update -- it's about NOT doing an update, depending on its return value.
Further, it's not just previewing the changes, it is actively making a
decision on what to do in response to them.  InspectUpdate seems to convey
this and I've unified the InspectUpdate and Update routines to take a
ChangeRequest, instead of UpdateRequest, to help imply the desired behavior.
2017-04-27 11:18:49 -07:00
joeduffy d6abea728c Add outputs to the Create provider's return
In order to support output properties (pulumi/coconut#90), we need to
modify the Create gRPC interface for resource providers slightly.  In
addition to returning the ID, we need to also return any properties
computed by the AWS provider itself.  For instance, this includes ARNs
and IDs of various kinds.  This change simply propagates the resources
but we don't actually support reading the outputs just yet.
2017-04-21 14:15:06 -07:00
joeduffy 0b6e262b46 Rename resource provider methods
This change renames two provider methods:

    * Read becomes Get.

    * UpdateImpact becomes PreviewUpdate.

These just read a whole lot nicer than the old names.
2017-04-20 14:09:00 -07:00
joeduffy bf8bf976de Add a cocogo SDK package
This change adds a rudimentary cocogo SDK package.  The only thing in
here is a cocogo.Resource type which will serve as the base marker for
all resource classes in IDL packages (see pulumi/coconut#133).
2017-04-15 07:47:10 -07:00
joeduffy 705880cb7f Add the ability to specify analyzers
This change adds the ability to specify analyzers in two ways:

1) By listing them in the project file, for example:

        analyzers:
            - acmecorp/security
            - acmecorp/gitflow

2) By explicitly listing them on the CLI, as a "one off":

        $ coco deploy <env> \
            --analyzer=acmecorp/security \
            --analyzer=acmecorp/gitflow

This closes out pulumi/coconut#119.
2017-03-11 10:07:34 -08:00
joeduffy 45064d6299 Add basic analyzer support
This change introduces the basic requirements for analyzers, as per
pulumi/coconut#119.  In particular, an analyzer can implement either,
or both, of the RPC methods, Analyze and AnalyzeResource.  The former
is meant to check an overall deployment (e.g., to ensure it has been
signed off on) and the latter is to check individual resources (e.g.,
to ensure properties of them are correct, such as checking style,
security, etc. rules).  These run simultaneous to overall checking.

Analyzers are loaded as plugins just like providers are.  The difference
is mainly in their naming ("analyzer-" prefix, rather than "resource-"),
and the RPC methods that they support.

This isn't 100% functional since we need a way to specify at the CLI
that a particular analyzer should be run, in addition to a way of
recording which analyzers certain projects should use in their manifests.
2017-03-10 23:49:17 -08:00
joeduffy 6194a59798 Add a pre-pass to validate resources before creating/updating
This change adds a new Check RPC method on the provider interface,
permitting resource providers to perform arbitrary verification on
the values of properties.  This is useful for validating things
that might be difficult to express in the type system, and it runs
before *any* modifications are run (so failures can be caight early
before it's too late).  My favorite motivating example is verifying
that an AWS EC2 instance's AMI is available within the target region.

This resolves pulumi/coconut#107, although we aren't using this
in any resource providers just yet.  I'll add a work item now for that...
2017-03-02 18:15:38 -08:00
joeduffy 523c669a03 Track which updates triggered a replacement
This change tracks which updates triggered a replacement.  This enables
better output and diagnostics.  For example, we now colorize those
properties differently in the output.  This makes it easier to diagnose
why an unexpected resource might be getting deleted and recreated.
2017-03-02 15:24:39 -08:00
joeduffy bd613a33e6 Make replacement first class
This change, part of pulumi/coconut#105, rearranges support for
resource replacement.  The old model didn't properly account for
the cascading updates and possible replacement of dependencies.

Namely, we need to model a replacement as a creation followed by
a deletion, inserted into the overall DAG correctly so that any
resources that must be updated are updated after the creation but
prior to the deletion.  This is done by inserting *three* nodes
into the graph per replacement: a physical creation step, a
physical deletion step, and a logical replacement step.  The logical
step simply makes it nicer in the output (the plan output shows
a single "replacement" rather than the fine-grained outputs, unless
they are requested with --show-replace-steps).  It also makes it
easier to fold all of the edges into a single linchpin node.

As part of this, the update step no longer gets to choose whether
to recreate the resource.  Instead, the engine takes care of
orchestrating the replacement through actual create and delete calls.
2017-03-02 09:52:08 -08:00
joeduffy fe0bb4a265 Support replacement IDs
This change introduces a new RPC function to the provider interface;
in pseudo-code:

    UpdateImpact(id ID, t Type, olds PropertyMap, news PropertyMap)
        (bool, PropertyMap, error)

Essentially, during the planning phase, we will consult each provider
about the nature of a proposed update.  This update includes a set of
old properties and the new ones and, if the resource provider will need
to replace the property as a result of the update, it will return true;
in general, the PropertyMap will eventually contain a list of all
properties that will be modified as a result of the operation (see below).

The planning phase reacts to this by propagating the change to dependent
resources, so that they know that the ID will change (and so that they
can recalculate their own state accordingly, possibly leading to a ripple
effect).  This ensures the overall DAG / schedule is ordered correctly.

This change is most of pulumi/coconut#105.  The only missing piece
is to generalize replacing the "ID" property with replacing arbitrary
properties; there are hooks in here for this, but until pulumi/coconut#90
is addressed, it doesn't make sense to make much progress on this.
2017-03-01 09:08:53 -08:00
joeduffy fbb56ab5df Coconut! 2017-02-25 07:25:33 -08:00
joeduffy c120f62964 Redo object monikers
This change overhauls the way we do object monikers.  The old mechanism,
generating monikers using graph paths, was far too brittle and prone to
collisions.  The new approach mixes some amount of "automatic scoping"
plus some "explicit naming."  Although there is some explicitness, this
is arguably a good thing, as the monikers will be relatable back to the
source more readily by developers inspecting the graph and resource state.

Each moniker has four parts:

    <Namespace>::<AllocModule>::<Type>::<Name>

wherein each element is the following:

    <Namespace>     The namespace being deployed into
    <AllocModule>   The module in which the object was allocated
    <Type>          The type of the resource
    <Name>          The assigned name of the resource

The <Namespace> is essentially the deployment target -- so "prod",
"stage", etc -- although it is more general purpose to allow for future
namespacing within a target (e.g., "prod/customer1", etc); for now
this is rudimentary, however, see marapongo/mu#94.

The <AllocModule> is the token for the code that contained the 'new'
that led to this object being created.  In the future, we may wish to
extend this to also track the module under evaluation.  (This is a nice
aspect of monikers; they can become arbitrarily complex, so long as
they are precise, and not prone to false positives/negatives.)

The <Name> warrants more discussion.  The resource provider is consulted
via a new gRPC method, Name, that fetches the name.  How the provider
does this is entirely up to it.  For some resource types, the resource
may have properties that developers must set (e.g., `new Bucket("foo")`);
for other providers, perhaps the resource intrinsically has a property
that explicitly and uniquely qualifies the object (e.g., AWS SecurityGroups,
via `new SecurityGroup({groupName: "my-sg"}`); and finally, it's conceivable
that a provider might auto-generate the name (e.g., such as an AWS Lambda
whose name could simply be a hash of the source code contents).

This should overall produce better results with respect to moniker
collisions, ability to match resources, and the usability of the system.
2017-02-24 14:50:02 -08:00
joeduffy 09c01dd942 Implement resource provider plugins
This change adds basic support for discovering, loading, binding to,
and invoking RPC methods on, resource provider plugins.

In a nutshell, we add a new context object that will share cached
state such as loaded plugins and connections to them.  It will be
a policy decision in server scenarios how much state to share and
between whom.  This context also controls per-resource context
allocation, which in the future will allow us to perform structured
cancellation and teardown amongst entire groups of requests.

Plugins are loaded based on their name, and can be found in one of
two ways: either simply by having them on your path (with a name of
"mu-ressrv-<pkg>", where "<pkg>" is the resource package name with
any "/"s replaced with "_"s); or by placing them in the standard
library installation location, which need not be on the path for this
to work (since we know precisely where to look).

If we find a protocol, we will load it as a child process.

The protocol for plugins is that they will choose a port on their
own -- to eliminate races that'd be involved should Mu attempt to
pre-pick one for them -- and then write that out as the first line
to STDOUT (terminated by a "\n").  This is the only STDERR/STDOUT
that Mu cares about; from there, the plugin is free to write all it
pleases (e.g., for logging, debugging purposes, etc).

Afterwards, we then bind our gRPC connection to that port, and create
a typed resource provider client.  The CRUD operations that get driven
by plan application are then simple wrappers atop the underlying gRPC
calls.  For now, we interpret all errors as catastrophic; in the near
future, we will probably want to introduce a "structured error"
mechanism in the gRPC interface for "transactional errors"; that is,
errors for which the server was able to recover to a safe checkpoint,
which can be interpreted as ResourceOK rather than ResourceUnknown.
2017-02-19 11:08:06 -08:00
joeduffy 53a568da87 Modify the ResourceProvider.Update API
This changes two aspects of the ResourceProvider.Update RPC API:

1. Update needs to return an ID, in case the resource had to be
   recreated in response to the request.

2. Include both the old and the new values for properties that are
   being updated.
2017-02-11 13:14:29 -08:00
joeduffy 11b7880547 Further reshuffle Protobufs; generate JavaScript code
After a bit more thinking, we will create new SDK packages for each
of the languages we wish to support writing resource providers in.
This is where the RPC goo will live, so I have created a new sdk/
directory, moved the Protobuf/gRPC definitions underneath sdk/proto/,
and put the generated code into sdk/go/ and sdk/js/.
2017-02-10 09:28:46 -08:00