Commit graph

200 commits

Author SHA1 Message Date
CyrusNajmabadi b135af10be
Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
CyrusNajmabadi 4d9336caa9
Specify the 8.0 version of node types. (#3215) 2019-09-11 10:54:44 -07:00
CyrusNajmabadi e61f8fdcb8
Update us to the same target ES version that Nodejs uses. (#3213) 2019-09-10 16:19:12 -07:00
Matt Ellis af2a2d0f42 Correctly flow secretness across structured values
For providers which do not natively support secrets (which is all of
them today), we annotate output values coming back from the provider
if there is a coresponding secret input in the inputs we passed in.

This logic was not tearing into rich objects, so if you passed a
secret as a member of an array or object into a resource provider, we
would lose the secretness on the way back.

Because of the interaction with Check (where we call Check and then
take the values returned by the provider as inputs for all calls to
Diff/Update), this would apply not only to the Output values of a
resource but also the Inputs (because the secret metadata would not
flow from the inputs of check to the outputs).

This change augments our logic which transfers secrets metadata from
one property map to another to handle these additional cases.
2019-05-15 09:32:25 -07:00
Matt Ellis fb1ebd0e06 Add an End to End test of secrets
This test ensures that our secrets support works by deploying
resources with a mix of secret and plantext inputs and then checks the
deployment file to ensure that everything is marked as a secret.
2019-05-10 17:07:52 -07:00
CyrusNajmabadi daca809d09
Fix local file:// stacks on Windows. (#2696) 2019-05-02 16:52:00 -07:00
CyrusNajmabadi 57a228c2ab
Fix issue with comments throwing off function/class serialization (#2438) 2019-02-08 14:58:24 -08:00
Matt Ellis 8cbe6554f5 Only run the 0.10.0 compat test on Node 6.10.X 2018-11-25 22:02:28 -08:00
Matt Ellis 872c7661e3 Provide a way to override packages during a test run
Add a new property to ProgramTestOptions, `Overrides` that allows a
test to request a different version of a package is used instead of
what would be listed in the package.json file.

This will be used by our nightly automation to run everything "at head"
2018-11-25 22:02:28 -08:00
Matt Ellis 22fef07fcf Remove existing lock files 2018-11-12 15:33:58 -08:00
Joe Duffy 511e830c5c
Delete a dead example (#1996) 2018-09-28 12:10:50 -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
Pat Gavlin a222705143
Implement first-class providers. (#1695)
### First-Class Providers
These changes implement support for first-class providers. First-class
providers are provider plugins that are exposed as resources via the
Pulumi programming model so that they may be explicitly and multiply
instantiated. Each instance of a provider resource may be configured
differently, and configuration parameters may be source from the
outputs of other resources.

### Provider Plugin Changes
In order to accommodate the need to verify and diff provider
configuration and configure providers without complete configuration
information, these changes adjust the high-level provider plugin
interface. Two new methods for validating a provider's configuration
and diffing changes to the same have been added (`CheckConfig` and
`DiffConfig`, respectively), and the type of the configuration bag
accepted by `Configure` has been changed to a `PropertyMap`.

These changes have not yet been reflected in the provider plugin gRPC
interface. We will do this in a set of follow-up changes. Until then,
these methods are implemented by adapters:
- `CheckConfig` validates that all configuration parameters are string
  or unknown properties. This is necessary because existing plugins
  only accept string-typed configuration values.
- `DiffConfig` either returns "never replace" if all configuration
  values are known or "must replace" if any configuration value is
  unknown. The justification for this behavior is given
  [here](https://github.com/pulumi/pulumi/pull/1695/files#diff-a6cd5c7f337665f5bb22e92ca5f07537R106)
- `Configure` converts the config bag to a legacy config map and
  configures the provider plugin if all config values are known. If any
  config value is unknown, the underlying plugin is not configured and
  the provider may only perform `Check`, `Read`, and `Invoke`, all of
  which return empty results. We justify this behavior becuase it is
  only possible during a preview and provides the best experience we
  can manage with the existing gRPC interface.

### Resource Model Changes
Providers are now exposed as resources that participate in a stack's
dependency graph. Like other resources, they are explicitly created,
may have multiple instances, and may have dependencies on other
resources. Providers are referred to using provider references, which
are a combination of the provider's URN and its ID. This design
addresses the need during a preview to refer to providers that have not
yet been physically created and therefore have no ID.

All custom resources that are not themselves providers must specify a
single provider via a provider reference. The named provider will be
used to manage that resource's CRUD operations. If a resource's
provider reference changes, the resource must be replaced. Though its
URN is not present in the resource's dependency list, the provider
should be treated as a dependency of the resource when topologically
sorting the dependency graph.

Finally, `Invoke` operations must now specify a provider to use for the
invocation via a provider reference.

### Engine Changes
First-class providers support requires a few changes to the engine:
- The engine must have some way to map from provider references to
  provider plugins. It must be possible to add providers from a stack's
  checkpoint to this map and to register new/updated providers during
  the execution of a plan in response to CRUD operations on provider
  resources.
- In order to support updating existing stacks using existing Pulumi
  programs that may not explicitly instantiate providers, the engine
  must be able to manage the "default" providers for each package
  referenced by a checkpoint or Pulumi program. The configuration for
  a "default" provider is taken from the stack's configuration data.

The former need is addressed by adding a provider registry type that is
responsible for managing all of the plugins required by a plan. In
addition to loading plugins froma checkpoint and providing the ability
to map from a provider reference to a provider plugin, this type serves
as the provider plugin for providers themselves (i.e. it is the
"provider provider").

The latter need is solved via two relatively self-contained changes to
plan setup and the eval source.

During plan setup, the old checkpoint is scanned for custom resources
that do not have a provider reference in order to compute the set of
packages that require a default provider. Once this set has been
computed, the required default provider definitions are conjured and
prepended to the checkpoint's resource list. Each resource that
requires a default provider is then updated to refer to the default
provider for its package.

While an eval source is running, each custom resource registration,
resource read, and invoke that does not name a provider is trapped
before being returned by the source iterator. If no default provider
for the appropriate package has been registered, the eval source
synthesizes an appropriate registration, waits for it to complete, and
records the registered provider's reference. This reference is injected
into the original request, which is then processed as usual. If a
default provider was already registered, the recorded reference is
used and no new registration occurs.

### SDK Changes
These changes only expose first-class providers from the Node.JS SDK.
- A new abstract class, `ProviderResource`, can be subclassed and used
  to instantiate first-class providers.
- A new field in `ResourceOptions`, `provider`, can be used to supply
  a particular provider instance to manage a `CustomResource`'s CRUD
  operations.
- A new type, `InvokeOptions`, can be used to specify options that
  control the behavior of a call to `pulumi.runtime.invoke`. This type
  includes a `provider` field that is analogous to
  `ResourceOptions.provider`.
2018-08-06 17:50:29 -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
Matt Ellis 2a8a54a24b Remove need for tsconfig.json
Set the following compiler defaults:

```
       "target": "es6",
       "module": "commonjs",
       "moduleResolution": "node",
       "sourceMap": true,
```

Which allows us to not even include a tsconfig.json file. If one is
present, `ts-node` will use its options, but the above settings will
override any settings in a local tsconfig.json file. This means if you
want full control over the target, you'll need to go back to the raw
tsc workflow where you explicitly build ahead of time.
2018-08-06 14:00:58 -07:00
Matt Ellis 7074ae8cf3 Use new native typescript support in many tests
We retain a few tests on the RunBuild plan, with `typescript` set to
false in the runtime options, but for the general case, we remove the
build steps and custom entry points for our programs.
2018-08-06 14:00:58 -07:00
Matt Ellis ce5eaa8343 Support TypeScript in a more first-class way
This change lets us set runtime specific options in Pulumi.yaml, which
will flow as arguments to the language hosts. We then teach the nodejs
host that when the `typescript` is set to `true` that it should load
ts-node before calling into user code. This allows using typescript
natively without an explicit compile step outside of Pulumi.

This works even when a tsconfig.json file is not present in the
application and should provide a nicer inner loop for folks writing
typescript (I'm pretty sure everyone has run into the "but I fixed
that bug!  Why isn't it getting picked up?  Oh, I forgot to run tsc"
problem.

Fixes #958
2018-08-06 14:00:58 -07:00
CyrusNajmabadi d19942f2b0
Go back to capturing *non-user* modules by 'require' reference. (#1655) 2018-07-31 11:37:46 -04:00
Joe Duffy 091c0e1c23
Upgrade Node.js SDK to TypeScript 3.0 (#1669)
Per pulumi/pulumi#1668. No code changes required, just package.json
and lockfile updates.
2018-07-30 23:19:28 -07:00
Matt Ellis 91247f2e19 Bump versions in compat test
There is not a prebuilt binary for Node 10.7 for the older version of gRPC
that we had locked to, forcing a rebuild when the project was restored.
On some CI workers this does not work out and the test spews a bunch of
output and then appears to hang.

Since this doesn't seem related to Pulumi in any way, just bump our
version.
2018-07-30 10:21:34 -07:00
CyrusNajmabadi b90235c611
Add license fields to package.json. (#1656) 2018-07-24 16:10:13 -07:00
Matt Ellis 4f28f3d44d Allow overriding config location
Now that the "config" member of Pulumi.yaml has been deprecated for a
while, we'll change it's meaning. When set, the value is treated as a
path and joined with the path to Pulumi.yaml, and per stack
configuration is stored in that folder

Fixes #1031
2018-06-05 09:26:48 -07:00
Matt Ellis 4ac1a2f355 Pull tracing and reporting information from the environment
This lets us set these values globaly, in our Travis and AppVeyor
configurations instead of forcing every test to opt-in. It also means
that by default, local builds will not report any of this data (and
will not need access to these endpoints).
2018-06-04 14:28:52 -07:00
joeduffy 7c7f6d3ed7 Bring back preview, swizzle some flags
This changes the CLI interface in a few ways:

* `pulumi preview` is back!  The alternative of saying
  `pulumi update --preview` just felt awkward, and it's a common
  operation to want to perform.  Let's just make it work.

* There are two flags consistent across all update commands,
  `update`, `refresh`, and `destroy`:

    - `--skip-preview` will skip the preview step.  Note that this
      does *not* skip the prompt to confirm that you'd like to proceed.
      Indeed, it will still prompt, with a little warning text about
      the fact that the preview has been skipped.

    * `--yes` will auto-approve the updates.

This lands us in a simpler and more intuitive spot for common scenarios.
2018-05-06 13:55:39 -07:00
Pat Gavlin c0ed11af14 Enable tracing of integration tests.
These changes add a new option to the integration test framework that
allows the specification of a tracing endpoint for Pulumi invocations.
2018-05-03 13:44:21 -07:00
Sean Gillespie 2c479c172d
Lift snapshot management out of the engine and serialize writes to snapshot (#1069)
* Lift snapshot management out of the engine

This PR is a prerequisite for parallelism by addressing a major problem
that the engine has to deal with when performing parallel resource
construction: parallel mutation of the global snapshot. This PR adds
a `SnapshotManager` type that is responsible for maintaining and
persisting the current resource snapshot. It serializes all reads and
writes to the global snapshot and persists the snapshot to persistent
storage upon every write.

As a side-effect of this, the core engine no longer needs to know about
snapshot management at all; all snapshot operations can be handled as
callbacks on deployment events. This will greatly simplify the
parallelization of the core engine.

Worth noting is that the core engine will still need to be able to read
the current snapshot, since it is interested in the dependency graphs
contained within. The full implications of that are out of scope of this
PR.

Remove dead code, Steps no longer need a reference to the plan iterator that created them

Fixing various issues that arise when bringing up pulumi-aws

Line length broke the build

Code review: remove dead field, fix yaml name error

Rebase against master, provide implementation of StackPersister for cloud backend

Code review feedback: comments on MutationStatus, style in snapshot.go

Code review feedback: move SnapshotManager to pkg/backend, change engine to use an interface SnapshotManager

Code review feedback: use a channel for synchronization

Add a comment and a new test

* Maintain two checkpoints, an immutable base and a mutable delta, and
periodically merge the two to produce snapshots

* Add a lot of tests - covers all of the non-error paths of BeginMutation and End

* Fix a test resource provider

* Add a few tests, fix a few issues

* Rebase against master, fixed merge
2018-04-12 09:55:34 -07:00
CyrusNajmabadi 97c1344035
Disallow capturing 'this' inside a lambda (#1138) 2018-04-09 15:57:39 -07:00
Luke Hoban 5ede33e03d
Run tests against managed stacks backend instead of FnF (#1092)
Tests now target managed stacks instead of local stacks.

The existing logged in user and target backend API are used unless PULUMI_ACCES_TOKEN is defined, in which case tests are run under that access token and against the PULUMI_API backend.

For developer machines, we will now need to be logged in to Pulumi to run tests, and whichever default API backend is logged in (the one listed as current in ~/.pulumi/credentials.json) will be used. If you need to override these, provide PULUMI_ACCESS_TOKEN and possibly PULUMI_API.

For Travis, we currently target the staging service using the Pulumi Bot user.

We have decided to run tests in the pulumi organization. This can be overridden for local testing (or in Travis in the future) by defining PULUMI_API_OWNER_ORGANIZATION and using an access token with access to that organization.

Part of pulumi/home#195.
2018-04-02 21:34:54 -07:00
Pat Gavlin a23b10a9bf
Update the copyright end date to 2018. (#1068)
Just what it says on the tin.
2018-03-21 12:43:21 -07:00
Matt Ellis 05d90a244c Pass legacy config mapping from nodejs langhost
We need to support the current version of the nodejs language host
running programs that use older version of @pulumi/pulumi where the
runtime expected config keys to look like
`<package>:config:<name>`. In the language host we actually did the
transformation from the new format to the old one, for compatability
reasons but we then droped the transfomed value on the floor.
2018-03-13 23:16:38 -07:00
CyrusNajmabadi 850130e30f
Capture modules through normal value capture. (#1030) 2018-03-11 00:11:53 -08:00
Matt Ellis 1515889a40 Remove the need for the :config: part of a config bag
We now unify new Config("package") and new Config("package:config"),
printing a warning when the new Config("package:config") form is
used and pointing consumers towards just new Config("package")

I've updated our examples to use the newer syntax, but I've added a
test ot the langhost to ensure both forms work.

Fixes #923
2018-03-08 10:52:25 -08:00
Joe Duffy 09cceb4e9e
Remove a few outdated references (#997) 2018-03-04 13:34:20 -08:00
joeduffy 09a819f801 Echo the dynamic provider's location 2018-02-20 14:14:05 -08:00
Joe Duffy a74aa51662
Rename pulumi package to @pulumi/pulumi (#917)
In order to begin publishing our core SDK package to NPM, we will
need it to be underneath the @pulumi scope so that it may remain
private.  Eventually, we can alias pulumi back to it.

This is part of pulumi/pulumi#915.
2018-02-12 13:13:13 -08:00
CyrusNajmabadi b740c93c18
Remove 'Computed' type. (#883) 2018-02-05 18:37:10 -08:00
Pat Gavlin 5c0b62e1aa
Serialize resource registration after inputs resolve. (#882)
As it stands, we serialize more than is correct when registering
resources: in addition to serializing the RegisterResource RPC, we also
wait for input properties to resolve in the same context. Unfortunately,
this means that we can create cycles in the promise graph when a
resource A is constructed in an earlier turn than some resource B and
one of B's output properties is an input to resource A. These changes
fix this issue by allowing input properties to resolve *before*
serializing the RegisterResource RPC.

Some integration tests had taken a dependency on the ordering of resources in
either the output of the `pulumi` command or the checkpoint file. The
only test that took a dependency on command output was updated s.t. its
resources have exactly one legal topographical sort (and therefore their
ordering is deterministic). The other tests were updated s.t. their
validation did not depend on resource ordering.
2018-02-05 16:29:20 -08:00
CyrusNajmabadi 275670692b
Introduce Output<T> and update Resource construction code to properly handle it. (#834)
This PR adds a new formalisms at the Resource layer.  First all inputs to a Resource are typed as ```Input<T>```.  This is either a T, ```Promise<T>``
2018-02-05 14:44:23 -08:00
Matt Ellis 4422700f0f Run yarn upgrade and commit all resulting lockfiles
This also adds lock files for some of our tests which we previously
did not commit.
2018-01-30 14:46:44 -08:00
Pat Gavlin 172a192e52 Add a test for derived inputs. 2018-01-22 11:47:14 -08:00
Matt Ellis b56e90ab2a Ensure resources are always parented to a stack
It was possiblef for the finally for a stack to complete before all
other resources had been created. In this case, we would put these new
resources at top level, instead of having them as children of the
stack resource.

Since we do not use the langhost across stacks, we can simply set the
stack resource at top level and never remove it.

Fixes #818
2018-01-19 16:54:50 -08:00
CyrusNajmabadi a5cf6f25d6
Add a framework for baselining and validating pulumi-update diff output. (#700) 2017-12-14 17:10:05 -08:00
Luke Hoban 6f15fa8ed8
Pass more stack info to ExtraRuntimeValidation (#717)
This will allow us to remove a lot of current boilerplate in individual tests, and move it into the test harness.

Note that this will require updating users of the integration test framework.  By moving to a property bag of inputs, we should avoid needing future breaking changes to this API though.
2017-12-13 16:09:14 -08:00
CyrusNajmabadi 7234cdef02
Take an options pointer so values can change as a test runs. (#679)
* Take an options pointer so values can change as a test runs.

* Don't pass redundant information.

* Extract initialization routine.

* Fix caller.

* Check return value.

* Extract destruction logic.

* Move preview and update into their own function.

* Inline null check.
2017-12-08 16:59:28 -08:00
CyrusNajmabadi edb7bf849e
Reverts (#676)
* Revert "Make sure we properly update dir so that pulumi-destroy works."

This reverts commit 56bfc57998.

* Revert "Edits needs to continuously pass along the new directory. (#668)"

This reverts commit 8bd1822722.

* Revert "Refactor test code to make it simpler to validate code in the middle. (#662)"

This reverts commit ed65360157.
2017-12-08 12:59:39 -08:00
CyrusNajmabadi ed65360157
Refactor test code to make it simpler to validate code in the middle. (#662)
* Refactor test code to make it simpler to validate code in the middle.
2017-12-07 16:29:48 -08:00
Joe Duffy 41beb257b0
Write a test for parenting and URNs 2017-12-05 19:14:28 -08:00
Pat Gavlin f848090479 Return all computed inputs from Provider.Check.
As documented in issue #616, the inputs/defaults/outputs model we have
today has fundamental problems. The crux of the issue is that our
current design requires that defaults present in the old state of a
resource are applied to the new inputs for that resource.
Unfortunately, it is not possible for the engine to decide which
defaults remain applicable and which do not; only the provider has that
knowledge.

These changes take a more tactical approach to resolving this issue than
that originally proposed in #616 that avoids breaking compatibility with
existing checkpoints. Rather than treating the Pulumi inputs as the
provider input properties for a resource, these inputs are first
translated by `Check`. In order to accommodate provider defaults that
were chosen for the old resource but should not change for the new,
`Check` now takes the old provider inputs as well as the new Pulumi
inputs. Rather than the Pulumi inputs and provider defaults, the
provider inputs returned by `Check` are recorded in the checkpoint file.

Put simply, these changes remove defaults as a first-class concept
(except inasmuch as is required to retain the ability to read old
checkpoint files) and move the responsibilty for manging and
merging defaults into the provider that supplies them.

Fixes #616.
2017-12-03 09:33:16 -08:00
joeduffy b59b8f2e6e Fix cloud tests 2017-12-03 06:34:06 -08:00
Pat Gavlin 84a7d4f3e0 PR feedback. 2017-11-28 12:44:49 -08:00