Commit graph

374 commits

Author SHA1 Message Date
Matt Ellis d0485f11f6 Include Python and Go langhosts in Windows SDK
This change includes the Python and Golang language hosts in the Windows
SDK. As part of this change, I had to adjust how we launched the second
stage of the language host, since we can't depend on the shebang, so now
we invoke `python` passing the executor and then the arguments.

Fixes #1509
2018-06-15 11:12:33 -07:00
Matt Ellis 50c98edd72 Don't set NODE_PATH in dynamic provider
This is a holdover from our old strategy for closure serialization. We
no longer use this module, so we don't need to tell Node where it is
anymore.
2018-06-15 11:12:24 -07:00
Matt Ellis 721bc9ccc6 s/docs.pulumi.com/pulumi.io/g
The docs website is moving to https://pulumi.io from
https://docs.pulumi.com
2018-06-11 15:57:47 -06: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
Sean Gillespie 8a00cb4d3b
Support better previews in Python by mocking out Unknown values (#1482) 2018-06-11 10:30: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
Luke Hoban 858e321110
Make RTTI markers internal (#1479)
Fixes #1477.
2018-06-07 21:34:06 -07:00
Sean Gillespie b5e4d87687
Improve the error message when data source invocations fail (#1472) 2018-06-07 11:21:38 -07:00
Sean Gillespie 5cbc979e17
Fix a couple of issues when projecting Protobuf and UNKNOWN in Python (#1468)
* Fix a few issues with the Python language host

1. Fix an issue where the UNKNOWN sentinel was leaking into user
programs
2. Fix an issue where Protobuf types were leaking into user programs

In fixing this issues I also added a framework for writing tests against
the Python SDK.

* License headers, and adopt a more idiomatic testing pattern

* Additional idiomatic Python

* That's what I get for trying to be fancy (Travis CI python version is very old and does not respect this form)

* CR feedback: use more comprehensions, typo fix

* Break a circular dependency between resource, runtime.resource, and runtime.rpc

* Don't check in .vscode

* CR: sort inputs, rename global variable, add a test for CustomResource serialization

* Remove accidental code duplication
2018-06-06 16:09:07 -07:00
Justin Van Patten 28a05e3085
Suggest npm run build instead of npm build (#1460) 2018-06-04 15:27:29 -07:00
Matt Ellis dcb5ae1e1f Stop including native serialization modules
We retained these modules to support using v0.11.X and earlier
versions of @pulumi/pulumi, which required a native module to do
closure serialization. 0.12.X does not need this, so lets stop
including it.
2018-06-04 14:27:01 -07:00
Luke Hoban 076d8887c9
Compute required packages during closure serialization (#1457)
Closure serialization now keeps track of the `require`d packages it sees in the function bodies that are serialized during a call to `serializeFunction`.

Also, replaces `serializeFunctionAsync` with `serializeFunction` which accepts richer parameters and return type, deprecating the former API (but leaving it available for now to avoid a breaking change).
2018-06-03 21:55:37 -07:00
Matt Ellis 9b24ad9738 Update gRPC to 1.12.2
This version has an updated protobufs dependency, which will remove
the warnings from `npm audit`.

Fixes #1350
2018-05-30 15:42:10 -07:00
Sean Gillespie 38cf2de39e
Issue a better error message if you capture a V8 intrinsic (#1423) 2018-05-24 11:54:31 -07:00
Pat Gavlin a2c30f75ed
Resolve missing outputs as undefined. (#1427)
Before the changes in #1414, all output properties were guaranteed to
have values after deserialization. After #1414, any properties with no
value were no longer resolved, which was treated as an error. These
changes resolve all missing proprties to `undefined`. If a property is
missing during an update, its `undefined` value is marked as known.
2018-05-24 11:22:08 -07:00
Pat Gavlin a16a880518
Discriminate unknown values in the JS runtime. (#1414)
These changes add support for distinguishing an output property with
an unknown value from an output property with a known value that is
undefined.

In a broad sense, the Pulumi property type system is just JSON with the
addition of unknown values. Notably absent, however, are undefined
values. As it stands, our marshalers between JavaScript and Pulumi
property values treat all undefined JavaScript values as unknown Pulumi
values. Unfortunately, this conflates two very different concepts:
unknown Pulumi values are intended to represent values of output
properties that are unknown at time of preview, _not_ values that are
known but undefined. This results in difficulty reasoning about when
transforms are run on output properties as well as confusing output in
the `diff` view of Pulumi preview (user-specifed undefined values are
rendered as unknown values).

As it turns out, we already have a way to decide whether or not an
Output value is known or not: Output.performApply. These changes rename
this property to `isKnown`, clarify its meaning, and take advantage of
the result to decide whether or not an Output value should marshal as
an unknown Pulumi value.

This also allowed these changes to improve the serialization of
undefined object keys and array elements s.t. we better match JavaScript
to JSON serialization behavior (undefined object keys are omitted;
undefined array elements are marshaled as `null`).

Fixes https://github.com/pulumi/pulumi-cloud/issues/483.
2018-05-23 14:47:40 -07:00
Sean Gillespie 1a51507206
Delete Before Create (#1365)
* Delete Before Create

This commit implements the full semantics of delete before create. If a
resource is replaced and requires deletion before creation, the engine
will use the dependency graph saved in the snapshot to delete all
resources that depend on the resource being replaced prior to the
deletion of the resource to be replaced.

* Rebase against master

* CR: Simplify the control flow in makeRegisterResourceSteps

* Run Check on new inputs when re-creating a resource

* Fix an issue where the planner emitted benign but incorrect deletes of DBR-deleted resources

* CR: produce the list of dependent resources in dependency order and iterate over the list in reverse

* CR: deps->dependents, fix an issue with DependingOn where duplicate nodes could be added to the dependent set

* CR: Fix an issue where we were considering old defaults and new inputs
inappropriately when re-creating a deleted resource

* CR: save 'iter.deletes[urn]' as a local, iterate starting at cursorIndex + 1 for dependency graph
2018-05-23 14:43:17 -07:00
joeduffy 5967259795 Add license headers 2018-05-22 15:02:47 -07:00
Joe Duffy 3c0376bb8e
Fix refresh on dynamic providers (#1393)
This changes two primary things about dynamic providers:

1) Always echo back the __provider upon read, even if there is a
   missing read function on the dynamic provider.  In fact, return
   the full input state in that case.

2) Store the __provider in the output state of the dynamic resource,
   in addition to the input state.  My recollection of the "model"
   discussion we had weeks ago was that the output properties are
   mean to capture the state of a resource in its entirety; not having
   this meant that refresh would marshal the outputs only, and find
   on the other side of the RPC boundary that __provider was missing.

Note that an alternative to the latter fix would be to use some hybrid
of input and output state, as we used to do, by merging property maps.
2018-05-20 07:42:24 -07:00
joeduffy 8aca7ab11e Fix pulumi.com hyperlink in README 2018-05-18 11:22:42 -07:00
joeduffy 12a2626c59 Prepare package for public publishing
This adds a warning to the top of the README.md and adds a license
to the package.json (to eliminate the associated warning).
2018-05-18 11:21:32 -07:00
joeduffy 6470adad2a Update the README 2018-05-18 07:41:28 -07:00
Sean Gillespie 82ac202139
Improve the promise leak experience (#1374)
* Fix a bug in promise leak detection that leaked promises when errors occur

* Add an opt-in to the super-verbose debug error message on promise leaks

* Fix a bad merge

* was/were grammar improvement in error message

* Fail the deployment if a debuggable promise leaks
2018-05-17 15:32:39 -07:00
Sean Gillespie 68911900fd
Graceful shutdown (#1320)
* Graceful RPC shutdown: CLI side

* Handle unavailable resource monitor in language hosts

* Fix a comment

* Don't commit package-lock.json

* fix mangled pylint pragma

* Rebase against master and fix Gopkg.lock

* Code review feedback

* Fix a race between closing the callerEventsOpt channel and terminating a goroutine that writes to it

* glog -> logging
2018-05-16 15:37:34 -07:00
CyrusNajmabadi 72e00810c4
Filter the logs we emit to glog so that we don't leak out secrets. (#1371) 2018-05-15 15:28:00 -07:00
CyrusNajmabadi 4807de038c
Capture 'exports' if referenced in user code. (#1359) 2018-05-11 16:35:41 -07:00
CyrusNajmabadi 6de1cead5a
Fix issue where we were not properly serializing out the prototype for an object. (#1352) 2018-05-11 15:53:16 -07:00
Pat Gavlin 97ace29ab1
Begin tracing Pulumi API calls. (#1330)
These changes enable tracing of Pulumi API calls.

The span with which to associate an API call is passed via a
`context.Context` parameter. This required plumbing a
`context.Context` parameter through a rather large number of APIs,
especially in the backend.

In general, all API calls are associated with a new root span that
exists for essentially the entire lifetime of an invocation of the
Pulumi CLI. There were a few places where the plumbing got a bit hairier
than I was willing to address with these changes; I've used
`context.Background()` in these instances. API calls that receive this
context will create new root spans, but will still be traced.
2018-05-07 18:23:03 -07:00
CyrusNajmabadi 5387e78cfa
Support async function serialization. (#1311) 2018-05-03 12:25:52 -07:00
Luke Hoban cc8b87ce3d
Make debuggable promise properties as non-enumerable (#1315)
Fixes #1237.
2018-05-02 23:29:20 -07:00
Matt Ellis 409477b951 Invoke node directly from the language host
Instead of using a shell script to jump from the language host into
node, just invoke node directly. This makes our start-up path a little
simpler to understand and indirectly fixes pulumi/home#156, where we
would fail on Windows if the `-exec` script was in a folder that had
spaces in it (due to a subtle interaction between how go launches cmd
files and how cmd.exe parses arguments).
2018-05-02 11:16:58 -07:00