Commit graph

166 commits

Author SHA1 Message Date
CyrusNajmabadi 3639d1e998
Serialized function parameter count. (#2748) 2019-05-20 22:19:22 -04:00
Matt Ellis 1af821db9c Don't capture secret outputs in closures.
Until #2718 is addressed, we will just disallow capturing secret
outputs when we serialize closures.
2019-05-13 15:45:08 -07:00
Matt Ellis 87bc7d443f Support Secret Outputs in the Node SDK
`Output<T>` now tracks if an output represents secret data or
not. When secret, it is marshalled as a secret value and we signal to
the resource monitor that it is safe to return secret values to us.

The `pulumi` module exports a new functiion, `secret<T>` which works
in the same was a `output<T>` except that it marks the underlying
output as a secret.

This secret bit flows as you would expect across `all`'s and
`apply`'s.

Note that in process memory, the raw value is still present, when you
run an `apply` for a secret output, you are able to see the raw
value. In addition, if you capture a secret output with a lambda, the
raw value will be present in the captured source text.
2019-05-10 17:07:52 -07:00
Matt Ellis 9325b6ec61 Add logging to tests 2019-05-01 10:04:27 -07:00
Sean Gillespie ad32d9d8ac
Plumb provider version through language hosts to engine (#2656)
* NodeJS: allow callers to override provider version

* Python: allow callers to override provider version

* NodeJS: add version for invoke

* Python: add version to invoke

* NodeJS: add tests for ReadResource

* Post-merge cleanup

* update doc comments
2019-04-23 11:02:51 -07:00
Luke Hoban 0550f71a35
Add an ignoreChanges resource option (#2657)
Fixes #2277.

Adds a new ignoreChanges resource option that allows specifying a list of property names whose values will be ignored during updates. The property values will be used for Create, but will be ignored for purposes of updates, and as a result also cannot trigger replacements.

This is a feature of the Pulumi engine, not of the resource providers, so no new logic is needed in providers to support this feature. Instead, the engine simply replaces the values of input properties in the goal state with old inputs for properties marked as ignoreChanges.

Currently, only top level properties may be specified in ignoreChanges. In the future, this could be extended to support paths to nested properties (including into array elements) with a JSONPath/JMESPath syntax.
2019-04-22 13:54:48 -07:00
Joe Duffy 644d5dc916
Enable unit testing for Pulumi programs (#2638)
* Enable unit testing for Pulumi programs

This change enables rudimentary unit testing of your Pulumi programs, by introducing a `PULUMI_TEST_MODE` envvar that, when set, allows programs to run without a CLI. That includes

* Just being able to import your Pulumi modules, and test ordinary functions -- which otherwise would have often accidentally triggered the "Not Running in a CLI" error message
* Being able to verify a subset of resource properties and shapes, with the caveat that outputs are not included, due to the fact that this is a perpetual "dry run" without any engine operations occurring

In principle, this also means you can attach a debugger and step through your code.

* Finish the unit testing features

This change

1) Incorporates CR feedback, namely requiring that test mode be
   explicitly enabled for any of this to work.

2) Implements Python support for the same capabilities.

3) Includes tests for both JavaScript and Python SDKs.

* Add a note on unit testing to the CHANGELOG

* Use Node 8 friendly assert API

* Embellish the CHANGELOG entry a bit
2019-04-16 22:20:01 -07:00
CyrusNajmabadi 02f46811db
Add a SxS test for @pulumi/pulumi to help catch when we make breaking changes to core types. (#2610) 2019-03-29 12:27:42 -07:00
CyrusNajmabadi 1f51ec00fc
Revert 'Simplify API for passing providers to a ComponentResource (#2602)' (#2606) 2019-03-28 18:31:03 -07:00
CyrusNajmabadi 49a8e73aa7
Ensure that the values in 'dependsOn' are actually Resources. (#2605) 2019-03-28 17:27:51 -07:00
CyrusNajmabadi 7193622183
Simplify API for passing providers to a ComponentResource (#2602) 2019-03-28 15:04:07 -07:00
CyrusNajmabadi fd6ae9cb7e
Suppress further errors at LangHost level if we know the nodejs process reported the errors to the user. (#2596) 2019-03-27 14:40:29 -07:00
CyrusNajmabadi 992952b54f
Revert "Better present interpolated strings during preview. (#2564)" (#2593) 2019-03-26 16:36:43 -07:00
CyrusNajmabadi 906488c7d0
Fix issue where we could not serialize an arrow-function with a deconstructed parameter. (#2582) 2019-03-22 16:48:38 -07:00
CyrusNajmabadi be1c3eb05b
Add support for serializing bigints (#2581) 2019-03-22 15:33:37 -07:00
CyrusNajmabadi 02369f9d8a
Allows the nodejs launcher to recognize that certain types of errors were printed, ensuring we don't cascade less relevant messages. (#2554) 2019-03-20 11:54:32 -07:00
CyrusNajmabadi c6d87157d9
Use result.Result in more places. (#2568) 2019-03-19 16:21:50 -07:00
CyrusNajmabadi 718a0c293b
Better present interpolated strings during preview. (#2564) 2019-03-18 17:09:12 -07:00
CyrusNajmabadi 82c4df84e5
Make test resilient to different node loading orders (#2525) 2019-03-06 12:17:24 -08:00
CyrusNajmabadi 7f5e089f04
Update @pulumi/pulumi to version 0.17.0 (#2510)
This update includes several changes to core `@pulumi/pulumi` constructs that will not play nicely
in side-by-side applications that pull in prior versions of this package.  As such, we are rev'ing
the minor version of the package from 0.16 to 0.17.  Recent version of `pulumi` will now detect,
and warn, if different versions of `@pulumi/pulumi` are loaded into the same application.  If you
encounter this warning, it is recommended you move to versions of the `@pulumi/...` packages that
are compatible.  i.e. keep everything on 0.16.x until you are ready to move everything to 0.17.x.

### Improvements

- `Output<T>` now 'lifts' property members from the value it wraps, simplifying common coding patterns.  Note: this wrapping only happens for POJO values, not `Output<Resource>`s. 

- Depending on a **Component** Resource will now depend on all other Resources parented by that
  Resource. This will help out the programming model for Component Resources as your consumers can
  just depend on a Component and have that automatically depend on all the child Resources created
  by that Component.  Note: this does not apply to a **Custom** resource.  Depending on a
  CustomResource will still only wait on that single resource being created, not any other Resources
  that consider that CustomResource to be a parent.
2019-03-05 17:06:57 -08:00
CyrusNajmabadi 0117c1c01d
Turn off warning for toString/toJSON on an Output (#2507) 2019-03-04 12:03:18 -08:00
CyrusNajmabadi 3d1df982de
Incorrect closure serialization when object referenced through different functions. (#2497) 2019-02-28 11:11:43 -08:00
CyrusNajmabadi aa3c6d0ba6
Converting an Output to a string or JSON now produces a warning . (#2496) 2019-02-27 16:00:54 -08:00
CyrusNajmabadi 0d2d1eb61a
Rolling back toString/toJSON change (#2495)
* Revert "Make toString and toJSON internal (#2489)"

This reverts commit 7579b84f73.

* Revert "Update error message to point at docs. (#2488)"

This reverts commit 9156c26a2e.

* Revert "Throw on Output.toString and toJSON (#2486)"

This reverts commit c33b4505c0.
2019-02-27 14:53:56 -08:00
CyrusNajmabadi 93defd4b90
Rollback waiting on children of a component when waiting on the component. (#2492) 2019-02-27 12:41:44 -08:00
CyrusNajmabadi c33b4505c0
Throw on Output.toString and toJSON (#2486) 2019-02-26 19:24:21 -08:00
CyrusNajmabadi c53f697a6f
Fix deadlock when waiting for transitive dependencies (#2471) 2019-02-24 12:14:16 -08:00
CyrusNajmabadi 27b04c4c62
Have child resources update their parent urn to include themselves in its dependencies. (#2299) 2019-02-21 20:18:29 -08:00
CyrusNajmabadi 5211954f3a
Break out Resource and Output into their own files (#2420) 2019-01-31 18:08:17 -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
CyrusNajmabadi bfcb07a164
Add functions to help make strings from values that may include Outputs (#2359) 2019-01-16 11:03:25 -08:00
CyrusNajmabadi 7e7544e27e
Revert https://github.com/pulumi/pulumi/pull/2281 (#2297) 2018-12-15 21:04:53 -08:00
CyrusNajmabadi 05f5311055
Prevent cycles when serializing props. (#2281) 2018-12-10 14:31:54 -08:00
Pat Gavlin 663e5342b0
Inherit custom resource providers (#2264)
If a custom resource has explicitly specified a provider, add that
provider to the resource's provider map under the resource's package.
This allows children of the custom resource to inherit the resource's
provider.

Fixes #2262.
2018-12-05 12:35:19 -08:00
Joe Duffy a337fd7379
Permit dependsOn that are Outputs (of Outputs) (#2198)
This changes the input type for dependsOn from simply
`Resource[] | Resource` to `Input<Input<Resource>[]> | Input<Resource>`.
This permits `Output<Resource>`s, etc in addition to
`Promise<Resource>`s. The logic for dynamically unpicking the right
types and recursing through the data structures isn't straightforward,
but I've written a test for all of the interesting permutations.

This fixes pulumi/pulumi#991.
2018-11-19 11:22:55 -05:00
CyrusNajmabadi cea165615e
Reenable tests. (#2200) 2018-11-13 17:13:27 -08:00
Pat Gavlin 170541546e
Disable the config capture tests (#2183)
These tests fail non-deterministically.
2018-11-08 17:45:51 -08:00
CyrusNajmabadi 901a238fd5
Get closure serialiation working in Node11 (#2101)
* Make v8 primitives async as there is no way to avoid async in node11.

* Simplify API.

* Move processing of well-known globals into the v8 layer.
We'll need this so that we can map from RemoteObjectIds back to these well known values.

* Remove unnecesssary check.

* Cleanup comments and extract helper.

* Introduce helper bridge method for the simple case of making an entry for a string.

* Make functions async.  They'll need to be async once we move to the Inspector api.

* Make functions async.  They'll need to be async once we move to the Inspector api.

* Make functions async.  They'll need to be async once we move to the Inspector api.

* Move property access behind helpers so they can move to the Inspector API in the future.

* Only call function when we know we have a Function.  Remove redundant null check.

* Properly serialize certain special JavaScript number values that JSON serialization cannot handle.

* Only marshall across the 'source' and 'flags' for a RegExp when serializing.

* Add a simple test to validate a regex without flags.

* Extract functionality into helper method.

* Add test with complex output scenarios.

* Output serialization needs to avoid recursively trying to serialize a serialized value.

* Introduce indirection for introspecting properties of an object.

* Use our own introspection API for examining an Array.

* Hide direct property access through API indirection.

* Produce values like the v8 Inspector does.

* Compute the module map asynchronously.  Will need that when mapping mirrors instead.

* Cleanup a little code in closure creation.

* Get serialization working on Node11 (except function locations).

* Run tests in the same order on <v11 and >=v11

* Make tests run on multiple versions of node.

* Rename file to make PR simpler to review.

* Cleanup.

* Be more careful with global state.

* Remove commented line.

* Only allow getting a session when on Node11 or above.

* Promisify methods.
2018-11-01 15:46:21 -07:00
CyrusNajmabadi 3e25bc80c8
Add test with complex output scenarios. (#2118) 2018-10-28 13:02:25 -07:00
CyrusNajmabadi 13d9043771
Produce values like the v8 Inspector does. (#2119) 2018-10-28 01:01:48 -07:00
Joe Duffy 4647aa6cdb
Merge pull request #2114 from pulumi/joeduffy/994_combinators
Add some helpful input/output combinators
2018-10-27 15:41:22 -07:00
joeduffy 930c86cb50 Fix some lint errors 2018-10-27 13:27:04 -07:00
joeduffy 1daad93ccd Add tests for the new combinators 2018-10-27 12:56:16 -07:00
CyrusNajmabadi c83eaf428b
Add a simple test to validate a regex without flags. (#2117) 2018-10-27 00:42:52 -07:00
CyrusNajmabadi 1d7f35352d
Properly serialize certain special JavaScript number values that JSON serialization cannot handle. (#2116) 2018-10-26 23:46:57 -07:00
CyrusNajmabadi 19a313b628
Do not analyze user source code for required packages. We'll analyze their project.json for that. (#1612) 2018-10-18 11:21:47 -07:00
Alex Clemmer 00a22b27f8 Don't unwrap functions
Suppose you have `pulumi.output(o).apply(foo)`, with `o` being type `O`
and `foo` taking type `O` as an argument. If `O` is a type with methods,
this will fail to type check.

The reason is that `UnwrappedObject<T>` (as well as the other
`Unwrapped*` types) will recursively wrap the types of field values
whose type was `Function`. Since `UnwrappedObject<Function>` is not the
same as `Function`, we fail to type check. Note that this does not
result in an actual "boxed" object -- this is purely at the type level.

This commit resolves this by considering `Function` a primitive type,
which will cause us to not wrap the types of field values, instead
leaving them as `Function`.
2018-10-15 14:28:28 -07:00
CyrusNajmabadi 177f0f7ca1
Fix computation of the isKnown bit for an Output (when the apply function returns an Output itself). (#1974) 2018-09-25 21:29:27 -07:00
Sean Gillespie 2d4a3f7a6a
Move management of root resource state to engine (#1944)
* Protobuf changes

* Move management of root resource state to engine

This commit fixes a persistent side-by-side issue in the NodeJS SDK by
moving the management of root resource state to the engine. Doing so
adds two new endpoints to the Engine gRPC service: 1) GetRootResource
and 2) SetRootResource, which get and set the root resource
respectively.

* Rebase against master, regenerate proto
2018-09-18 11:47:34 -07:00