Commit graph

799 commits

Author SHA1 Message Date
Matt Ellis b04732f76b Rename env folder to stacks 2017-10-17 17:44:53 -07:00
Pat Gavlin dacff3db48 Merge pull request #425 from pulumi/DrainStreamsPluginLoadFailure
Drain std{out,err} when a plugin fails to load.
2017-10-16 23:32:02 -07:00
pat@pulumi.com 9453f86c2e Implement dynamic resources.
A dynamic resource is a resource whose provider is implemented alongside
the resource itself. This provider may close over and use orther
resources in the implementation of its CRUD operations. The provider
itself must be stateless, as each CRUD operation for a particular
dynamic resource type may use an independent instance of the provider.
Changes to the definition of a resource's provider result in replacement
of the resource itself (rather than a simple update), as this allows the
old provider definition to delete the old resource and the new provider
definition to create an appropriate replacement.
2017-10-16 23:06:53 -07:00
Pat Gavlin 546612a354 Drain std{out,err} when a plugin fails to load.
If a plugin fails to load after we've set up the goroutines that copy
from its std{out,err} streams, then those goroutines can end up writing
to a closed event channel. This change ensures that we properly drain
those streams in this case.
2017-10-16 21:38:11 -07:00
Matt Ellis 8fda24a776 Write a .yarnrc file when running tests to enable mutex
In #411 we started to run tests in parallel again. To support that, we
added a .yarnrc file in the root of our repository to pass --mutex
network to all yarn invocations, because tests may run yarn commands
concurrently with one another and yarn is not safe to run
concurrently.

However, when we run the integration tests, we actually copy them into
a folder under `/tmp` and so yarn's logic to walk up the directory to
tree to find a `.yarnrc` will not see this `.yarnrc` and we're back
where we started.

Have the testing package explicitly write this file, which should
prevent this issue from happening in the future.
2017-10-16 16:08:50 -07:00
Matt Ellis 996ac8872d Merge pull request #420 from pulumi/rename-env-to-stack
Use `Stack` over `Environment` to describe a deployment target
2017-10-16 14:24:11 -07:00
pat@pulumi.com bdbb1b59d4 Ensure a plugin's std{out,err} streams are drained in Close().
Not doing so can cause panics, as the goroutines we use to copy these
streams can end up writing to a closed channel.
2017-10-16 13:44:37 -07:00
Matt Ellis 22c9e0471c Use Stack over Environment to describe a deployment target
Previously we used the word "Environment" as the term for a deployment
target, but since then we've started to use the term Stack. Adopt this
across the CLI.

From a user's point of view, there are a few changes:

1. The `env` verb has been renamed to `stack`
2. The `-e` and `--env` options to commands which operate on an
environment now take `-s` or `--stack` instead.
3. Becase of (2), the commands that used `-s` to display a summary now
only support passing the full option name (`--summary`).

On the local file system, we still store checkpoint data in the `env`
sub-folder under `.pulumi` (so we can reuse existing checkpoint files
that were written to the old folder)
2017-10-16 13:04:20 -07:00
joeduffy 301739c6b5 Add auto-parenting
This changes a few things about "components":

* Rename what was previously ExternalResource to CustomResource,
  and all of the related fields and parameters that this implies.
  This just seems like a much nicer and expected name for what
  these represent.  I realize I am stealing a name we had thought
  about using elsewhere, but this seems like an appropriate use.

* Introduce ComponentResource, to make initializing resources
  that merely aggregate other resources easier to do correctly.

* Add a withParent and parentScope concept to Resource, to make
  allocating children less error-prone.  Now there's no need to
  explicitly adopt children as they are allocated; instead, any
  children allocated as part of the withParent callback will
  auto-parent to the resource provided.  This is used by
  ComponentResource's initialization function to make initialization
  easier, including the distinction between inputs and outputs.
2017-10-15 04:38:26 -07:00
joeduffy fbfca58a3f Implement components
This change implements core support for "components" in the Pulumi
Fabric.  This work is described further in pulumi/pulumi#340, where
we are still discussing some of the finer points.

In a nutshell, resources no longer imply external providers.  It's
entirely possible to have a resource that logically represents
something but without having a physical manifestation that needs to
be tracked and managed by our typical CRUD operations.

For example, the aws/serverless/Function helper is one such type.
It aggregates Lambda-related resources and exposes a nice interface.
All of the Pulumi Cloud Framework resources are also examples.

To indicate that a resource does participate in the usual CRUD resource
provider, it simply derives from ExternalResource instead of Resource.

All resources now have the ability to adopt children.  This is purely
a metadata/tagging thing, and will help us roll up displays, provide
attribution to the developer, and even hide aspects of the resource
graph as appropriate (e.g., when they are implementation details).

Our use of this capability is ultra limited right now; in fact, the
only place we display children is in the CLI output.  For instance:

    + aws:serverless:Function: (create)
      [urn=urn:pulumi:demo::serverless::aws:serverless:Function::mylambda]
      => urn:pulumi:demo::serverless::aws:iam/role:Role::mylambda-iamrole
      => urn:pulumi:demo::serverless::aws:iam/rolePolicyAttachment:RolePolicyAttachment::mylambda-iampolicy-0
      => urn:pulumi:demo::serverless::aws:lambda/function:Function::mylambda

The bit indicating whether a resource is external or not is tracked
in the resulting checkpoint file, along with any of its children.
2017-10-14 18:30:59 -07:00
Pat Gavlin aaf46c12f4 Narrow destroy events as well. 2017-10-13 10:12:09 -07:00
pat@pulumi.com 107f667b87 Accept a send-only event channel in Deploy and Preview.
Just what it says on the tin.
2017-10-12 14:16:44 -07:00
Matt Ellis 2676e8bad1 Split apart EnvironmentProvider interface 2017-10-11 13:23:44 -07:00
Matt Ellis 6f4537010c Fix typo 2017-10-10 12:16:41 -07:00
Matt Ellis 377eb61e32 Always emit debug events into the stream 2017-10-09 18:27:05 -07:00
Matt Ellis 7587bcd7ec Have engine emit "events" instead of writing to streams
Previously, the engine would write to io.Writer's to display output.
When hosted in `pulumi` these writers were tied to os.Stdout and
os.Stderr, but other applications hosting the engine could send them
other places (e.g. a log to be sent to an another application later).

While much better than just using the ambient streams, this was still
not the best. It would be ideal if the engine could just emit strongly
typed events and whatever is hosting the engine could care about
displaying them.

As a first step down that road, we move to a model where operations on
the engine now take a `chan engine.Event` and during the course of the
operation, events are written to this channel. It is the
responsibility of the caller of the method to read from the channel
until it is closed (singifying that the operation is complete).

The events we do emit are still intermingle presentation with data,
which is unfortunate, but can be improved over time. Most of the
events today are just colorized in the client and printed to stdout or
stderr without much thought.
2017-10-09 18:24:56 -07:00
Matt Ellis 5fd0ada303 Remove Checkpoint return value from GetEnvironment 2017-10-09 18:21:55 -07:00
Matt Ellis e7e4e75af3 Don't examine the Checkpoint in the CLI
The checkpoint is an implementation detail of the storage of an
environment. Instead of interacting with it, make sure that all the
data we need from it either hangs off the Snapshot or Target
objects (which you can get from a Checkpoint) and then start consuming
that data.
2017-10-09 18:21:55 -07:00
Matt Ellis 6e8185884e Remove GetEnvironmentInfo from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis 7e4a1f515b Remove GetEnvironments from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis bd92f8eaed Remove RemoveEnv from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis 7fdbdb2152 Remove InitEnv from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis 76663d30fa Remove SetConfig from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis 02a33a4384 Remove DeleteConfig from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis 242eb929fb Remove GetConfiguration from Engine 2017-10-09 18:21:55 -07:00
Matt Ellis acd35b9916 Remove Checkpoint from planContext
Nothing actually consumed the Checkpoint property of the planContext,
so just remove it.
2017-10-09 18:21:55 -07:00
Matt Ellis 6bab1dbad4 Pass $(YARNFLAGS) to all yarn invocations
This let's you set things like YARNFLAGS==--offline which is helpful
when you are on an airplane. Yarn can still pick up stuff that you had
pulled down recently from its local cache
2017-10-09 18:21:55 -07:00
joeduffy 7e30dde8f4 Update plan test to new interface 2017-10-04 08:30:50 -04:00
joeduffy b7576b9b14 Add a notion of stable properties
This change adds the capability for a resource provider to indicate
that, where an action carried out in response to a diff, a certain set
of properties would be "stable"; that is to say, they are guaranteed
not to change.  As a result, properties may be resolved to their final
values during previewing, avoiding erroneous cascading impacts.

This avoids the ever-annoying situation I keep running into when demoing:
when adding or removing an ingress rule to a security group, we ripple
the impact through the instance, and claim it must be replaced, because
that instance depends on the security group via its name.  Well, the name
is a great example of a stable property, in that it will never change, and
so this is truly unfortunate and always adds uncertainty into the demos.
Particularly since the actual update doesn't need to perform replacements.

This resolves pulumi/pulumi#330.
2017-10-04 08:22:21 -04:00
pat@pulumi.com 3121284117 Remove incremental checkpointing.
This is currently broken in the case of resource replacements, in which
case we may have multiple resources with the same URN.
2017-10-03 16:21:53 -07:00
pat@pulumi.com f78aa02a54 Report SaveEnvironment errors.
Furthermore, only save the environment in `deployActions.Run`. Fixes #388.
2017-10-03 15:18:08 -07:00
pat@pulumi.com 15be0a8b83 Simplify deploy.StepActions.
Now that `deploy.Step.Pre` is no more, we can simplify the `StepActions`
interface down to a single method, `Run`, which performs all actions
associated with the step. This feeds into #388.
2017-10-03 11:10:06 -07:00
pat@pulumi.com 252fd8e6bb Remove deploy.Step.Pre.
As per @joeduffy, this is an artifact of the prior runtime model.
2017-10-03 10:03:05 -07:00
Matt Ellis daa083636c Rename envCmdInfo to planContext
This name is still not great, but the old name was really, really bad.
2017-10-02 18:03:07 -07:00
Pat Gavlin 5f203e7f15 Merge pull request #384 from pulumi/IncrementalCheckpoint
Incrementally update the checkpoint file during `pulumi update`.
2017-10-02 17:25:24 -07:00
pat@pulumi.com 967414117a PR feedback 2017-10-02 17:18:16 -07:00
Matt Ellis 93ab134bbb Have the CLI keep track of the current environment
Previously, the engine was concered with maintaing information about
the currently active environment. Now, the CLI is in charge of
this. As part of this change, the engine can now assume that every
environment has a non empty name (and I've added asserts on the
entrypoints of the engine API to ensure that any consumer of the
engine passes a non empty environment name)
2017-10-02 16:57:41 -07:00
Matt Ellis ae8f2a84c2 Merge pull request #385 from pulumi/pulumi-service-interface
More pulumi engine refactoring
2017-10-02 16:16:55 -07:00
pat@pulumi.com 11114bd243 Incrementally update the checkpoint file during pulumi update.
Simply write the current snapshot after each step. We should probably be
more clever about this in the future (i.e. write only the changes rather
than the entire file).
2017-10-02 15:53:13 -07:00
Matt Ellis 2a16a198f6 Move environment info printing into the CLI
The engine now provides a strongly typed view of an environment and
the CLI decides how to display it
2017-10-02 15:50:08 -07:00
Matt Ellis a704750714 Remove Workspace dependency on diag.Sink
It was only being used for two cases where we would issue warnings for
cases where the file system casing did not match expected casing. I
think it's probably better if we don't try to be smart here and just
treat these cases the same as if the file had not existed. Removing
the dependncy on diag also makes it a little clearer that this stuff
should be pulled out from the engine.
2017-10-02 15:25:22 -07:00
Matt Ellis d29f6fc4e5 Use tokens.QName instead of string as the type for environment
Internally, the engine deals with tokens.QName and not raw
strings. Push that up to the API boundary
2017-10-02 15:14:55 -07:00
Pat Gavlin ff2a3fa242 Replace Plan.Apply with planResult.Walk. (#383)
`deploy.Plan.Apply` was only consumed by the engine, and seemed to be in
the wrong place given the API exported by the rest of `Plan` (i.e.
`Plan.Start` + `PlanIterator`). Furthermore, we were missing a reasonable
opportunity to share code between `update` and `preview`, both of which
need to walk the plan. These changes move the plan walk into `package engine`
as `planResult.Walk` and replace the `Progress` interface with a new interface,
`StepActions`, which subsumes the functionality of the former and adds support
for implementation-specific step execution. `planResult.Walk` is then
consumed by both `Engine.Deploy` and `Engine.PrintPlan`.
2017-10-02 14:26:51 -07:00
Matt Ellis aa6c6d6617 Move some configuration logic into the CLI
The CLI is now responsible for actually displaying information and the
engine is only concerned with getting the configuration. As part of
this change, I've removed the display a single configuration value API
from the engine. It can now be done in terms of getting all the config
for an environment and selecting the value the user is interested in
2017-10-02 13:35:39 -07:00
Matt Ellis 7900e2edb1 Move environment printing back into the CLI
Previously the engine was concerned with displaying information about
the environment. Now the engine returns an environment info object
which the CLI uses to display environment information.
2017-10-02 13:34:33 -07:00
Matt Ellis c022db9285 Require environment name on deployment APIs
Deployments always need to be done in the context of some environment,
so let's make the argument explicit instead of it coming in the
property bag
2017-10-02 11:14:27 -07:00
joeduffy ac2dbc80fa Add an Invoke RPC method on ResourceProvider
This change enables us to make progress on exposing data sources
(see pulumi/pulumi-terraform#29).  The idea is to have an Invoke
function that simply takes a function token and arguments, performs
the function lookup and invocation, and then returns a return value.
2017-09-30 14:53:27 -04:00
pat@pulumi.com 28d02e232b Fix #372.
Print "modified" rather than "modifyd". This introduces a new method,
`resource.StepOp.PastTense()`, which returns the past tense description
of the operation.
2017-09-28 09:28:36 -07:00
Cyrus Najmabadi bdd819379e Extract out test helper functionality for use from pulumi-cloud. 2017-09-25 14:14:09 -07:00
Joe Duffy b4646db39b Merge branch 'master' into RenameVerbs 2017-09-23 11:31:29 -07:00