Commit graph

910 commits

Author SHA1 Message Date
joeduffy 7e68e47e9d Implement NonNullExpressions in CocoJS
This is there for static typechecking, and so we can safely erase it.
2017-03-09 16:02:54 +00:00
joeduffy 783f9534c8 Add the ability to specify and env config during eval
This adds the --config-env flag which can be used to apply configuration
before performing evaluation of a package.
2017-03-09 15:52:50 +00:00
joeduffy cbf5407a53 Print results only if non-nil, during eval 2017-03-09 15:45:24 +00:00
joeduffy bfee271087 Rename the coco nut command to coco pack 2017-03-09 15:43:28 +00:00
joeduffy 9f524e4c8c Organize all package management commands
This change organizes all package management commands underneath
the top-level subcommand `nut`; so, for example:

    $ nut get ...
    $ nut eval ...
    and so on
2017-03-08 11:41:13 +00:00
joeduffy 3b3b56a836 Properly reap child processes
This change reaps child plugin processes before exiting.  It also hardens
some of the exit paths to avoid os.Exiting from the middle of a callstack.
2017-03-07 13:47:42 +00:00
joeduffy d94f9d4768 Implement a very basic env config command
This change implements a very basic `coco env config` command, that
lets you read, set, or unset configuration values for an environment.

For a single environment, these four usage styles are supported:

    # query all values in a given environment <env>:
    $ coco env config <env>

    # query a single value with key <key> in a given environment <env>:
    $ coco env config <env> <key>

    # set a single value with key <key> and value <value> in <env>:
    $ coco env config <env> <key> <value>

    # unset a single value with key <key> in the environment <env>:
    $ coco env config <env> <key> --unset

This is a vast subset of pulumi/coconut#113.
2017-03-06 15:07:24 +00:00
joeduffy 86dc13ed5b More term rotations
This changes a few naming things:

* Rename "husk" to "environment" (`coco env` for short).

* Rename NutPack/NutIL to CocoPack/CocoIL.

* Rename the primary Nut.yaml/json project file to Coconut.yaml/json.

* Rename the compiled Nutpack.yaml/json file to Cocopack.yaml/json.

* Rename the package asset directory from nutpack/ to .coconut/.
2017-03-06 14:32:39 +00:00
joeduffy 5318d5af57 Merge branch 'master' of github.com:pulumi/coconut 2017-03-06 14:20:34 +00:00
joeduffy 800f3dd388 Eliminate superfluous copy of ec2instance 2017-03-06 13:04:25 +00:00
joeduffy 9044047b84 Fix a go vet failure 2017-03-06 13:02:48 +00:00
joeduffy 7cb9ce2663 Implement some AWS provider checking
This change refactors the existing property verification logic for
the AWS provider to use the new checking capabilities.  Beyond just
checking for required properties, there isn't much here yet.  There
is a single check for security group description length that goes
beyond this, mostly for illustration purposes.

This is part of pulumi/coconut#115, although there is clearly more
to do here for something sufficiently snazzy and demoable.
2017-03-03 12:13:19 -08:00
joeduffy 6194a59798 Add a pre-pass to validate resources before creating/updating
This change adds a new Check RPC method on the provider interface,
permitting resource providers to perform arbitrary verification on
the values of properties.  This is useful for validating things
that might be difficult to express in the type system, and it runs
before *any* modifications are run (so failures can be caight early
before it's too late).  My favorite motivating example is verifying
that an AWS EC2 instance's AMI is available within the target region.

This resolves pulumi/coconut#107, although we aren't using this
in any resource providers just yet.  I'll add a work item now for that...
2017-03-02 18:15:38 -08:00
joeduffy adf852dd84 Fix an off by one (duhhh) 2017-03-02 17:15:13 -08:00
joeduffy 076d689a05 Rename Monikers to URNs
This change is mostly just a rename of Moniker to URN.  It does also
prefix resource URNs to have a standard URN namespace; in other words,
"urn🥥<name>", where <name> is the same as the prior Moniker.

This is a minor step that helps to prepare us for pulumi/coconut#109.
2017-03-02 17:10:10 -08:00
joeduffy 2ce75cb946 Make security group changes imply replacement 2017-03-02 16:16:18 -08:00
joeduffy 966969945b Add a resource.NewUniqueHex API (and use it)
This change adds a new resource.NewUniqueHex API, that simply generates
a unique hex string with the given prefix, with a specific count of
random bytes, and optionally capped to a maximum length.

This is used in the AWS SecurityGroup resource provider to avoid name
collisions, which is especially important during replacements (otherwise
we cannot possibly create a new instance before deleting the old one).

This resolves pulumi/coconut#108.
2017-03-02 16:02:41 -08:00
joeduffy 341c30f0c8 Issue deploy errors in the after callback
This just orders the output more nicely; previously, "step #n failed"
would come *before* the error detailing the reason.  This was a bit
confusing.  This change reorders them so the error reads more naturally.
2017-03-02 15:46:14 -08:00
joeduffy 523c669a03 Track which updates triggered a replacement
This change tracks which updates triggered a replacement.  This enables
better output and diagnostics.  For example, we now colorize those
properties differently in the output.  This makes it easier to diagnose
why an unexpected resource might be getting deleted and recreated.
2017-03-02 15:24:39 -08:00
joeduffy f0d9b12a3c Don't emit logical step resources while checkpointing 2017-03-02 13:14:57 -08:00
joeduffy c633d0ceb0 Add "still waiting" messages to retries 2017-03-02 13:12:40 -08:00
joeduffy e3715ef836 Add some handy aliases for deploy and init 2017-03-02 11:50:29 -08:00
joeduffy da5e737e08 Update EC2 resources to new Update model 2017-03-02 10:02:05 -08:00
joeduffy bd613a33e6 Make replacement first class
This change, part of pulumi/coconut#105, rearranges support for
resource replacement.  The old model didn't properly account for
the cascading updates and possible replacement of dependencies.

Namely, we need to model a replacement as a creation followed by
a deletion, inserted into the overall DAG correctly so that any
resources that must be updated are updated after the creation but
prior to the deletion.  This is done by inserting *three* nodes
into the graph per replacement: a physical creation step, a
physical deletion step, and a logical replacement step.  The logical
step simply makes it nicer in the output (the plan output shows
a single "replacement" rather than the fine-grained outputs, unless
they are requested with --show-replace-steps).  It also makes it
easier to fold all of the edges into a single linchpin node.

As part of this, the update step no longer gets to choose whether
to recreate the resource.  Instead, the engine takes care of
orchestrating the replacement through actual create and delete calls.
2017-03-02 09:52:08 -08:00
joeduffy 8698e5abeb Implement replacement for EC2 instances 2017-03-01 13:42:10 -08:00
joeduffy df3c0dcb7d Display and colorize replacements distinctly 2017-03-01 13:34:29 -08:00
joeduffy f93e093ab3 Unify some CLI error reporting
This unifies some of the CLI error reporting logic.  It's still
not perfect, but this tidies up some minor issues that were starting
to annoy me (e.g., inconsistencies in message formatting, message
colorization, and exit code handling).
2017-03-01 10:09:27 -08:00
joeduffy 49f5f3debc Add a distinct husk rm command
This changes the workflow for destroying a husk slightly.  Rather than
`coco husk destroy` actually removing the husk and its associated config
information, `coco husk destroy` just destroys the resources.  Then,
afterwards, to permanently remove the husk, you use `coco husk rm`.

As usual with `rm`-style commands, it refues to remove the husk if there
are any resources still associated with it; however, `--force` overrides
this default.
2017-03-01 09:57:14 -08:00
joeduffy fe0bb4a265 Support replacement IDs
This change introduces a new RPC function to the provider interface;
in pseudo-code:

    UpdateImpact(id ID, t Type, olds PropertyMap, news PropertyMap)
        (bool, PropertyMap, error)

Essentially, during the planning phase, we will consult each provider
about the nature of a proposed update.  This update includes a set of
old properties and the new ones and, if the resource provider will need
to replace the property as a result of the update, it will return true;
in general, the PropertyMap will eventually contain a list of all
properties that will be modified as a result of the operation (see below).

The planning phase reacts to this by propagating the change to dependent
resources, so that they know that the ID will change (and so that they
can recalculate their own state accordingly, possibly leading to a ripple
effect).  This ensures the overall DAG / schedule is ordered correctly.

This change is most of pulumi/coconut#105.  The only missing piece
is to generalize replacing the "ID" property with replacing arbitrary
properties; there are hooks in here for this, but until pulumi/coconut#90
is addressed, it doesn't make sense to make much progress on this.
2017-03-01 09:08:53 -08:00
joeduffy a4e806a07c Remember old moniker to ID mappings
For cerain update shapes, we will need to recover an ID of an already-deleted,
or soon-to-be-deleted resource; in those cases, we have a moniker but want to
serialize an ID.  This change implements support for remembering/recovering them.
2017-02-28 17:03:33 -08:00
joeduffy 7f53727575 Require the full --yes for destroys 2017-02-28 16:44:46 -08:00
joeduffy 632bb357da Remove superfluous indentation 2017-02-28 16:30:20 -08:00
joeduffy 954fd9ae78 Use real configuration in ec2instance example
This change eliminates the hard-coded region from the ec2instance
example, and instead uses the new `aws.config.region` configuration
variable.  This makes the code more amenable to multi-instancing.
2017-02-28 16:14:18 -08:00
joeduffy cf2788a254 Allow restarting from partial failures
This change fixes a couple issues that prevented restarting a
deployment after partial failure; this was due to the fact that
unchanged resources didn't propagate IDs from old to new.  This
is remedied by making unchanged a map from new to old, and making
ID propagation the first thing plan application does.
2017-02-28 16:09:56 -08:00
joeduffy 6a2edc9159 Ensure configuration round-trips in Huskfiles 2017-02-28 15:43:46 -08:00
joeduffy c77329129a Print more details when an unhandled exception occurs 2017-02-28 13:15:28 -08:00
joeduffy a1a8812910 Add a requireRegion helper function
This change adds a requireRegion helper function to the AWS library,
enabling easy fetching of the current region (and/or throwing if the
region hasn't been properly configured).
2017-02-28 12:37:37 -08:00
joeduffy 300f87137c Improve verify; verify packages before install
This change improves the verify command by unifying its package
discovery logic with compile.  All libraries are also now verified
before installing, just to catch silly mistakes (compiler bugs, etc).

This also fixes a verification error in the AWS library due to
pulumi/coconut#104, the inability to use `!` on "anything".
2017-02-28 12:31:50 -08:00
joeduffy b54d343889 Treat Never as dynamic
The TypeScript compiler will often transform Anys into Nevers when it
thinks control flow cannot reach a certain point.  This isn't handled
gracefully at the moment.  This change just erases it back to Any.
2017-02-28 12:08:50 -08:00
joeduffy 7593dd3ce9 Permit dots in names
This is sometimes used for "internal" functionality; and, furthermore,
NPM-style modules can legally contain dots.
2017-02-28 12:07:18 -08:00
joeduffy 36d9251400 Export lib.es5 and lib.es6 modules
This ensures that TypeScript library references to ES5 and ES6-specific
things resolve to the correct CocoJS runtime library types.
2017-02-28 12:05:45 -08:00
joeduffy 6460ccaa83 Disable the ECMAScript runtime layer
For now, we will disable the CocoJS library's ECMAScript runtime
layer, because it's causing some troubles.  The details -- and
reenabling it -- are tracked in pulumi/coconut#103.
2017-02-28 11:38:19 -08:00
joeduffy 923c3150db Fix the cocojs library
* for ..of isn't yet supported yet (see pulumi/coconut#88); in its
  absence, use a regular for loop so that this library can compile.

* List coconut as a dependency.
2017-02-28 11:32:24 -08:00
joeduffy 679a4bf479 Export a first class Region type 2017-02-28 11:12:34 -08:00
joeduffy 1c43abffec Fix some go vet issues 2017-02-28 11:02:33 -08:00
joeduffy 51fc9b1845 Fix a test break 2017-02-28 10:38:29 -08:00
joeduffy ce7f8d130e Change the error prefix from MU to COCO 2017-02-28 10:36:21 -08:00
joeduffy 7f0a97a4e3 Print configuration variables; etc.
This change does a few things:

* First and foremost, it tracks configuration variables that are
  initialized, and optionally prints them out as part of the
  prelude/header (based on --show-config), both in a dry-run (plan)
  and in an actual deployment (apply).

* It tidies up some of the colorization and messages, and includes
  nice banners like "Deploying changes:", etc.

* Fix an assertion.

* Issue a new error

      "One or more errors occurred while applying X's configuration"

  just to make it easier to distinguish configuration-specific
  failures from ordinary ones.

* Change config keys to tokens.Token, not tokens.ModuleMember,
  since it is legal for keys to represent class members (statics).
2017-02-28 10:32:24 -08:00
joeduffy d91b04d8f4 Support config maps
This change adds support for configuration maps.

This is a new feature that permits initialization code to come from markup,
after compilation, but before evaluation.  There is nothing special with this
code as it could have been authored by a user.  But it offers a convenient
way to specialize configuration settings per target husk, without needing
to write code to specialize each of those husks (which is needlessly complex).

For example, let's say we want to have two husks, one in AWS's us-west-1
region, and the other in us-east-2.  From the same source package, we can
just create two husks, let's say "prod-west" and "prod-east":

    prod-west.json:
    {
        "husk": "prod-west",
        "config": {
            "aws:config:region": "us-west-1"
        }
    }

    prod-east.json:
    {
        "husk": "prod-east",
        "config": {
            "aws:config:region": "us-east-2"
        }
    }

Now when we evaluate these packages, they will automatically poke the
right configuration variables in the AWS package *before* actually
evaluating the CocoJS package contents.  As a result, the static variable
"region" in the "aws:config" package will have the desired value.

This is obviously fairly general purpose, but will allow us to experiment
with different schemes and patterns.  Also, I need to whip up support
for secrets, but that is a task for another day (perhaps tomorrow).
2017-02-27 19:43:54 -08:00
joeduffy 2c6616831f Add AWS configuration variables 2017-02-27 16:52:06 -08:00