Commit graph

1974 commits

Author SHA1 Message Date
Matt Ellis 62efc1b441 Fix up some pulumi init error cases
- When looking for a `.pulumi` folder to reuse, only consider ones
  that have a `settings.json` in them.
- Make the error message when there is no repository a little more
  informative by telling someone to run `pulumi init`
2017-10-30 11:40:32 -07:00
pat@pulumi.com 8fd2d3e9e0 Fix require paths in closure serialization on Windows.
We were ending up with unescaped backslashes in require paths, which was
causing the requires to fail.
2017-10-30 08:55:18 -07:00
Chris Smith bd5e54d63e
Fix panic when using commands w/o Pulumi.yaml (#492)
Calls to `NewProjectWorkspace` will panic if there is no Pulumi.yaml found in the folder hierarchy. Simple repo:

```
git init
pulumi init
pulumi stack init x
```

`DetectPackage` will search until it gets to the `.pulumi` directory or finds a `Pulumi.yaml` file. In the case of the former, we pass "" to `LoadPackage` which then asserts because the file doesn't exist.

We now detect this condition and surface an error to the user. The error text is patterned after running a git command when there is no .git folder found:

fatal: Not a git repository (or any of the parent directories): .git
2017-10-28 18:07:03 -07:00
Joe Duffy cdb2c79e8e
Exit with an error code in the face of unhandled errors (#495)
As part of fixing the exit bug recently, we accidentally made errors
lead to zero exit codes.  As a result, the Pulumi CLI thought the
prgoram exited ordinarily, and proceeded to do its usual planning and
deployment, rather than terminating abruptly.

This is a byproduct of how Node's process.uncaughtException handler
works.  It hijacks and replaces all usual error logic, including the
process.exit part.  This change simply adds back the non-zero exit.

I also added a test (and fixed one other that began failing
afterwards), so that we can prevent regressions down the road.
2017-10-28 17:05:05 -07:00
Joe Duffy 2344f9e079
Merge pull request #490 from pulumi/int_test_stackdir
Fix where integration tests look for checkpoints
2017-10-27 20:12:07 -07:00
joeduffy 6d74b3ca27 Add minimal runtime verification test
This adds a minimal runtime verification test to our basic
test suite, to at least exercise the portions of the integration
test library that load up and parse checkpoint files.
2017-10-27 20:03:38 -07:00
joeduffy 7835305b82 Fix where integration tests look for checkpoints 2017-10-27 19:42:17 -07:00
Matt Ellis 8d7a87f694
Merge pull request #488 from pulumi/windows-hang
Fix AppVeyor hang when tests fail
2017-10-27 18:00:08 -07:00
Matt Ellis 51250c42db Lower timeout
The tests usually complete in about 15 seconds, so let's lower the
timeout to fail a little faster in cases where we have hangs in
`pulumi` itself.
2017-10-27 15:54:16 -07:00
Matt Ellis 786e1b92e1 Ensure we always kill leaking node processes
When go test fails, we would not kill any extra node processes lying
around. In AppVeyor, not killing these causes the job to hang until we
reach the AppVeyor timeout. Explicitly killing the jobs ensures
AppVeyor ends quickly.
2017-10-27 15:54:16 -07:00
Matthew Riley 90e53482dc
Merge pull request #485 from pulumi/remove-proccnt
Remove unused PROCCNT variable
2017-10-27 15:43:24 -07:00
Chris Smith d80cba135a
Add newline after update completes (#487)
The last status message from the PPC doesn't include a newline. So the `pulumi` CLI renders any error messages on the same line as the last diagnostic message. Not ideal.
2017-10-27 15:40:15 -07:00
Matt Ellis e25a5f91ef
Merge pull request #479 from pulumi/move-workspace-data
Move .pulumi to root of a repository
2017-10-27 14:52:24 -07:00
Matthew Riley 418ff30725 Remove unused PROCCNT variable 2017-10-27 14:42:47 -07:00
Pat Gavlin a5358088d7
Merge pull request #484 from pulumi/Followup
Follow up to PR feedback for #475.
2017-10-27 14:18:58 -07:00
pat@pulumi.com 73baaa2867 Follow up to PR feedback for #475.
- Change a `console.log` to `log.debug`
- Null out gRPC clients after disconnecting.
2017-10-27 13:51:47 -07:00
Pat Gavlin 40c72f37d5
Merge pull request #478 from pulumi/PadProviderArgs
Pad provider arguments on Windows.
2017-10-27 13:49:54 -07:00
Chris Smith d81b00f758
Update error message to reflect current CLI format (#482) 2017-10-27 13:44:32 -07:00
Matt Ellis 3f1197ef84 Move .pulumi to root of a repository
Now, instead of having a .pulumi folder next to each project, we have
a single .pulumi folder in the root of the repository. This is created
by running `pulumi init`.

When run in a git repository, `pulumi init` will place the .pulumi
file next to the .git folder, so it can be shared across all projects
in a repository. When not in a git repository, it will be created in
the current working directory.

We also start tracking information about the repository itself, in a
new `repo.json` file stored in the root of the .pulumi folder. The
information we track are "owner" and "name" which map to information
we use on pulumi.com.

When run in a git repository with a remote named origin pointing to a
GitHub project, we compute the owner and name by deconstructing
information from the remote's URL. Otherwise, we just use the current
user's username and the name of the current working directory as the
owner and name, respectively.
2017-10-27 11:46:21 -07:00
Matt Ellis 843ae4a4f6
Merge pull request #468 from pulumi/fix-pulumi-config-ls
Configuration UX improvements
2017-10-27 11:43:46 -07:00
Matt Ellis c051da476f Improve the US for pulumi config
- `pulumi config ls` now does not prompt for a passphrase if there are
  secrets, instead ******'s are shown. `--show-secrets` can be passed
  to force decryption. The behavior of `pulumi config ls <key>` is
  unchanged, if the key is secure, we will prompt for a passphrase.

- `pulumi config secret <key>` now prompts for the passphrase and verifies
  it before asking for the secret value.

Fixes #465
2017-10-27 10:04:53 -07:00
Chris Smith 9b3dd54385 Enable 'pulumi stack init' to the Cloud (#480)
This PR enables the `pulumi stack init` to work against the Pulumi Cloud. Of note, I using the approach described in https://github.com/pulumi/pulumi-service/issues/240. The command takes an optional `--cloud` parameter, but otherwise will use the "default cloud" for the target organization.

I also went back and revised `pulumi update` to do this as well. (Removing the `--cloud` parameter.)

Note that neither of the commands will not work against `pulumi-service` head, as they require some API refactorings I'm working on right now.
2017-10-26 22:14:56 -07:00
pat@pulumi.com 6ef0747219 Pad provider arguments on Windows.
All of our providers expect to be invoked as `node path/to/provider
...provider_args`, but on Windows, we are invoking them as `node -e
require(path/to/provider) ...provider_args`. This throws off the
provider's argument processing and causes connections to the resource
monitor to fail.

Fixes #477, though I think that there is going to be another issue with
dynamic resources.
2017-10-26 18:44:29 -07:00
Pat Gavlin ccb0333a39 Merge pull request #475 from pulumi/ExitDisconnect
Do not disconnect from the engine prematurely.
2017-10-26 17:36:38 -07:00
CyrusNajmabadi 44d95666e7 Make it possible to do extra validation tests after applying an edit. (#476)
* Make it possible to do extra validation tests after applying an edit.

* Chane name.
2017-10-26 16:01:28 -07:00
pat@pulumi.com 73f2670b98 Add a Windows version of the dynamic provider. 2017-10-26 15:01:16 -07:00
pat@pulumi.com 97f99d7fa1 Do not disconnect from the engine prematurely.
The `nodejs` language support is implemented as two programs: one that
manages the initial connection to the engine and provides the language
serivce itself, and another that the language service invokes in order
to run a `nodejs` Pulumi program. The latter is responsible for running
the user's program and communicating its resource requests to the
engine. Currently, `run` effectively assumes that the user's program
will run synchronously from start to finish, and will disconnect from
the engine once the user's program has completed. This assumption breaks
if the user's program requires multiple turns of the event loop to
finish its root resource requests. For example, the following program
would fail to create its second resource because the engine will be
disconnected once it reaches its `await`:

```
(async () => {
    let a = new Resource();
    await somePromise();
    let = new Resource();
})();
```

These changes fix this issue by disconnecting from the engine during
process shutdown rather than after the user's program has finished its
first turn through the event loop.
2017-10-26 12:16:32 -07:00
joeduffy b06a708f11 Use Fprint, not Fprintf, so we don't format messages
I noticed in our Docker builds, we often end up seeing %(MISSING)!
style messages, which were an indication we were trying to format
them.  The reason was the presence of %c's in the stream, and the
fact that we passed said messages to Fprintf.  We were careful in
all other layers to use the message on the "right hand side" of
any *f calls, but in this instance, we used Fprintf and passed the
message on the "left hand side", triggering formatting.  It turns
out we've already formatted everything by the time we get here,
so there's no need -- we can just use Fprint instead.
2017-10-26 10:30:30 -07:00
Chris Smith f52e7233f9 Fix panic from incorrect assumption (#473)
Fixes panic when the output from the PPC doesn't have a "text" property. (Still need to unify the way the PPC emits event data with the types that the Pulumi codebase uses internally.)
2017-10-25 15:28:29 -07:00
CyrusNajmabadi 3bbe21db25 Simplify the type system around 'computed' a little. (#469) 2017-10-25 12:52:49 -07:00
Matt Ellis e15131e3e7 Have pulumi config ls take the current stack into account 2017-10-25 12:04:23 -07:00
Chris Smith 95062100f7 Enable pulumi update to target the Console (#461)
Adds `pulumi update` so you can deploy to the Pulumi Console (via PPC on the backend).

As per an earlier discussion (now lost because I rebased/squashed the commits), we want to be more deliberate about how to bifurcate "local" and "cloud" versions of every Pulumi command.

We can block this PR until we do the refactoring to have `pulumi` commands go through a generic "PulumiCloud" interface. But it would be nice to commit this so I can do more refining of the `pulumi` -> Console -> PPC workflow. 

Another known area that will need to be revisited is how we render the PPC events on the CLI. Update events from the PPC are generated in a different format than the `engine.Event`, and we'll probably want to change the PPC to emit messages in the same format. (e.g. how we handle coloring, etc.)
2017-10-25 10:46:05 -07:00
Matt Ellis ade366544e Encrypt secrets in Pulumi.yaml
We now encrypt secrets at rest based on a key derived from a user
suplied passphrase.

The system is designed in a way such that we should be able to have a
different decrypter (either using a local key or some remote service
in the Pulumi.com case in the future).

Care is taken to ensure that we do not leak decrypted secrets into the
"info" section of the checkpoint file (since we currently store the
config there).

In addtion, secrets are "pay for play", a passphrase is only needed
when dealing with a value that's encrypted. If secure config values
are not used, `pulumi` will never prompt you for a
passphrase. Otherwise, we only prompt if we know we are going to need
to decrypt the value. For example, `pulumi config <key>` only prompts
if `<key>` is encrypted and `pulumi deploy` and friends only prompt if
you are targeting a stack that has secure configuration assoicated
with it.

Secure values show up as unecrypted config values inside the language
hosts and providers.
2017-10-24 16:48:12 -07:00
Pat Gavlin 76f6aceb29 Merge pull request #462 from pulumi/NoSignalTrap
Do not trap signals in `rpcutil.Serve`.
2017-10-24 15:01:22 -07:00
pat@pulumi.com ce18c8293b Do not trap signals in rpcutil.Serve.
Trapping these signals hijacks the usual termination behavior for any
program that happens to link in the engine and perform an operation
that starts a gRPC server. These servers already provide a cancellation
mechanism via a `cancel` channel parameter; if the using program wants
to gracefully terminate these servers on some signal, it is responsible
for providing that behavior.

This also fixes a leak in which the goroutine responsible for waiting on
a server's signals and cancellation channel would never exit.
2017-10-24 14:35:59 -07:00
Matt Ellis 9840bf4ec8 Merge pull request #460 from pulumi/fix-453
Retain historical checkpoints
2017-10-24 12:31:31 -07:00
Matt Ellis 25b8111eea Retain historical checkpoints
When `PULUMI_RETAIN_CHECKPOINTS` is set in the environment, also write
the checkpoint file to <stack-name>.<ext>.<timestamp>.

This ensures we have historical information about every snapshot, which
would aid in debugging issues like #451. We set this to true for our
integration tests.

Fixes #453
2017-10-24 11:48:33 -07:00
joeduffy 3d3f778c3d Fix asset bugs; write more tests
This change fixes a couple bugs with assets:

* We weren't recursing into subdirectories in the new "path as
  archive" feature, which meant we missed most of the files.

* We need to make paths relative to the root of the archive
  directory itself, otherwise paths end up redundantly including
  the asset's root folder path.

* We need to clean the file paths before adding them to the
  archive asset map, otherwise they are inconsistent between the
  path, tar, tgz, and zip cases.

* Ignore directories when traversing zips, since they aren't
  included in the other formats.

* Tolerate io.EOF errors when reading the ZIP contents into blobs.

* Add test cases for the four different archive kinds.

This fixes pulumi/pulumi-aws#50.
2017-10-24 09:00:11 -07:00
Chris Smith ede1595a6a Add more context information to assert. (#449) 2017-10-24 08:25:39 -07:00
joeduffy c61bce3e41 Permit undefined in more places
The prior code was a little too aggressive in rejected undefined
properties, because it assumed any occurrence indicated a resource
that was unavailable due to planning.  This is a by-produt of our
relatively recent decision to flow undefineds freely during planning.

The problem is, it's entirely legitimate to have undefined values
deep down in JavaScript structures, entirely unrelated to resources
whose property values are unknown due to planning.

This change flows undefined more freely.  There really are no
negative consequences of doing so, and avoids hitting some overly
aggressive assertion failures in some important scenarios.  Ideally
we would have a way to know statically whether something is a resource
property, and tighten up the assertions just to catch possible bugs
in the system, but because this is JavaScript, and all the assertions
are happening at runtime, we simply lack the necessary metadata to do so.
2017-10-23 16:02:28 -07:00
joeduffy 680e73bb97 Add context to "unexpected unknown property" error log 2017-10-23 15:31:45 -07:00
Pat Gavlin 236fd6bf76 Merge pull request #448 from pulumi/TwoPhaseSnapshot
Add two-phase snapshotting.
2017-10-23 10:27:30 -07:00
Pat Gavlin cdbcc394dd PR feedback. 2017-10-23 10:11:09 -07:00
joeduffy 0248b6c309 Fix an err shadowing lint error 2017-10-23 05:55:34 -07:00
joeduffy a7d99a0c80 Preserve Pulumi.yaml while applying edits
Now that config is stored in Pulumi.yaml, we need to mimic the behavior
around .pulumi/ while edits are applied.  This will ensure that config
values carry forward from the original program settings.

This fixes pulumi/pulumi-aws#48.
2017-10-23 05:27:26 -07:00
joeduffy b6e00c7c90 Update integration example 2017-10-22 19:03:08 -07:00
joeduffy c6ee323ce1 Add some "still running..." messages to Pulumi tests 2017-10-22 18:54:29 -07:00
joeduffy d20f043a3e Fix a few SHA1 comment typos (should be SHA256) 2017-10-22 18:30:42 -07:00
Joe Duffy 4a493292b1 Tolerate missing hashes 2017-10-22 15:54:44 -07:00
joeduffy 3d9dcb0942 Break the diag goroutine upon exit 2017-10-22 15:52:00 -07:00