Commit graph

1087 commits

Author SHA1 Message Date
joeduffy
2d109f736c Convert AWS IAM types and provider to new IDL model 2017-04-28 11:16:49 -07:00
joeduffy
19577d67f0 Don't emit imports for zero-resource cases 2017-04-28 11:05:34 -07:00
joeduffy
75a897c23f Map interface{} RPC projections correctly
A property whose type is `interface{}` in the IDL ought to be projected
as a "JSON-like" map, just like it is on the Coconut package side of things,
which means a `map[string]interface{}`.
2017-04-28 10:58:27 -07:00
joeduffy
72b4035f3a Add a script to regenerate the AWS package from IDL 2017-04-28 10:37:37 -07:00
joeduffy
954d594e94 Rename --recurse to --recursive
My muscle memory kicked in (grep, et al), and then I realized the
name wasn't quite right.  This rights a wrong.
2017-04-28 10:37:05 -07:00
joeduffy
af3949509a Implement CIDLC support for package imports
This change correctly implements package/module resolution in CIDLC.
For now, this only works for intra-package imports, which is sufficient
for now.  Eventually we will need to support this (see pulumi/coconut#138).
2017-04-28 10:31:18 -07:00
joeduffy
46227870e4 Implement a few CIDLC improvements
* Allow `interface{}` to mean "weakly typed property bag."

* Allow slices in IDL types.

* Permit the package base as an argument.
2017-04-27 15:40:51 -07:00
joeduffy
df01db5df7 Finish converting the AWS EC2 resource IDLs 2017-04-27 11:53:32 -07:00
joeduffy
dd032e0784 Make IsResource tolerant of types.Named types 2017-04-27 11:52:59 -07:00
joeduffy
70f6d88a5b Implement the basic ARN/Region IDL types 2017-04-27 11:29:51 -07:00
joeduffy
47ef3f673b Rename PreviewUpdate (again)
Unfortunately, this wasn't a great name.  The old one stunk, but the
new one was misleading at best.  The thing is, this isn't about performing
an update -- it's about NOT doing an update, depending on its return value.
Further, it's not just previewing the changes, it is actively making a
decision on what to do in response to them.  InspectUpdate seems to convey
this and I've unified the InspectUpdate and Update routines to take a
ChangeRequest, instead of UpdateRequest, to help imply the desired behavior.
2017-04-27 11:18:49 -07:00
joeduffy
617ac91c92 Convert the AWS EC2 Instance provider to the new IDL model 2017-04-27 11:07:16 -07:00
joeduffy
43bb3ec766 Reject non-pointer optional fields
This change rejects non-pointer optional fields in the IDL.  Although
there is no reason this couldn't work, technically speaking, it's almost
always certainly a mistake.  Better to issue an error about it; in the
future, we could consider making this a warning.
2017-04-27 11:03:13 -07:00
joeduffy
7b66ae2be5 Add the AWS EC2 VPC IDL
This change includes just the AWS EC2 VPC IDL, and not the corresponding
provider (which is not yet implemented in our system anyway).
2017-04-27 10:49:46 -07:00
joeduffy
d88773b773 Convert AWS EC2 SecurityGroup to the new IDL model 2017-04-27 10:42:35 -07:00
joeduffy
3f54c672be Fix/alter a few aspects of RPC code-generation
* Use --out-rpc, rather than --out-provider, since rpc/ is a peer to provider/.

* Use strongly typed tokens in more places.

* Append "rpc" to the generated RPC package names to avoid conflicts.

* Change the Check function to return []mapper.FieldError, rather than
  mapper.DecodeError, to make the common "no errors" case easier (and to eliminate
  boilerplate resulting in needing to conditionally construct a mapper.DecodeError).

* Rename the diffs argument to just diff, matching the existing convention.

* Automatically detect changes to "replaces" properties in the PreviewUpdate
  function.  This eliminates tons of boilerplate in the providers and handles the
  90% common case for resource recreation.  It's still possible to override the
  PreviewUpdate logic, of course, in case there is more sophisticated recreation
  logic necessary than just whether a property changed or not.

* Add some comments on some generated types.

* Generate property constants for the names as they will appear in weakly typed
  property bags.  Although the new RPC interfaces are almost entirely strongly
  typed, in the event that diffs must be inspected, this often devolves into using
  maps and so on.  It's much nicer to say `if diff.Changed(SecurityGroup_Description)`
  than `if diff.Changed("description")` (and catches more errors at compile-time).

* Fix resource ID generation logic to properly fetch the Underlying() type on
  named types (this would sometimes miss resources during property analysis, emitting
  for example `*VPC` instead of `*resource.ID`).
2017-04-27 10:36:22 -07:00
joeduffy
164d4db30a Implement CIDLC RPC code generation
This change implements the boilerplate RPC stub generation for CIDLC
resource providers.  This includes a lot of the marshaling goo required
to bridge between the gRPC plugin interfaces and the strongly typed
resource types and supporting marshalable structures.

This completes the major tasks of implementing CIDLC (pulumi/coconut#133),
and I have most of the AWS package running locally on it.  There are
undoubtedly bugs left to shake out, but no planned work items remain.
2017-04-27 07:33:00 -07:00
joeduffy
507a2609a7 Add an initial implementation of CIDLC
This is an initial implementation of the Coconut IDL Compiler (CIDLC).
This is described further in
https://github.com/pulumi/coconut/blob/master/docs/design/idl.md,
and the work is tracked by coconut/pulumi#133.

I've been kicking the tires with this locally enough to checkpoint the
current version.  There are quite a few loose ends not yet implemented,
most of them minor, with the exception of the RPC stub generation which
I need to flesh out more before committing.
2017-04-25 15:05:51 -07:00
joeduffy
8c58950639 Tolerate nils in output property marshaling 2017-04-25 14:04:22 -07:00
joeduffy
d3899981e0 Make AWS instance DNS/IP outputs optional 2017-04-25 14:03:42 -07:00
joeduffy
90b172aacf Fix a few typos 2017-04-24 10:04:18 -07:00
joeduffy
3f866e353f Merge branch 'master' of github.com:pulumi/coconut 2017-04-24 09:52:38 -07:00
joeduffy
7d3192637e Jot down design for resource provider IDL
As part of pulumi/coconut#133, we will be doing an IDL dialect of Go
plus a compiler, to support writing resource providers more easily.

This commit includes a design note for how it works.
2017-04-24 09:50:48 -07:00
Eric Rudder
f8405325db Fixed typo 2017-04-24 09:16:56 -07:00
joeduffy
4671e5f435 Take an initial cut at AWS API Gateway support in Mantle
There are still several loose ends, but this sketches out the
overall shape of the API Gateway usage in Mantle.
2017-04-21 16:47:31 -07:00
joeduffy
0827ca5b58 Implement creation outputs for AWS resources
This change implements the appropriate creation outputs for AWS
resource providers, both on the IDL side and in the providers themselves.
2017-04-21 16:14:59 -07:00
joeduffy
1edced2d4b Add the ability to convert structs to PropertyMaps 2017-04-21 15:27:32 -07:00
joeduffy
d6abea728c Add outputs to the Create provider's return
In order to support output properties (pulumi/coconut#90), we need to
modify the Create gRPC interface for resource providers slightly.  In
addition to returning the ID, we need to also return any properties
computed by the AWS provider itself.  For instance, this includes ARNs
and IDs of various kinds.  This change simply propagates the resources
but we don't actually support reading the outputs just yet.
2017-04-21 14:15:06 -07:00
joeduffy
a2b37d7dda Implement an aws.ARN type
This "strongly types" the aws.ARN type.  In reality, it is simply an
alias for a string at the moment (as this is what it boils down to on
the wire), but this at least gets us some amount of compile-time safety.
2017-04-21 14:03:06 -07:00
joeduffy
9b9fac4254 Make iam.Role's managed policy ARNs a string list 2017-04-21 13:27:34 -07:00
joeduffy
cb10ec7014 Mark lambda.Permission's source args as optional 2017-04-21 13:24:56 -07:00
joeduffy
6a6b82e2ab Add the AWS lambda.Permission resource IDL 2017-04-21 13:23:13 -07:00
joeduffy
689dd06949 Add AWS API Gateway resource IDL definitions
This change includes resource IDL definitions for all of AWS API Gateway's
corresponding CloudFormation resource types.  There are no actual provider
implementations yet.
2017-04-21 10:15:19 -07:00
joeduffy
25fb74803a Add a sample "Hello, World" for Mantle
This is a sample serverless function, written in Node.js, and exposed
over an HTTP API gateway endpoint.

It even works!  (For Kubernetes Fission; the AWS support is dependent
upon projecting the various API gateway resource providers...)
2017-04-20 18:46:21 -07:00
joeduffy
fdd441fd25 Implement the Kubernetes Fission HTTPTrigger provider 2017-04-20 18:40:05 -07:00
joeduffy
aa44b46608 Lower instanceof in CocoJS; implement IsInst in CocoIL 2017-04-20 17:38:15 -07:00
joeduffy
3f25aca7dd Add a http.API abstraction to Mantle
This introduces an http.API abstraction to Mantle and implements it
for Kubernetes Fission.  (The AWS implementation will come shortly,
but requires a fair bit of API Gateway elbow grease first.)

This lets you invoke a function in response to an API event:

    let func = new mantle.func.Function(
        (e, ctx, cb => { ... },
    );
    let api = new mantle.http.API("/hello", "GET", func);
2017-04-20 16:05:19 -07:00
joeduffy
0b6e262b46 Rename resource provider methods
This change renames two provider methods:

    * Read becomes Get.

    * UpdateImpact becomes PreviewUpdate.

These just read a whole lot nicer than the old names.
2017-04-20 14:09:00 -07:00
joeduffy
94e072c653 Add a TryLoadDynamicExpression IL opcode
This change introduces TryLoadDynamicExpression.  This is similar to
the existing LoadDynamicExpression opcode, except that it will return
null in response to a missing member (versus the default of raising
an exception).  This is to enable languages like JavaScript to encode
operations properly (which always yields undefined/nulls), while still
catering to languages like Python (which throw exceptions).
2017-04-19 16:49:59 -07:00
joeduffy
8eecc2c05b Flatten Fission metadata property
This change flattens the Fission metadata property on the Coconut
side so that it is nicer to consume.  Due to struct embedding in Go,
we need to perform translation at the serialization boundary anyway,
so the less-usable approach we had before didn't really buy us anything.
2017-04-19 16:05:33 -07:00
joeduffy
da73d81dd0 Implement the Fission function provider 2017-04-19 15:52:17 -07:00
joeduffy
47a9a6ee08 Implement Kubernetes functions
This change detects when the target scheduler is Kubernetes, and prefers
to schedule atop Fission functions.
2017-04-19 15:36:48 -07:00
joeduffy
cc6dd63556 Use inter-resource references for Fission resources
The Fission internal data structures reference one another by
name/URI.  Coconut needs the graph with dependencies, however, so
we prefer to model things using real object references in these
situations.  (This also makes it much nicer to program.)  This
changes to fit the Coconut model better; the provider will then
turn around and present names/URIs to the various APIs.
2017-04-19 15:33:33 -07:00
joeduffy
0977477f95 Improve an assertion message 2017-04-19 15:23:05 -07:00
joeduffy
cbd3692d3d Initialize the logging libraries 2017-04-19 15:05:18 -07:00
joeduffy
53e7bfbb86 Rearrange the way stderr/stdout is handled for plugins
The order of operations for stderr/stdout monitoring with plugins
managed to hide some important errors.  For example, if something
was written to stderr *before* the port was parsed from stdout, a
very possible scenario if the plugin fails before it has even
properly sarted, then we would silently drop the stderr on the floor
leaving behind no indication of what went wrong.  The new ordering
ensures that stderr is never ignored with some minor improvements
in the case that part of the port is parsed from stdout but it
ultimately ends in an error (e.g., if an EOF occurs prematurely).
2017-04-19 15:01:04 -07:00
joeduffy
f429bc6a0c Use github.com/pkg/errors for errors
This change moves us over to the github.com/pkg/errors package to
encourage the addition of more context associated with failures.
2017-04-19 14:46:50 -07:00
joeduffy
958d67d444 Move NewCheckResponse into coconut/pkg/resource package 2017-04-19 14:25:49 -07:00
joeduffy
366e236853 Implement the Fission provider scaffolding; and Environments 2017-04-19 14:23:01 -07:00
joeduffy
936d3f45e6 Fix another package name reference 2017-04-19 14:20:12 -07:00