Commit graph

1514 commits

Author SHA1 Message Date
Britton Forsyth 01003ad48b Implemented highlighted edits 2017-06-13 11:01:23 -07:00
Joe Duffy bfe7db03c9 Merge pull request #236 from pulumi/90-plan_revamp
Implement output properties
2017-06-13 07:27:16 -07:00
joeduffy 01bbc23144 Only mark immediate outputs as outputs
The primary purposes of this change is to mark only immediate ouptuts
on a resource object as "output" and categories the rest as computed.

It also contains a few minor things:

    * Rebase atop the latest in master.

    * Always marshal unknows as their default value.

    * Permit computed as the existing ID property, in addition to null.

    * Tidy up some asserts.
2017-06-13 07:10:13 -07:00
joeduffy 0d836ae0bd Recover from deployment failures 2017-06-13 07:10:13 -07:00
joeduffy 2eb78e1036 Label replacements as simply "replace" 2017-06-13 07:10:13 -07:00
joeduffy 75a2f14d10 Propagate IDs/outs differently based on step kind
This change updates the ID/output propagation logic to properly handle
the case of replacements, in addition to accurately conveying the fact
that an update may change the values of output properties (but not the ID).

Also fixes a formatting issue with the replacement diffing displays.
2017-06-13 07:10:13 -07:00
joeduffy 25c52a04c5 Tidy up some loose ends
This removes some loose ends and reimplements `lumi pack eval`.
2017-06-13 07:10:13 -07:00
joeduffy dedeab3c5e Update test util to use new packages
Also add a license, fix some long lines, and make it gofmt clean.
2017-06-13 07:10:13 -07:00
joeduffy dd9e6b35f4 Introduce an OpSame planning step
This change introduces an OpSame planning step.  The reason we need
this is so that we can apply the necessary output properties, including
the ID, even as we are simply walking the plan (i.e., when we aren't
actually performing a deployment).  This ensures that the object state
evolves as required to let reads of output properties propagate in the
ways necessary to reproduce past executions of the program.
2017-06-13 07:10:13 -07:00
joeduffy 9d73c54994 Run post-construction hooks before freezing
We need to run the post-construction hook *before* freezing an object's
readonly properties, since the hook will actually mutate the object in
the case of a deployment (it stores the output properties).  In a sense,
this hook simply becomes an extension of the object's constructor.
2017-06-13 07:10:13 -07:00
joeduffy d1414af321 Fix a few minor things; clean stuff up
* Assert new things in new places.

* Log more interesting tidbits during evaluation.

* Invoke the OnStart hook before triggering initializers.

* Tolerate nil prev snapshots during deletion calculation.

* Handle and serialize missing resource IDs as output props.

* Return "done" flag from Rendezvous.Meet.
2017-06-13 07:10:13 -07:00
joeduffy d277dd5800 More progress on pulumi/lumi#90
This change refactors a number of aspects of the CLI's treatment of
steps, in line with the new scheme, and a number of other miscellaneous
and minor fixes.  It also regenerates all RPC code impacted by recent renames.
2017-06-13 07:10:13 -07:00
joeduffy d044720045 Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.

The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.

The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine.  It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.

There are two other sources, however.  First, a nullSource, which simply
refuses to create new objects.  This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment.  Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.

Boatloads of code is now changed and updated in the various CLI commands.

This further chugs along towards pulumi/lumi#90.  The end is in sight.
2017-06-13 07:10:13 -07:00
joeduffy 6b2408e086 Rewrite plans and deployments
This change guts the deployment planning and execution process, a
necessary component of pulumi/lumi#90.

The major effect of this change is that resources are actually
connected to the live objects, instead of being snapshots taken at
inopportune moments in time.
2017-06-13 07:10:13 -07:00
joeduffy c53ddeb678 Overhaul resources, planning, and environments
This change, part of pulumi/lumi#90, overhauls quite a bit of the
core resource, planning, environments, and related areas.

The biggest amount of movement comes from the splitting of pkg/resource
into multiple sub-packages.  This results in:

- pkg/resource: just the core resource data structures.

- pkg/resource/deployment: all planning and deployment logic.

- pkg/resource/environment: all environment, configuration, and
      serialized checkpoint structures and logic.

- pkg/resource/plugin: all dynamically loaded analyzer and
      provider logic, including the actual loading and RPC mechanisms.

This also splits the resource abstraction up.  We now have:

- resource.Resource: a shared interface.

- resource.Object: a resource that is connected to a live object
      that will periodically observe mutations due to ongoing
      evaluation of computations.  Snapshots of its state may be
      taken; however, this is purely a "pre-planning" abstraction.

- resource.State: a snapshot of a resource's state that is frozen.
      In other words, it is no longer connected to a live object.
      This is what will store provider outputs (ID and properties),
      and is what may be serialized into a deployment record.

The branch is in a half-baked state as of this change; more changes
are to come...
2017-06-13 07:10:13 -07:00
Luke Hoban 29fcde459b Add demo script and raw serverless example
Adds an initial cut at a demo script along with
a raw version of the serverless example that
is a better stepping stone between the low-level
AWS infrastructure providers and the high-level
`aws.serverless` APIs.
2017-06-12 15:20:37 -07:00
Luke Hoban 2914505a08 Expose the HTTP URL as an APIGateway Stage output property
Adds two output properties on APIGateway Stage resources.
* `url` is the full URL to the root of the deployed stage.
* `executionARN` is the arn needed to pass to Lambda to
give the stage permission to invoke a Lambda handler.
2017-06-12 10:40:41 -07:00
Luke Hoban 9bd441be05 Support for nested lambdas and node_modules
LumiJS lambdas can now be serialized when they include calls to other LumiJS lambdas.  The chain of lambda dependencies is jointly serialized into the target Lambda.

Also, LumiJS lambdas now include `node_modules` automatically in the AWS Lambda, ensuring the the runtime execution environment more closely matches the deployment time environment.

An early version of the gh-cicd example supporting #134 is added which uses these capabilities, currently including a mocked GitHub resource provider.
2017-06-12 10:15:20 -07:00
joeduffy 19febfcd9a Use a typedef for serverless function handler 2017-06-12 08:38:11 -07:00
joeduffy 97468ef38d Add an invoke.sh script for easier serverless demos 2017-06-10 15:59:53 -07:00
joeduffy 2b7b8c6160 Increase the default AWS timeout
We just hit a CI failure due to a timeout waiting for a lambda's
permissions to become available.  The AWS documents say "it may take
a few seconds", which is remarkably unhelpful.  Our current default
wait time is 30 seconds.  I am bumping it to 1 minute.

I also filed pulumi/lumi#233 for future consideration, since I would
like to think we can be more principled in our approach here...
2017-06-10 12:45:36 -07:00
joeduffy 7fb9a977db Fix a typo: "intance" should be "instance" 2017-06-10 12:15:03 -07:00
Luke Hoban 9bb868191f Add support for template literals in LumiJS
Support for untagged template literals.

Also unblocks a couple of cases where dynamic was not
propogated through the binder correctly.

Fixes #102.
2017-06-09 18:46:09 -07:00
Britton Forsyth 69e4834f63 Merge branch 'master' into gometalinter 2017-06-09 14:34:51 -07:00
Britton Forsyth 8c8f68d4ae Added specified changes 2017-06-09 12:51:31 -07:00
Luke Hoban 07ac77b903 Merge pull request #229 from pulumi/freevars
Improved lambda environment serialization
2017-06-09 11:35:53 -07:00
Luke Hoban 2870e8a0b1 Merge branch 'gometalinter' of https://github.com/bforsyth927/lumi into bforsyth927-gometalinter 2017-06-09 10:30:50 -07:00
Luke Hoban e87d21cb80 Store module object on Functions
We now store the module object instead of the
symbol on function stubs.
2017-06-09 10:23:07 -07:00
Luke Hoban 7171b58459 Address PR feedback on #229 2017-06-09 10:15:03 -07:00
Britton Forsyth 13dbcdbafc Finalized tslint edits and deletes 2017-06-09 08:54:05 -07:00
Luke Hoban 705c0edbfc Fix lumijs tests
Update baselines for Lumijs tests after change to
emit `TryLoadDynamic` for module-scoped
variable references.
2017-06-08 22:22:55 -07:00
Luke Hoban d77c51ff7f Allow runtime lambda to reference globals.
For lambdas which will execute at runtime,
we want to allow them to reference Node.js
global variables, like `console`.

This change makes Lumijs generated IL
incrementally more dynamic by preferring to
generate `TryLoadDynamic` over `LoadLocation`
for references to global variables (except for
references to imports).

Also introduces `console.log` in LumiJS, though
it is not yet attached to a Lumi global environment.

Fixes #174.
2017-06-08 22:06:41 -07:00
Britton Forsyth 11c74f12d9 Fixed tslint issues 2017-06-08 16:40:12 -07:00
Luke Hoban e838c6ff2d Allow lambdas to capture reference to module scope variables
The scope chain currently does not include module-scope
vairables, which are instead stored on a module object.  For
now, we are capturing this module object along with the
scope chain as part of a Lambda object so that we can use
it when evaluating variable references within a lambda
expression.

Fixes #175.
2017-06-08 15:56:50 -07:00
Luke Hoban ae9730bad3 Only capture free variables in lambda environment
Introduces a free variable AST visitor, and uses this to limit
the environment exposed by the `serizlizeClosure` intrinsic
to only those variables that are referenced by the lambda body.

Fixes #177.
2017-06-08 11:55:24 -07:00
Britton Forsyth 3066fcda78 Implemented suggested edits 2017-06-08 11:44:16 -07:00
Britton Forsyth 7457cadf58 Fixed various additional linting issues 2017-06-08 10:21:17 -07:00
joeduffy 2ab2b09474 Introduce object resources
This change slightly refactors the way resources are created and
implemented.  We now have two implementations of the Resource interface:

* `resource` (in resource_value.go), which is a snapshot of a resource's
  state.  All values are resolved and there is no live reference to any
  heap state or objects.  This will be used when serializing and/or
  deserializing snapshots of deployments.

* `objectResource` (in resource_object.go), which is an implementation
  of the Resource interface that wraps an underlying, live runtime object.
  This currently introduces no functional difference, as fetching Inputs()
  amounts to taking a snapshot of the full state.  But this at least
  gives us a leg to stand on in making sure that output properties are
  read at the right times during evaluation.

This is a fundamental part of pulumi/lumi#90.
2017-06-08 09:26:06 -07:00
joeduffy 027fe0766c Rename computed/output's eventual property to element
This rename now ensures the name mirrors that in the type/symbol layer.
2017-06-08 06:48:23 -07:00
joeduffy dce2fae4c2 Track implicated objects
This change begins to track objects that are implicated in the
creation of computed values.  This ultimately translates into the
resource URNs which are used during dependency analysis and
serialization.  This is part of pulumi/lumi#90.
2017-06-08 06:46:28 -07:00
Luke Hoban 771a30c688 Save build artifacts aftifacts for Go builds
In the places we run `go build`, we should use
`go build -i` to save the `.a` files generated
during the build.  This ensures the artifacts
are availble for other Go tools (linters, IDEs), and
should also improve build speeds.
2017-06-07 17:03:07 -07:00
Luke Hoban 96c25a9614 Generate valid Permission names for aws.serverless.API
The previous checkin exposed some validation
errors that had previously been surpressed,
including an error validating the Permission
statementId's generated by aws.serverless.API.
2017-06-07 16:34:17 -07:00
Luke Hoban 73e4be9f5e Some cleanup on AWS examples 2017-06-07 16:16:55 -07:00
Luke Hoban 0f8bd74a82 Address PR feedback on #224
Adds Check implementation for aws.lambda.Permission
resources using AWS-defined regexps.

Fixes bug in lumidl Check wrapper which was dropping
reported check failures (an regen all rpc files).

Add calls to Get into the AWS provider test framework.
2017-06-07 15:13:56 -07:00
Britton Forsyth 00ade9f28a Fixed some gometalinter issues 2017-06-07 10:52:03 -07:00
Luke Hoban 977e56e03e Add aws.lambda.Permission resource (#224)
Adds a Permission resource to enable lambda Functions
to be invoked by event sources.

Per #223, we are continuing to discuss whether these
should really be a seperate resource or just an inline
component of a Function resource.  However, until we
support cycle-breaking, we'll need them to be a separate
resource type.

Progress on #222.
2017-06-06 18:42:00 -07:00
joeduffy fd719d64cd Fix pulumi/lumi#198
This change fixes the serialization of resource properties during
deployment checkpoints.  We erroneously serialized empty arrays and
empty maps as though they were nil; instead, we want to keep them
serialized as non-nil empty collections, since the presence of a
value might be semantically meaningful.  (We still skip nils.)

Also added some test cases.
2017-06-06 16:42:14 -07:00
joeduffy f33b20e6cf Dereference some names; add some missing licenses 2017-06-06 15:19:32 -07:00
joeduffy c7dc3036d7 Finish scrubbing TODOs
This is a final pass over our TODOs, and closes pulumi/lumi#212.
2017-06-06 06:05:35 -07:00
joeduffy ec2b964daa Do an initial pass over TODOs
This scrubs about 80% of our TODOs, as part of pulumi/lumi#212.
The remaining 20% will come shortly.
2017-06-05 18:11:51 -07:00