Commit graph

287 commits

Author SHA1 Message Date
Matt Ellis 342f8311a1 Fix renaming a freshly created stack using the local backend
Attempting to `pulumi stack rename` a stack which had been created but
never updated, when using the local backend, was broken because
code-paths were not hardened against the snapshot being `nil` (which
is the case for a stack before the initial deployment had been done).

Fixes #2654
2019-08-16 13:39:34 -07:00
Matt Ellis 8c31683c80
Merge pull request #3071 from pulumi/ellismg/fix-2744
Do not taint all stack outputs as secrets if just one is
2019-08-14 10:54:04 -07:00
Matt Ellis c34cf9407e Add regression test 2019-08-13 16:12:20 -07:00
Matt Ellis a383e412bc Do not print resources to stdout in a test
Since we now include output from `go test` (so we can see progress
from our integration tests as they run) we shouldn't print large blobs
of uninteresting JSON data.
2019-08-13 15:58:32 -07:00
Luke Hoban 6ed4bac5af
Support additional cloud secrets providers (#2994)
Adds support for additional cloud secrets providers (AWS KMS, Azure KeyVault, Google Cloud KMS, and HashiCorp Vault) as the encryption backend for Pulumi secrets. This augments the previous choice between using the app.pulumi.com-managed secrets encryption or a fully-client-side local passphrase encryption.

This is implemented using the Go Cloud Development Kit support for pluggable secrets providers.

Like our cloud storage backend support which also uses Go Cloud Development Kit, this PR also bleeds through to users the URI scheme's that the Go CDK defines for specifying each of secrets providers - like `awskms://alias/LukeTesting?region=us-west-2` or `azurekeyvault://mykeyvaultname.vault.azure.net/keys/mykeyname`.

Also like our cloud storage backend support, this PR doesn't solve for how to configure the cloud provider client used to resolve the URIs above - the standard ambient credentials are used in both cases. Eventually, we will likely need to provide ways for both of these features to be configured independently of each other and of the providers used for resource provisioning.
2019-08-02 16:12:16 -07:00
Chris Smith 17ee050abe
Refactor the way secrets managers are provided (#3001) 2019-08-01 10:33:52 -07:00
CyrusNajmabadi 237f8d2222
Add python aliases support. (#2974) 2019-07-25 11:21:06 -07:00
Luke Hoban 3768e5c690
Python Dynamic Providers (#2900)
Dynamic providers in Python.

This PR uses [dill](https://pypi.org/project/dill/) for code serialization, along with a customization to help ensure deterministic serialization results.

One notable limitation - which I believe is a general requirement of Python - is that any serialization of Python functions must serialize byte code, and byte code is not safely versioned across Python versions.  So any resource created with Python `3.x.y` can only be updated by exactly the same version of Python.  This is very constraining, but it's not clear there is any other option within the realm of what "dynamic providers" are as a feature.  It is plausible that we could ensure that updates which only update the serialized provider can avoid calling the dynamic provider operations, so that version updates could still be accomplished.  We can explore this separately.

```py
from pulumi import ComponentResource, export, Input, Output
from pulumi.dynamic import Resource, ResourceProvider, CreateResult, UpdateResult
from typing import Optional
from github import Github, GithubObject

auth = "<auth token>"
g = Github(auth)

class GithubLabelArgs(object):
    owner: Input[str]
    repo: Input[str]
    name: Input[str]
    color: Input[str]
    description: Optional[Input[str]]
    def __init__(self, owner, repo, name, color, description=None):
        self.owner = owner
        self.repo = repo
        self.name = name
        self.color = color
        self.description = description

class GithubLabelProvider(ResourceProvider):
    def create(self, props):
        l = g.get_user(props["owner"]).get_repo(props["repo"]).create_label(
            name=props["name"],
            color=props["color"],
            description=props.get("description", GithubObject.NotSet))
        return CreateResult(l.name, {**props, **l.raw_data}) 
    def update(self, id, _olds, props):
        l = g.get_user(props["owner"]).get_repo(props["repo"]).get_label(id)
        l.edit(name=props["name"],
               color=props["color"],
               description=props.get("description", GithubObject.NotSet))
        return UpdateResult({**props, **l.raw_data})
    def delete(self, id, props):
        l = g.get_user(props["owner"]).get_repo(props["repo"]).get_label(id)
        l.delete()

class GithubLabel(Resource):
    name: Output[str]
    color: Output[str]
    url: Output[str]
    description: Output[str]
    def __init__(self, name, args: GithubLabelArgs, opts = None):
        full_args = {'url':None, 'description':None, 'name':None, 'color':None, **vars(args)}
        super().__init__(GithubLabelProvider(), name, full_args, opts)

label = GithubLabel("foo", GithubLabelArgs("lukehoban", "todo", "mylabel", "d94f0b"))

export("label_color", label.color)
export("label_url", label.url)
```


Fixes https://github.com/pulumi/pulumi/issues/2902.
2019-07-19 10:18:25 -07: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
Pat Gavlin 6e5c4a38d8
Defer all diffs to resource providers. (#2849)
Thse changes make a subtle but critical adjustment to the process the
Pulumi engine uses to determine whether or not a difference exists
between a resource's actual and desired states, and adjusts the way this
difference is calculated and displayed accordingly.

Today, the Pulumi engine get the first chance to decide whether or not
there is a difference between a resource's actual and desired states. It
does this by comparing the current set of inputs for a resource (i.e.
the inputs from the running Pulumi program) with the last set of inputs
used to update the resource. If there is no difference between the old
and new inputs, the engine decides that no change is necessary without
consulting the resource's provider. Only if there are changes does the
engine consult the resource's provider for more information about the
difference. This can be problematic for a number of reasons:

- Not all providers do input-input comparison; some do input-state
  comparison
- Not all providers are able to update the last deployed set of inputs
  when performing a refresh
- Some providers--either intentionally or due to bugs--may see changes
  in resources whose inputs have not changed

All of these situations are confusing at the very least, and the first
is problematic with respect to correctness. Furthermore, the display
code only renders diffs it observes rather than rendering the diffs
observed by the provider, which can obscure the actual changes detected
at runtime.

These changes address both of these issues:
- Rather than comparing the current inputs against the last inputs
  before calling a resource provider's Diff function, the engine calls
  the Diff function in all cases.
- Providers may now return a list of properties that differ between the
  requested and actual state and the way in which they differ. This
  information will then be used by the CLI to render the diff
  appropriately. A provider may also indicate that a particular diff is
  between old and new inputs rather than old state and new inputs.

Fixes #2453.
2019-07-01 12:34:19 -07:00
Chris Smith 997516a7b8
Persist engine events in batches (#2860)
* Add EngineEventsBatch type

* Persist engine events in batches

* Reenable ee_perf test

* Limit max concurrent EE requests

* Address PR feedback
2019-06-28 09:40:21 -07:00
Matt Ellis 881db4d72a Correctly flow secretness across POJO serliazation for stack outputs
Our logic to export a resource as a stack output transforms the
resource into a plain old object by eliding internal fields and then
just serializing the resource as a POJO.

The custom serialization logic we used here unwrapped an Output
without care to see if it held a secret. Now, when it does, we
continue to return an Output as the thing to be serialized and that
output is marked as a secret.

Fixes #2862
2019-06-26 15:16:07 -07:00
CyrusNajmabadi 7b8421f0b2
Fix crash when there were multiple duplicate aliases to the same resource. (#2865) 2019-06-23 02:16:18 -07:00
CyrusNajmabadi b26f444a0f
Disable test that is blocking PRs. (#2855) 2019-06-20 16:47:24 -07:00
CyrusNajmabadi 867abac947
Make it possible with aliases to say 'I had no parent before' (#2853) 2019-06-20 15:53:33 -07:00
Matt Ellis eb3a7d0a7a Fix up some spelling errors
@keen99 pointed out that newer versions of golangci-lint were failing
due to some spelling errors. This change fixes them up.  We have also
now have a work item to track moving to a newer golangci-lint tool in
the future.

Fixes #2841
2019-06-18 15:30:25 -07:00
CyrusNajmabadi 11a19a4990
Make it possible to get a StackReference output promptly (#2824) 2019-06-17 12:25:56 -07:00
Alex Clemmer 02788b9b32 Implement listResourceOutputs in the Node.js SDK
This commit will expose the new `Invoke` routine that lists resource
outputs through the Node.js SDK.

This API is implemented via a new API, `EnumerablePromise`, which is a
collection of simple query primitives built onto the `Promise` API. The
query model is lazy and LINQ-like, and generally intended to make
`Promise` simpler to deal with in query scenarios. See #2601 for more
details.

Fixes #2600.
2019-06-03 14:56:49 -07:00
Luke Hoban 15e924b5cf
Support aliases for renaming, re-typing, or re-parenting resources (#2774)
Adds a new resource option `aliases` which can be used to rename a resource.  When making a breaking change to the name or type of a resource or component, the old name can be added to the list of `aliases` for a resource to ensure that existing resources will be migrated to the new name instead of being deleted and replaced with the new named resource.

There are two key places this change is implemented. 

The first is the step generator in the engine.  When computing whether there is an old version of a registered resource, we now take into account the aliases specified on the registered resource.  That is, we first look up the resource by its new URN in the old state, and then by any aliases provided (in order).  This can allow the resource to be matched as a (potential) update to an existing resource with a different URN.

The second is the core `Resource` constructor in the JavaScript (and soon Python) SDKs.  This change ensures that when a parent resource is aliased, that all children implicitly inherit corresponding aliases.  It is similar to how many other resource options are "inherited" implicitly from the parent.

Four specific scenarios are explicitly tested as part of this PR:
1. Renaming a resource
2. Adopting a resource into a component (as the owner of both component and consumption codebases)
3. Renaming a component instance (as the owner of the consumption codebase without changes to the component)
4. Changing the type of a component (as the owner of the component codebase without changes to the consumption codebase)
4. Combining (1) and (3) to make both changes to a resource at the same time
2019-05-31 23:01:01 -07:00
Pat Gavlin 2324eaaa59
Add StackReference to the Python SDK (#2786)
This commit adds StackReference to the Python SDK, which uses
read_resource to read the remote state of a a Pulumi stack.
2019-05-30 14:12:37 -07:00
Joe Duffy bf75fe0662
Suppress JSON outputs in preview correctly (#2771)
If --suppress-outputs is passed to `pulumi preview --json`, we
should not emit the stack outputs. This change fixes pulumi/pulumi#2765.

Also adds a test case for this plus some variants of updates.
2019-05-25 12:10:38 +02:00
Matt Ellis 4f693af023 Do not pass arguments as secrets to CheckConfig/Configure
Providers from plugins require that configuration value be
strings. This means if we are passing a secret string to a
provider (for example, trying to configure a kubernetes provider based
on some secret kubeconfig) we need to be careful to remove the
"secretness" before actually making the calls into the provider.

Failure to do this resulted in errors saying that the provider
configuration values had to be strings, and of course, the values
logically where, they were just marked as secret strings

Fixes #2741
2019-05-17 16:42:29 -07:00
Matt Ellis b606b3091d Allow passing a nil SecretsManager to SerializeDeployment
When nil, it means no information is retained in the deployment about
the manager (as there is none) and any attempt to persist secret
values fails.

This should only be used in cases where the snapshot is known to not
contain secret values.
2019-05-10 17:07:52 -07:00
Matt Ellis 5cde8e416a Rename base64sm to b64 2019-05-10 17:07:52 -07:00
Matt Ellis cc74ef8471 Encrypt secret values in deployments
When constructing a Deployment (which is a plaintext representation of
a Snapshot), ensure that we encrypt secret values. To do so, we
introduce a new type `secrets.Manager` which is able to encrypt and
decrypt values. In addition, it is able to reflect information about
itself that can be stored in the deployment such that we can
deserialize the deployment into a snapshot (decrypting the values in
the process) without external knowledge about how it was encrypted.

The ability to do this is import for allowing stack references to
work, since two stacks may not use the same manager (or they will use
the same type of manager, but have different state).

The state value is stored in plaintext in the deployment, so it **must
not** contain sensitive data.

A sample manager, which just base64 encodes and decodes strings is
provided, as it useful for testing. We will allow it to be varried
soon.
2019-05-10 17:07:52 -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
Joe Duffy fcfaa641b6
Ignore spurious warning on Node.js 11 (#2682)
This fixes a nightly test failure that only occurs on Node.js 11,
due to the JSON output including a diagnostics message the Node.js
runtime prints to stderr during the test run.
2019-04-29 10:46:09 -07:00
joeduffy 019600719b Suppress header/footer in JSON mode
...and also switch back to printing these to stdout otherwise.
2019-04-25 18:01:51 -07:00
joeduffy 250bcb9751 Add a --json flag to the preview command
This change adds a --json flag to the preview command, enabling
basic JSON serialization of preview plans. This effectively flattens
the engine event stream into a preview structure that contains a list
of steps, diagnostics, and summary information. Each step contains
the deep serialization of resource state, in addition to metadata about
the step, such as what kind of operation it entails.

This is a partial implementation of pulumi/pulumi#2390. In particular,
we only support --json on the `preview` command itself, and not `up`,
meaning that it isn't possible to serialize the result of an actual
deployment yet (thereby limiting what you can do with outputs, etc).
2019-04-25 17:36:31 -07:00
PLACE 70bc0436ed Add support for state in cloud object storage (S3, GCS, Azure) (#2455) 2019-04-24 20:55:39 -07:00
CyrusNajmabadi f0d8cd89cd
Consistent dependencies (#2517) 2019-03-05 20:34:51 -08:00
Sean Gillespie c720d1329f
Enable delete parallelism for Python (#2443)
* Enable delete parallelism for Python

* Add CHANGELOG.md entry

* Expand changelog message - upgrade to Python 3

* Rework stack rm test

The service now allows removing a stack if it just contains the top
level `pulumi:pulumi:Stack` resource, so we need to actually create
another resource before `stack rm` fails telling you to pass
`--force`.

Fixes #2444
2019-02-12 14:49:43 -08:00
Matt Ellis 687a780b20 Show a better error when --force needs to be passed to stack rm
When `pulumi stack rm` is run against a stack with resources, the
service will respond with an error if `--force` is not
passed. Previously we would just dump the contents of this error and
it looked something like:

`error: [400] Bad Request: Stack still has resources.`

We now handle this case more gracefully, showing our usual "this stack
still has resources" error like we would for the local backend.

Fixes #2431
2019-02-07 15:25:02 -08:00
Matt Ellis d9b6d54e2e Use prefered new pulumi.Config() form
In #2330 there was a case where if you didn't pass a value to the
`pulumi.Config()` constructor, things would fail in a weird manner.

This shouldn't be the case, and I'm unable to reproduce the issue. So
I'm updating the test to use the form that didn't work at one point so
we can lock in the win.

Fixes #2330
2019-01-31 16:11:57 -08: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
Matt Ellis 42ea5d7d14 Pass project in StackReference test 2019-01-30 16:54:12 -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
diana-slaba bf300038d4
Initial stack history command (#2270)
* Initial stack history command

* Adding use of color pkg, adding background colors to color pkg, and removing extra stack output

* gofmt-ed colors file

* Fixing format and removing JSON output

* Fixing nits, changing output for environment, and adding some tests

* fixing failing history test
2019-01-14 18:19:24 -08:00
Matt Ellis 08ed8ad97e
Relax baseline for the TestEngineEventPerf test (#2336)
* Relax baseline for the TestEngineEventPerf test

The mesurments we used to compute the baseline were on a local recent
MacBook. We added some slack, but we've already seen instances of the
baseline being too tight, even with no changes in product code.

This is most common on the OSX machines in Travis, which in general
seem quite slow for many workloads.

We'll bump it up to 8 seconds and if we start hitting that as well,
we'll need to do something more serious.
2019-01-05 23:58:11 -08:00
Chris Smith 5619fbce49
Add EngineEvents perf test (#2315)
* Add EngineEvents stress test

* Address PR feedback

* Specify value to config bag

* Don't test run in parallel
2019-01-03 14:18:19 -08:00
Sean Gillespie 03dbf2754c
Launch Python programs with 'python3' by default (#2204)
'python' is not usually symlinked to 'python3' on most distros unless
you are already running in a virtual environment. Launching 'python3'
explicitly ensures that we will either launch the program successfully
or immediately fail, instead of launching the program with Python 2 and
failing with syntax errors at runtime.

This commit also emits an error message asking users to install Python
3.6 or later if we failed to find the 'python3' executable.
2018-11-19 17:54:24 -05:00
Matt Ellis 6e95bdda9c Merge branch 'release/0.16' into ellismg/merge-release 2018-11-16 20:22:13 -08:00
Matt Ellis c95890c481 Don't require stderr to be empty in a test
Because of a bug in our version scripts (which will be addressed by
pulumi/pulumi#2216) we generate a goofy version when building an
untagged commit in the release branches. That causes our logic to
decide if it should print the upgrade message or not to print an
upgrade message, because it thinks the CLI is out of date.

It then prints the upgrade message and a test fails because it is
expecting an empty stderr.

Just stop checking that stderr was empty, and just validate standard
out.
2018-11-16 20:07:24 -08:00
Pat Gavlin bc08574136
Add an API for importing stack outputs (#2180)
These changes add a new resource to the Pulumi SDK,
`pulumi.StackReference`, that represents a reference to another stack.
This resource has an output property, `outputs`, that contains the
complete set of outputs for the referenced stack. The Pulumi account
performing the deployment that creates a `StackReference`  must have
access to the referenced stack or the call will fail.

This resource is implemented by a builtin provider managed by the engine.
This provider will be used for any custom resources and invokes inside
the `pulumi:pulumi` module. Currently this provider supports only the
`pulumi:pulumi:StackReference` resource.

Fixes #109.
2018-11-14 13:33:35 -08:00
Matt Ellis 22fef07fcf Remove existing lock files 2018-11-12 15:33:58 -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
Sean Gillespie 9c82082a57
Implement RegisterResourceOutputs for Python 3 (#2173)
* Implement RegisterResourceOutputs for Python 3

RegisterResourceOutputs allows Python 3 programs to export stack outputs
and export outputs off of component resources (which, under the hood,
are the same thing).

Adds a new integration test for stack outputs for Python programs, as
well as add a langhost test for register resource outputs.

Fixes pulumi/pulumi#2163

* CR: Rename stack_output -> export

Fix integration tests that hardcoded paths to stack_outputs

* Fix one more reference to stack_outputs
2018-11-08 09:44:34 -08:00
Sean Gillespie 36c88aab37
Fix Python support in integration test framework (#2158)
* Fix Python support in integration test framework

Update the integratino test framework to use pipenv to bootstrap new
virtual environments for tests and use those virtual environments to run
pulumi update and pulumi preview.

Fixes pulumi/pulumi#2138

* Install packages via 'Dependencies' field

* Remove code for installing packages from Dependencies
2018-11-05 13:52:37 -08:00
Joe Duffy 9aedb234af
Tidy up some data structures (#2135)
In preparation for some workspace restructuring, I decided to scratch a
few itches of my own in the code:

* Change project's RuntimeInfo field to just Runtime, to match the
  serialized name in JSON/YAML.

* Eliminate the no-longer-used Context and NoDefaultIgnores fields on
  project, and all of the associated legacy PPC-related code.

* Eliminate the no-longer-used IgnoreFile constant.

* Remove a bunch of "// nolint: lll" annotations, and simply format
  the structures with comments on dedicated lines, to avoid overly
  lengthy lines and lint suppressions.

* Mark Dependencies and InitErrors as `omitempty` in the JSON
  serialization directives for CheckpointV2 files. This was done for
  the YAML directives, but (presumably accidentally) omitted for JSON.
2018-11-01 08:28:11 -07:00
Sean Gillespie 56be1a6677
Implement RPC for Python 3 (#2111)
* Implement RPC for Python 3

* Try not setting PYTHONPATH

* Remove PYTHONPATH line

* Implement Invoke for Python 3

* Implement register resource

* progress

* Rewrite the whole thing

* Fix a few bugs

* All tests pass

* Fix an abnormal shutdown bug

* CR feedback

* Provide a hook for resources to rename properties

As dictionaries and other classes come from the engine, the
translate_property hook can be used to intercept them and rename
properties if desired.

* Fix variable names and comments

* Disable Python integration tests for now
2018-10-31 13:35:31 -07:00
CyrusNajmabadi 76d08f8590
Simplify summary text. (#2136) 2018-10-30 21:57:38 -07:00
Matt Ellis 5b97cf5cd1 Don't prompt if you want to continue when --skip-preview is passed
If you took the time to type out `--skip-preview`, we should have high
confidence that you don't want a preview and you're okay with the
operation just happening without a prompt.

Fixes #1448
2018-10-26 15:41:29 -07:00
Matt Ellis 19cf3c08fa Add --json flag to pulumi stack ls
We've had multiple users ask for this, so let's do it proactively
instead of waiting for #496

Fixes #2018
2018-10-26 13:13:50 -07:00
Joe Duffy c5a86ae7c2
Add an option to suppress displaying stack outputs (#2029)
This adds an option, --suppress-outputs, to many commands, to
avoid printing stack outputs for stacks that might contain sensitive
information in their outputs (like key material, and whatnot).

Fixes pulumi/pulumi#2028.
2018-10-06 14:13:02 -07:00
Joe Duffy 4640d12e08
Enable stack outputs to be JSON formatted (#2000)
This change adds a --json (short -j) flag for `pulumi stack output`
that prints the results as JSON, rather than our ad-hoc format.

Fixes pulumi/pulumi#1863.
2018-09-29 09:57:58 -07:00
joeduffy f4ed9763a7 Update test baselines
This updates the test baselines to validate the new output.
2018-09-24 15:22:50 -07:00
CyrusNajmabadi 4f9db82a43
Stop using black/white colors directly when printing out console text. They can have issues with light/dark terminals. (#1951) 2018-09-19 01:40:03 -07:00
Pat Gavlin d67e04247f
Fix a few dynamic provider issues. (#1935)
- Do not require replacement of dynamic resources due to provider
  changes. This is not necessary, and is almost certainly the wrong
  thing to do if the dynamic provider is managing a physical resource.

- Return all inputs by default from a dynamic provider's check method.
  Currently a dynamic provider that does not implement check will end up
  receiving no inputs. This is confusing, and is not the correct default.
2018-09-14 19:59:06 -07:00
Sean Gillespie a35aba137b
Retire pending deletions at start of plan (#1886)
* Retire pending deletions at start of plan

Instead of letting pending deletions pile up to be retired at the end of
a plan, this commit eagerly disposes of any pending deletions that were
pending at the end of the previous plan. This is a nice usability win
and also reclaims an invariant that at most one resource with a given
URN is live and at most one is pending deletion at any point in time.

* Rebase against master

* Fix a test issue arising from shared snapshots

* CR feedback

* plan -> replacement

* Use ephemeral statuses to communicate deletions
2018-09-10 16:48:14 -07:00
CyrusNajmabadi 0d6acebecd
Be resilient to encountering invalid data in a package.json file. (#1897) 2018-09-06 16:35:14 -07:00
joeduffy c1967129e7 Fix integration tests
This fixes the integration tests:

* Expect and allow the update header.

* Don't print the local permalink if there's an error.
2018-09-05 11:39:58 -07:00
joeduffy db48f10412 Update test frameworks to new packages 2018-09-05 08:16:14 -07:00
Matt Ellis 44714864b3 Use the local backend in another test
In CI, when runing a test job for a Pull Request from a fork of
pulumi/pulumi we are unable to use the service (since we don't have an
access token, since Travis does not allow secure environment
varables in pull requests job).

Our "Lifecycle" tests already are no-ops in these cases, and some of our
directed tests use the local backend (in favor of just getting
skipped). Move one other directed test over to using the local
backend, as well. This should get PR's from forks green again.
2018-09-04 14:27:43 -07:00
Pat Gavlin abfdf69a9c
Indent stack outputs by 1. (#1822)
* Indent stack outputs by 1.

Also:
- Show stack output diffs during preview
- Fix a bug where deletes in stack outputs were not displayed
2018-08-24 15:36:55 -07:00
Pat Gavlin 73f4f2c464
Reimplement refresh. (#1814)
Replace the Source-based implementation of refresh with a phase that
runs as the first part of plan execution and rewrites the snapshot in-memory.

In order to fit neatly within the existing framework for resource operations,
these changes introduce a new kind of step, RefreshStep, to represent
refreshes. RefreshSteps operate similar to ReadSteps but do not imply that
the resource being read is not managed by Pulumi.

In addition to the refresh reimplementation, these changes incorporate those
from #1394 to run refresh in the integration test framework.

Fixes #1598.
Fixes pulumi/pulumi-terraform#165.
Contributes to #1449.
2018-08-22 17:52:46 -07:00
CyrusNajmabadi 8aed774f09
Properly capture modules that are in a non-local node_modules path. (#1803) 2018-08-21 12:43:52 -07:00
Sean Gillespie 491bcdc602
Add a list of in-flight operations to the deployment (#1759)
* Add a list of in-flight operations to the deployment

This commit augments 'DeploymentV2' with a list of operations that are
currently in flight. This information is used by the engine to keep
track of whether or not a particular deployment is in a valid state.

The SnapshotManager is responsible for inserting and removing operations
from the in-flight operation list. When the engine registers an intent
to perform an operation, SnapshotManager inserts an Operation into this
list and saves it to the snapshot. When an operation completes, the
SnapshotManager removes it from the snapshot. From this, the engine can
infer that if it ever sees a deployment with pending operations, the
Pulumi CLI must have crashed or otherwise abnormally terminated before
seeing whether or not an operation completed successfully.

To remedy this state, this commit also adds code to 'pulumi stack
import' that clears all pending operations from a deployment, as well as
code to plan generation that will reject any deployments that have
pending operations present.

At the CLI level, if we see that we are in a state where pending
operations were in-flight when the engine died, we'll issue a
human-friendly error message that indicates which resources are in a bad
state and how to recover their stack.

* CR: Multi-line string literals, renaming in-flight -> pending

* CR: Add enum to apitype for operation type, also name status -> type for clarity

* Fix the yaml type

* Fix missed renames

* Add implementation for lifecycle_test.go

* Rebase against master
2018-08-10 21:39:59 -07:00
Justin Van Patten 9d84f2e249
Initial support for passing URLs to new and up (#1727)
* Initial support for passing URLs to `new` and `up`

This PR adds initial support for `pulumi new` using Git under the covers
to manage Pulumi templates, providing the same experience as before.

You can now also optionally pass a URL to a Git repository, e.g.
`pulumi new [<url>]`, including subdirectories within the repository,
and arbitrary branches, tags, or commits.

The following commands result in the same behavior from the user's
perspective:
 - `pulumi new javascript`
 - `pulumi new https://github.com/pulumi/templates/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/master/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/HEAD/templates/javascript`

To specify an arbitrary branch, tag, or commit:
 - `pulumi new https://github.com/pulumi/templates/tree/<branch>/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/<tag>/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/<commit>/templates/javascript`

Branches and tags can include '/' separators, and `pulumi` will still
find the right subdirectory.

URLs to Gists are also supported, e.g.:
`pulumi new https://gist.github.com/justinvp/6673959ceb9d2ac5a14c6d536cb871a6`

If the specified subdirectory in the repository does not contain a
`Pulumi.yaml`, it will look for subdirectories within containing
`Pulumi.yaml` files, and prompt the user to choose a template, along the
lines of how `pulumi new` behaves when no template is specified.

The following commands result in the CLI prompting to choose a template:
 - `pulumi new`
 - `pulumi new https://github.com/pulumi/templates/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/master/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/HEAD/templates`

Of course, arbitrary branches, tags, or commits can be specified as well:
 - `pulumi new https://github.com/pulumi/templates/tree/<branch>/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/<tag>/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/<commit>/templates`

This PR also includes initial support for passing URLs to `pulumi up`,
providing a streamlined way to deploy installable cloud applications
with Pulumi, without having to manage source code locally before doing
a deployment.

For example, `pulumi up https://github.com/justinvp/aws` can be used to
deploy a sample AWS app. The stack can be updated with different
versions, e.g.
`pulumi up https://github.com/justinvp/aws/tree/v2 -s <stack-to-update>`

Config values can optionally be passed via command line flags, e.g.
`pulumi up https://github.com/justinvp/aws -c aws:region=us-west-2 -c foo:bar=blah`

Gists can also be used, e.g.
`pulumi up https://gist.github.com/justinvp/62fde0463f243fcb49f5a7222e51bc76`

* Fix panic when hitting ^C from "choose template" prompt

* Add description to templates

When running `pulumi new` without specifying a template, include the template description along with the name in the "choose template" display.

```
$ pulumi new
Please choose a template:
  aws-go                  A minimal AWS Go program
  aws-javascript          A minimal AWS JavaScript program
  aws-python              A minimal AWS Python program
  aws-typescript          A minimal AWS TypeScript program
> go                      A minimal Go program
  hello-aws-javascript    A simple AWS serverless JavaScript program
  javascript              A minimal JavaScript program
  python                  A minimal Python program
  typescript              A minimal TypeScript program
```

* React to changes to the pulumi/templates repo.

We restructured the `pulumi/templates` repo to have all the templates in the root instead of in a `templates` subdirectory, so make the change here to no longer look for templates in `templates`.

This also fixes an issue around using `Depth: 1` that I found while testing this. When a named template is used, we attempt to clone or pull from the `pulumi/templates` repo to `~/.pulumi/templates`. Having it go in this well-known directory allows us to maintain previous behavior around allowing offline use of templates. If we use `Depth: 1` for the initial clone, it will fail when attempting to pull when there are updates to the remote repository. Unfortunately, there's no built-in `--unshallow` support in `go-git` and setting a larger `Depth` doesn't appear to help. There may be a workaround, but for now, if we're cloning the pulumi templates directory to `~/.pulumi/templates`, we won't use `Depth: 1`. For template URLs, we will continue to use `Depth: 1` as we clone those to a temp directory (which gets deleted) that we'll never try to update.

* List available templates in help text

* Address PR Feedback

* Don't show "Installing dependencies" message for `up`

* Fix secrets handling

When prompting for config, if the existing stack value is a secret, keep it a secret and mask the prompt. If the template says it should be secret, make it a secret.

* Fix ${PROJECT} and ${DESCRIPTION} handling for `up`

Templates used with `up` should already have a filled-in project name and description, but if it's a `new`-style template, that has `${PROJECT}` and/or `${DESCRIPTION}`, be helpful and just replace these with better values.

* Fix stack handling

Add a bool `setCurrent` param to `requireStack` to control whether the current stack should be saved in workspace settings. For the `up <url>` case, we don't want to save. Also, split the `up` code into two separate functions: one for the `up <url>` case and another for the normal `up` case where you have workspace in your current directory. While we may be able to combine them back into a single function, right now it's a bit cleaner being separate, even with some small amount of duplication.

* Fix panic due to nil crypter

Lazily get the crypter only if needed inside `promptForConfig`.

* Embellish comment

* Harden isPreconfiguredEmptyStack check

Fix the code to check to make sure the URL specified on the command line matches the URL stored in the `pulumi:template` config value, and that the rest of the config from the stack satisfies the config requirements of the template.
2018-08-10 18:08:16 -07:00
Pat Gavlin 58a75cbbf4
Pull default options from a resource's parent. (#1748)
If a resource's options bag does not specify `protect` or `provider`,
pull a default value from the resource's parent.

In order to allow a parent resource to specify providers for multiple
resource types, component resources now accept an optional map from
package name to provider instance. When a custom resource needs a
default provider from its parent, it checks its parent provider bag for
an entry under its package. If a component resource does not have a
provider bag, its pulls a default from its parent.

These changes also add a `parent` field to `InvokeOptions` s.t. calls to
invoke can use the same behavior as resource creation w.r.t. providers.

Fixes #1735, #1736.
2018-08-10 16:18:21 -07:00
Sean Gillespie a09d9ba035
Default to a parallelism fanout of 10 (#1756)
* Default to a parallelism fanout of 10

* Add dependsOn to double_pending_delete tests to force serialization
2018-08-10 14:16:59 -07:00
Matt Ellis 00f5a02b99 Make test package versions valid semvers
NPM and some other packages (including read-package-json that
@pulumi/pulumi) uses require the version field to be a valid
semver. So ensure ours are.
2018-08-09 19:10:00 -07:00
Pat Gavlin e8697d872a
Elide events that refer to default providers. (#1739)
The belief is that this hides some complexity that we shouldn't be
exposing in the default case.

In order to filter these events from both the diff/progress display
and the resource change summary, we perform this filtering in
`pkg/engine`.

Fixes #1733.
2018-08-09 14:45:39 -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
Matt Ellis a337f17c70 Add a small end to end test for config capturing 2018-08-08 13:49:37 -07:00
Pat Gavlin 5513f08669
Do not call Read in read steps with unknown IDs. (#1734)
This is consistent with the behavior prior to the introduction of Read
steps. In order to avoid a breaking change we must do this check in the
engine itself, which causes a bit of a layering violation: because IDs
are marshaled as raw strings rather than PropertyValues, the engine must
check against the marshaled form of an unknown directly (i.e.
`plugin.UnknownStringValue`).
2018-08-08 12:06:20 -07:00
Pat Gavlin 94802f5c16
Fix deletes with duplicate URNs. (#1716)
When calculating deletes, we will only issue a single delete step for a
particular URN. This is incorrect in the presence of pending deletes
that share URNs with a live resource if the pending deletes follow the
live resource in the checkpoint: instead of issuing a delete for
every resource with a particular URN, we will only issue deletes for
the pending deletes.

Before first-class providers, this was mostly benigin: any remaining
resources could be deleted by re-running the destroy. With the
first-class provider changes, however, the provider for the undeleted
resources will be deleted, leaving the checkpoint in an invalid state.

These changes fix this issue by allowing the step generator to issue
multiple deletes for a single URN and add a test for this scenario.
2018-08-07 11:01:08 -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 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
Sean Gillespie 48aa5e73f8
Save resources obtained from ".get" in the snapshot (#1654)
* Protobuf changes to record dependencies for read resources

* Add a number of tests for read resources, especially around replacement

* Place read resources in the snapshot with "external" bit set

Fixes pulumi/pulumi#1521. This commit introduces two new step ops: Read
and ReadReplacement. The engine generates Read and ReadReplacement steps
when servicing ReadResource RPC calls from the language host.

* Fix an omission of OpReadReplace from the step list

* Rebase against master

* Transition to use V2 Resources by default

* Add a semantic "relinquish" operation to the engine

If the engine observes that a resource is read and also that the
resource exists in the snapshot as a non-external resource, it will not
delete the resource if the IDs of the old and new resources match.

* Typo fix

* CR: add missing comments, DeserializeDeployment -> DeserializeDeploymentV2, ID check
2018-08-03 14:06:00 -07:00
Luke Hoban 85121274aa
Allow dependsOn to accept a Resource | Resource[] (#1692)
Fixes #1690.
2018-08-02 13:13:33 -07:00
Sean Gillespie c4f08db78b
Fix an issue where we fail to catch duplicate URNs in the same plan (#1687) 2018-08-01 21:32:29 -07:00
Joe Duffy 76eea4863a
Prefer "up" over "update" (#1672) 2018-07-31 10:22:16 -07:00
CyrusNajmabadi b90235c611
Add license fields to package.json. (#1656) 2018-07-24 16:10:13 -07:00
Alex Clemmer f037c7d143 Checkpoint resource initialization errors
When a resource fails to initialize (i.e., it is successfully created,
but fails to transition to a fully-initialized state), and a user
subsequently runs `pulumi update` without changing that resource, our
CLI will fail to warn the user that this resource is not initialized.

This commit begins the process of allowing our CLI to report this by
storing a list of initialization errors in the checkpoint.
2018-07-20 17:59:06 -07:00
Sean Gillespie 80c28c00d2
Add a migrate package for migrating to and from differently-versioned API types (#1647)
* Add a migrate package for migrating to and from differently-versioned
API types

* travis: gofmt -s deployment_test.go
2018-07-20 13:31:41 -07:00
Sean Gillespie 57ae7289f3
Work around a potentially bad assert in the engine (#1644)
* Work around a potentially bad assert in the engine

The engine asserts if presented with a plan that deletes the same URN
more than once. This has been empirically proven to be possible, so I am
removing the assert.

* CR: Add log for multiple pending-delete deletes
2018-07-18 15:48:55 -07:00
Sean Gillespie 1cbf8bdc40 Partial status for resource providers
This commit adds CLI support for resource providers to provide partial
state upon failure. For resource providers that model resource
operations across multiple API calls, the Provider RPC interface can now
accomodate saving bags of state for resource operations that failed.
This is a common pattern for Terraform-backed providers that try to do
post-creation steps on resource as part of Create or Update resource
operations.
2018-07-02 13:32:23 -07:00
CyrusNajmabadi 0b0927d257
Fix printing out outputs in a pulumi program. (#1531) 2018-06-18 16:03:26 -07:00
Matt Ellis c5b7caa52b
Merge pull request #1506 from pulumi/ellismg/clean-up-build-test-issues
Fix some build and test issues
2018-06-17 23:09:34 -07:00
CyrusNajmabadi 57ee29ebbb
Tweak readme. (#1505) 2018-06-15 13:33:51 -07:00
Matt Ellis a47babd194 Run export/import rounttrip as part of our lifecycle tests
This allows us to delete the one off export/import test, which is nice
because it failed to run when PULUMI_ACCESS_TOKEN was not set in the
environment (due to an interaction between `pulumi login` and the
bare-bones integration test framework)
2018-06-14 16:01:28 -07:00
Pat Gavlin dc0c604ae7
Enable fork builds. (#1495)
If we're building in CI and do not have an access token, skip any
lifecycle tests.
2018-06-11 16:01:04 -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
Matt Ellis 8a6ffd08b2 Use crypto/rand when generating a stack suffix
math/rand uses a fixed seed, meaning that across runs the Kth call to
`rand.Int63()` will always return the same value.

Given that we want to provide a unique suffix across multiple
concurrent runs, this isn't the behavior we want.

I saw an instance fail in CI where all three legs ran the test
concurrently and they raced on creating the test stack, since they all
generated the same name.
2018-06-05 11:06:01 -07:00
Justin Van Patten 6a11d049b7
Add optional --dir flag to pulumi new (#1459)
Usage:

```
pulumi new <template> --dir folderName
```

Used to specify the directory where to place the generated project.
If the directory does not exist, it will be created.
2018-06-04 13:33:58 -07:00
Sean Gillespie 1a2d4d9ff1
Fix an issue where the Version field of an UntypeDeployment was lost (#1450)
The Version field was inadvertently dropped when sending an import
request to the service. Now that we are requiring that the Version field
be set in deployments, this was causing errors.
2018-06-03 14:30:51 -07:00
Chris Smith 485bb35180
Relax stack name requirements (#1381)
* Relax stack name requirements

* Add error if stack name too long

* Max tag length is 256 chars
2018-05-29 13:52:11 -07:00
Sean Gillespie 924c49d7e0
Fail fast when attempting to load a too-new or too-old deployment (#1382)
* Error when loading a deployment that is not a version that the CLI understands

* Add a test for 'pulumi stack import' on a badly-versioned deployment

* Move current deployment version to 'apitype'

* Rebase against master

* CR: emit CLI-friendly error message at the two points outside of the engine calling 'DeserializeDeployment'
2018-05-25 13:29:59 -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
Matt Ellis 0732b05c5d Remove pulumi init
`pulumi init` was part of our old identity model with the service and
is no longer used. We can now delete this code.

Fixes #1241
2018-05-22 13:37:08 -07:00
Justin Van Patten e1edd1e88d
Make the default pulumi new project description empty (#1339)
Previously, we'd default to "A Pulumi project.", which isn't a helpful
description for any real project.
2018-05-08 10:46:39 -07:00
Justin Van Patten d1b49d25f8
pulumi new improvements (#1307)
* Initialize a new stack as part of `pulumi new`
* Prompt for values with defaults preselected
* Install dependencies
* Prompt for default config values
2018-05-07 15:31:27 -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
joeduffy 6ad785d5c4 Revise the way previews are controlled
I found the flag --force to be a strange name for skipping a preview,
since that name is usually reserved for operations that might be harmful
and yet you're coercing a tool to do it anyway, knowing there's a chance
you're going to shoot yourself in the foot.

I also found that what I almost always want in the situation where
--force was being used is to actually just run a preview and have the
confirmation auto-accepted.  Going straight to --force isn't the right
thing in a CI scenario, where you actually want to run a preview first,
just to ensure there aren't any issues, before doing the update.

In a sense, there are four options here:

1. Run a preview, ask for confirmation, then do an update (the default).
2. Run a preview, auto-accept, and then do an update (the CI scenario).
3. Just run a preview with neither a confirmation nor an update (dry run).
4. Just do an update, without performing a preview beforehand (rare).

This change enables all four workflows in our CLI.

Rather than have an explosion of flags, we have a single flag,
--preview, which can specify the mode that we're operating in.  The
following are the values which correlate to the above four modes:

1. "": default (no --preview specified)
2. "auto": auto-accept preview confirmation
3. "only": only run a preview, don't confirm or update
4. "skip": skip the preview altogether

As part of this change, I redid a bit of how the preview modes
were specified.  Rather than booleans, which had some illegal
combinations, this change introduces a new enum type.  Furthermore,
because the engine is wholly ignorant of these flags -- and only the
backend understands them -- it was confusing to me that
engine.UpdateOptions stored this flag, especially given that all
interesting engine options _also_ accepted a dryRun boolean.  As of
this change, the backend.PreviewBehavior controls the preview options.
2018-05-06 13:55:04 -07:00
CyrusNajmabadi fd3ddda917
Disable interactive mode for a CI/CD server. (#1297) 2018-04-30 15:27:53 -07:00
Matt Ellis e6d2854429 Remove pulumi history command
We already have a great history viewing experience on
Pulumi.com. `pulumi history` in the CLI today is basically unuseable,
and instead of working on trying to improve it, let's just remove it
for now.

Fixes #965
2018-04-30 12:12:27 -07:00
CyrusNajmabadi 11f1e444f4
Require a resource's parent to actually be a resource. (#1266) 2018-04-24 17:23:18 -07:00
CyrusNajmabadi 3b13803c71
Add a hidden --no-interactive flag so that we can reduce interactive noise when running jenkins. (#1262) 2018-04-24 14:23:08 -07:00
Chris Smith 6a0718bcff
Revert adding HEAD commit info to update env (#1257) 2018-04-23 14:01:28 -07:00
Chris Smith 4651419f7f
Add Commit message, committer, and author to update env (#1249)
* Add Commit message, committer, and author to update env

* Remove low value comments
2018-04-23 11:39:14 -07:00
Matt Ellis cc938a3bc8 Merge remote-tracking branch 'origin/master' into ellismg/identity 2018-04-20 01:56:41 -04:00
Sean Gillespie 28806ac9f3
Fix the protect_resources test (#1228)
Step 3 should also assert that the protected resource that we failed to
delete is still in the checkpoint.
2018-04-18 12:26:46 -07:00
Matt Ellis 50982e8763 Add some randomness to stack names in our integration tests
To prepare for a world where stack names must be unique across an
owner, add some randomness to the names we use for stacks as part of
our integration tests.
2018-04-18 04:54:02 -07:00
Matt Ellis bac02f1df1 Remove the need to pulumi init for the local backend
This change removes the need to `pulumi init` when targeting the local
backend. A fair amount of the change lays the foundation that the next
set of changes to stop having `pulumi init` be used for cloud stacks
as well.

Previously, `pulumi init` logically did two things:

1. It created the bookkeeping directory for local stacks, this was
stored in `<repository-root>/.pulumi`, where `<repository-root>` was
the path to what we belived the "root" of your project was. In the
case of git repositories, this was the directory that contained your
`.git` folder.

2. It recorded repository information in
`<repository-root>/.pulumi/repository.json`. This was used by the
cloud backend when computing what project to interact with on
Pulumi.com

The new identity model will remove the need for (2), since we only
need an owner and stack name to fully qualify a stack on
pulumi.com, so it's easy enough to stop creating a folder just for
that.

However, for the local backend, we need to continue to retain some
information about stacks (e.g. checkpoints, history, etc). In
addition, we need to store our workspace settings (which today just
contains the selected stack) somehere.

For state stored by the local backend, we change the URL scheme from
`local://` to `local://<optional-root-path>`. When
`<optional-root-path>` is unset, it defaults to `$HOME`. We create our
`.pulumi` folder in that directory. This is important because stack
names now must be unique within the backend, but we have some tests
using local stacks which use fixed stack names, so each integration
test really wants its own "view" of the world.

For the workspace settings, we introduce a new `workspaces` directory
in `~/.pulumi`. In this folder we write the workspace settings file
for each project. The file name is the name of the project, combined
with the SHA1 of the path of the project file on disk, to ensure that
multiple pulumi programs with the same project name have different
workspace settings.

This does mean that moving a project's location on disk will cause the
CLI to "forget" what the selected stack was, which is unfortunate, but
not the end of the world. If this ends up being a big pain point, we
can certianly try to play games in the future (for example, if we saw
a .git folder in a parent folder, we could store data in there).

With respect to compatibility, we don't attempt to migrate older files
to their newer locations. For long lived stacks managed using the
local backend, we can provide information on where to move things
to. For all stacks (regardless of backend) we'll require the user to
`pulumi stack select` their stack again, but that seems like the
correct trade-off vs writing complicated upgrade code.
2018-04-18 04:53:49 -07:00
Matt Ellis 6f0bc7eb46 Call pulumi stack rm --yes in some tests
Our normal lifecycle tests always call pulumi stack rm, but some of
the tests that used the more barebones framework did not do so. This
was "ok" in the past, since all bookkeeping data about a stack was
stored next to the Pulumi program itself and we deleted that folder
once the test passed.

As part of removing `pulumi init` workspace tracking will move to
~/.pulumi/workspaces and so we'd like to have a gesture that actually
removes the stack, which will cause the workspace file to be removed
as well, instead of littering ~/.pulumi/workspaces with tests.
2018-04-18 03:29:19 -07:00
Matt Ellis e83aa175ff Remove configuration upgrade code
Upcoming work to remove the need for `pulumi init` makes testing the
upgrade code much harder than it did in the past (since workspace data
is moving to a different location on the file system, as well as some
other changes).

Instead of trying to maintain the code and test, let's just remove
it. Folks who haven't migrated (LM and the PPC deployment in the
service) should use the 0.11.3 or earlier CLI to migrate their
projects (simply by logging in and running a pulumi command) or move
things forward by hand.
2018-04-18 03:29:19 -07:00
Matt Ellis a55d3f9d7e Make diff tests pass when running against a local service
In cases where we are running against a local service, the CLI does
not print a Permalink line when updating a stack, because we can not
determine what the URL for the link would be. This breaks the diff
tests which need to clean the CLI output and compare them to known
values, since the output now has one less line than expected.

Update the test's cleaning logic to handle this case.
2018-04-16 16:38:39 -07:00
CyrusNajmabadi f2b9bd4b13
Remove the explicit 'pulumi preview' command. (#1170)
Old command still exists, but tells you to run "pulumi update --preview".
2018-04-13 22:26:01 -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
Chris Smith ab2385437a
Validate stack properties like names, runtime, etc. (#1146)
* Validate stack properties like names, runtime, etc.

* Fix build error
2018-04-11 10:08:32 -07:00
CyrusNajmabadi a759f2e085
Switch to a resource-progress oriented view for pulumi preview/update/destroy (#1116) 2018-04-10 12:03:11 -07:00
CyrusNajmabadi 97c1344035
Disallow capturing 'this' inside a lambda (#1138) 2018-04-09 15:57:39 -07:00
Matt Ellis d3240fdc64 Require pulumi login before commands that need a backend
This change does three major things:

1. Removes the ability to be logged into multiple clouds at the same
time. Previously, we supported being logged into multiple clouds at
the same time and the CLI would fan out requests and join responses
when needed. In general, this was only useful for Pulumi employees
that wanted run against multiple copies of the service (say production
and staging) but overall was very confusing (for example in the old
world a stack with the same identity could appear twice (since it was
in two backends) which the CLI didn't handle very well).

2. Stops treating the "local" backend as a special thing, from the
point of view of the CLI. Previouly we'd always connect to the local
backend and merge that data with whatever was in clouds we were
connected to. We had gestures like `--local` in `pulumi stack init`
that meant "use the local mode". Instead, to use the local mode now
you run `pulumi login --cloud-url local://` and then you are logged in
the local backend. Since you can only ever be logged into a single
backend, we can remove the `--local` and `--remote` flags from `pulumi
stack init`, it just now requires you to be logged in and creates a
stack in whatever back end you were logged into. When logging into the
local backend, you are not prompted for an access key.

3. Prompt for login in places where you have to log in, if you are not
already logged in.
2018-04-05 10:19:41 -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
Joe Duffy abbac13655
Assume --remote when --cloud-url is set (#1060)
If you use --cloud-url, as in

    $ pulumi stack init foo --cloud-url https://x.io

we would silently fall back to logic that creates local stacks.

I realize all of this will get better with the new stack identity
model, however in the meantime, let's infer that the user wanted
--remote when --cloud-url is non-"".
2018-03-18 12:44:00 -07:00
Joe Duffy 41127c55e9
Add basic config tests (#1049)
This adds a basic config test, for both Node.js and Python runtimes,
that simply reads back and checks configuration and secret values.
2018-03-14 12:24:49 -07:00
Justin Van Patten c7985ed296
Support offline template descriptions (#1044)
Note: This is a minor issue that I didn't get to for M11 that isn't
required for M11 and would be fine merging for post-M11.

When you specify a template name explicitly (e.g.
`pulumi new typescript`), we'll try to download the template tarball
without first downloading the JSON list of available templates. The JSON
includes a description used when replacing the `${DESCRIPTION}` string
in template files. Since we didn't download the JSON, we won't have a
description, so we fallback to a default value (`"A Pulumi project."`).
This also happens when specifying `--offline` to use an existing
template under `~/.pulumi/templates`; we won't have a description for
the template, so we fallback to a default description. The fallback
value happens to be the same as the description for each of our current
templates, so noone will currently notice an issue.

For M11, I included initial support for a template manifest file where
the description (and any future metadata) could be stored, but didn't go
as far as actually reading the file.

This change makes it so the CLI actually reads the description from the
manifest file (if it exists), otherwise falling back to the default
value as is done currently. Some minor related cleanup is included in
this change.
2018-03-13 16:09:25 -07:00
CyrusNajmabadi 5b244dbdb1
Use a class for Output serialization to ensure that .apply exists on it. (#1040)
Also, rename/cleanup a bunch of serialization code.

Also, generate better environment names in the serialized closure code. Thsi code should be much easier to make sense of as hte names will better track to the original names in the user code.

Also, dedupe simple non-capturing functions. This helps ensure we don't spit out N copies of __awaiter (one per file it is declared in).
2018-03-12 16:27:00 -07:00
Justin Van Patten 8906731315
Adds a pulumi new command to scaffold a project (#1008)
This adds a `pulumi new` command which makes it easy to quickly
automatically create the handful of needed files to get started building
an empty Pulumi project.

Usage:

```
$ pulumi new typescript
```

Or you can leave off the template name, and it will ask you to choose
one:

```
$ pulumi new
Please choose a template:
> javascript
  python
  typescript
```
2018-03-09 15:27:55 -08:00
Matt Ellis 81a273c7bb Change represention of config.Key
config.Key has become a pair of namespace and name. Because the whole
world has not changed yet, there continues to be a way to convert
between a tokens.ModuleMember and config.Key, however now sometime the
conversion from tokens.ModuleMember can fail (when the module member
is not of the form `<package>:config:<name>`).
2018-03-08 10:52:25 -08:00
Matt Ellis 7c39620e9a Introduce config.Key
Right now, config.Key is a type alias for tokens.ModuleMember. I did a
pass over the codebase such that we use config.Key everywhere it
looked like the value did not leak to some external process (e.g a
resource provider or a langhost).

Doing this makes it a little clearer (hopefully) where code is
depending on a module member structure (e.g. <package>:config:<value>)
instead of just an opaque type.
2018-03-08 10:52:25 -08:00
Matt Ellis 96d7f9307a
Merge pull request #986 from pulumi/config-refactor
Rework config storage
2018-03-02 13:46:49 -08:00
CyrusNajmabadi e7c0e4cdaa
Make many fixes to closure serialization (#944)
Make many fixes to closure serialization

Primary things that i've done as part of this change:

    Added support for cyclic objects.
    Properly serialize objects that are shared across different function. previously you would get multiple copies, now you properly reference the same copy.
    Remove the usages of 'hashes' for functions. Because we track identity of objects, we no longer need them.
    Serialize properties of functions (if they have any).
    Handle Objects/Functions with different __proto__s than normal. i.e. classes/constructors. but also anything the user may have done themselves to the object.
    Handle generator functions.
    Handle functions with 'computed' names.
    Handle functions with 'symbol' names.
    Handle serializing Promises as Promises.
    Removed the dual Closure/AsyncClosure tree. One existed solely so we could have a tree without promises (for use in testing maybe?). Because this all exists in a part of our codebase that is entirely async, it's fine to have promises in the tree, and to await them when serializing the Closure to a string.
    Handle serializing class-constructors and methods. Including properly handling 'super' calls.
2018-03-01 00:32:01 -08:00
Matt Ellis e2ce16b057 Upgrade configuration files on first run
Migrate configuration from the old model to the new model. The
strategy here is that when we first run `pulumi` we enumerate all of
the stacks from all of the backends we know about and for each stack
get the configuration values from the project and workspace and
promote them into the new file. As we do this, we remove stack
specific config from the workspace and Pulumi.yaml file.

If we are able to upgrade all the stacks we know about, we delete all
global configuration data in the workspace and in Pulumi.yaml as well.

We have a test that ensures upgrades continue to work.
2018-02-28 17:37:18 -08:00
Matt Ellis 207a9755d8 Rework configuration model
This change updates our configuration model to make it simpler to
understand by removing some features and changing how things are
persisted in files.

Notable changes:

- We've removed the notion of "workspace" vs "project"
  config. Now, configuration is always stored in a file next to
  `Pulumi.yaml` named `Pulumi.<stack-name>.yaml` (the same file we'd
  use for an other stack specific information we would need to persist
  in the future).
- We've removed the notion of project wide configuration. Every new
  stack gets a completely empty set of configuration and there's no
  way to share common values across stacks, instead the common value
  has to be set on each stack.

We retain some of the old code for the configuration system so we can
support upgrading a project in place. That will happen with the next
change.

This change fixes some issues and allows us to close some
others (since they are no longer possible).

Fixes #866
Closes #872
Closes #731
2018-02-28 17:30:50 -08:00
Matt Ellis d99f9457b0 Deprecate old configuration model
We are going to be changing the configuration model. To begin, let's
take most of the existing stuff and mark it as "deprecated" so we can
keep the existing behavior (to help transition newer code forward)
while making it clear what APIs should not be called in the
implementation of `pulumi` itself.
2018-02-28 17:25:09 -08:00
joeduffy 2362d45a5c Eliminate type redundancy
Despite our good progress moving towards having an apitype package,
where our exchange types live and can be shared among the engine and
our services, there were a few major types that were still duplciated.
Resource was the biggest example -- and indeed, the apitype varirant
was missing the new Dependencies property -- but there were others,
like Manfiest, PluginInfo, etc.  These too had semi-random omissions.

This change merges all of these types into the apitype package.  This
not only cleans up the redundancy and missing properties, but will
"force the issue" with respect to keeping them in sync and properly
versioning the information in a backwards compatible way.

The resource/stack package still exists as a simple marshaling layer
to and from the engine's core data types.

Finally, I've made the controversial change to share the actual
Deployment data structure at the apitype layer also.  This will force
us to confront differences in that data structure similarly, and will
allow us to leverage the strong typing throughout to catch issues.
2018-02-28 12:44:55 -08:00
Justin Van Patten ac58f151b4
Change default of where stack is created (#971)
If currently logged in, `stack init` creates a managed stack. Otherwise, it creates a local
stack. This avoids the need to specify `--local` when not using the service.

As today, `--local` can be passed, which will create a local stack regardless of being logged
in or not.

A new flag, `--remote`, has been added, which can be passed to indicate a managed stack,
used to force an error if not logged into the service.
2018-02-26 11:00:16 -08:00
joeduffy 1acb0eb226 Use new package name for empty test 2018-02-24 10:39:18 -08:00
joeduffy 74563afdc8 Get the empty Python program working
This change gets enough of the Python SDK up and running that the
empty Python program will work.  Mostly just scaffolding, but the
basic structure is now in place.  The primary remaining work is to
wire up resource creation to the gRPC interfaces.

In summary:

* The basic structure is as follows:

    - Everything goes into sdk/python/.

    - sdk/python/cmd/pulumi-langhost-python is a Go language host
      that simply knows how to spawn Python processes to run out
      entrypoint in response to requests by the engine.

    - sdk/python/cmd/pulumi-langhost-python-exec is a little Python
      shim that is invoked by the language host to run Python programs,
      and is responsible for setting up the minimal goo before we can
      do so (RPC connections and the like).

    - sdk/python/lib/ contains a Python Pip package suitable for PyPi.

    - In there, we have two packages: the root pulumi package that
      contains all of the basic Pulumi programming model abstractions,
      and pulumi.runtime, which contains the implementation of
      resource registration, RPC interfacing with the engine, and so on.

* Add logic in our test framework to conditionalize on the language
  type and react accordingly.  This will allow us to skip Yarn for
  Python projects and eventually run Pip if there's a requirements.txt.

* Created the basic project structure, including all of the usual
  Make targets for installing into the proper places.

* Building also runs Pylint and we are clean.

There are a few other minor things in here:

* Add an "empty" test for both Node.js and Python.  These pass.

* Fix an existing bug in plugin shutdown logic.  At some point, we
  started waiting for stderr/stdout to flush before shutting down
  the plugin; but if certain failures happen "early" during the
  plugin launch process, these channels will never get initialized
  and so waiting for them deadlocks.

* Recently we seem to have added logic to delete test temp
  directories  if a failure happened during initialization of said
  temp directories.  This is unfortunate, because you often need to
  look at the temp directory to see what failed.  We already clean
  them up elsewhere after the full test completes successfully, so
  I don't think we need to be doing this, and I've removed it.

Still many loose ends (config, resources, etc), but it's a start!
2018-02-23 19:33:02 -08:00
Sean Gillespie b84320b45e
Code review feedback:
1. Various idiomatic Go and TypeScript fixes
    2. Add an integration test that end-to-end roundtrips dependency
    information for a simple Pulumi program
    3. Add an additional test assert that tests that dependency information
    comes from the language host as expected
2018-02-22 13:33:50 -08:00
Justin Van Patten ed9716f6ef
Create backups of all local stack checkpoint files (#949)
Backup copies of local stack checkpoints are now saved to the
user's home directory (`~/.pulumi/backups`) by default.

This enables users to recover after accidentally deleting their
local `.pulumi` directory (e.g. via `git clean`).

The behavior can be disabled by setting the
PULUMI_DISABLE_CHECKPOINT_BACKUPS environment variable, which
we use to disable backups when running all tests other than the
test for this functionality.
2018-02-20 21:05:57 -08:00
Joe Duffy 776a76dffd
Make some stack-related CLI improvements (#947)
This change includes a handful of stack-related CLI formatting
improvements that I've been noodling on in the background for a while,
based on things that tend to trip up demos and the inner loop workflow.

This includes:

* If `pulumi stack select` is run by itself, use an interactive
  CLI menu to let the user select an existing stack, or choose to
  create a new one.  This looks as follows

      $ pulumi stack select
      Please choose a stack, or choose to create a new one:
        abcdef
        babblabblabble
      > currentlyselected
        defcon
        <create a new stack>

  and is navigated in the usual way (key up, down, enter).

* If a stack name is passed that does not exist, prompt the user
  to ask whether s/he wants to create one on-demand.  This hooks
  interesting moments in time, like `pulumi stack select foo`,
  and cuts down on the need to run additional commands.

* If a current stack is required, but none is currently selected,
  then pop the same interactive menu shown above to select one.
  Depending on the command being run, we may or may not show the
  option to create a new stack (e.g., that doesn't make much sense
  when you're running `pulumi destroy`, but might when you're
  running `pulumi stack`).  This again lets you do with a single
  command what would have otherwise entailed an error with multiple
  commands to recover from it.

* If you run `pulumi stack init` without any additional arguments,
  we interactively prompt for the stack name.  Before, we would
  error and you'd then need to run `pulumi stack init <name>`.

* Colorize some things nicely; for example, now all prompts will
  by default become bright white.
2018-02-16 15:03:54 -08:00
Matt Ellis b8f3bb24aa Yarn link pulumi in history tests 2018-02-14 17:55:48 -08:00
Joe Duffy 902d646215
Rename package to project (#935)
This addresses pulumi/pulumi#446: what we used to call "package" is
now called "project".  This has gotten more confusing over time, now
that we're doing real package management.

Also fixes pulumi/pulumi#426, while in here.
2018-02-14 13:56:16 -08:00