Commit graph

3283 commits

Author SHA1 Message Date
joeduffy 2499539afb Add the ability to have a stacks map file
For CI situations, we'll support a simple stacks map file, e.g.

    {
        "refs/heads/master": "production",
        "refs/heads/testing": "test'
    }

and, when PULUMI_CI is set, we'll use it to select the stack.

This is purely for experimental purposes; we're not sure this is
exactly what we want right now, but it's better than the manual
munging we've been doing with various bash scripts, etc. right now.
2018-10-01 13:45:26 -07:00
joeduffy 33ab82e9ac Set up some CI variables for GitHub App support 2018-10-01 11:38:03 -07:00
Pat Gavlin 74df0e67db
Allow previews when operations are pending. (#1999)
The preview will proceed as if the operations had not been issued (i.e.
we will not speculate on a new state for the stack). This is consistent
with our behavior prior to the changes that added pending operations to
the checkpoint.
2018-10-01 09:48:48 -07:00
Joe Duffy 9dd9c800a0
Merge pull request #2007 from jen20/alias-apply
Add suggestion for "apply" for "up" command
2018-10-01 08:17:07 -07:00
James Nugent c0cabf171f Add suggestion for "apply" for "up" command
It is easy to continually type `pulumi apply` from years of muscle memory using
Terraform - this commit makes the CLI suggest `up` when the `apply` subcommand
is used, similar to how `plan` suggests `preview`.
2018-10-01 13:14:14 +02:00
joeduffy eeb7da9eda Properly install Node.js 10.x 2018-09-30 08:20:29 -07:00
joeduffy d3ed7de33b Use a thin script wrapper for the entrypoint
This adds a package installation step just before calling the
`pulumi` CLI, making it easier to just volume mount a project
without needing to have `npm install`ed its contents yet.
2018-09-30 08:09:57 -07:00
joeduffy bf33f8113d Symlink node as nodejs
On Debian, the Node.js binary is named `nodejs`, whereas all our
scripts and tools assume `node`. This is a standard problem. To
address it, add symlink. Also move other binaries under /usr/bin.
2018-09-30 07:49:52 -07:00
joeduffy 61662d2e5f Install Node.js in the runtime Docker container 2018-09-30 07:34:11 -07:00
joeduffy ab43f1916a Restructure CI list 2018-09-30 07:31:49 -07:00
joeduffy 17a95c30b0 Install ca-certificates
Without this package, /etc/ssl/certs is empty, and the Pulumi CLI
will fail perpetually with

    error: problem logging in: getting user info from
        https://api.pulumi.com: performing HTTP request:
        Get https://api.pulumi.com/api/user: x509: certificate
        signed by unknown authority
2018-09-30 07:09:58 -07:00
Joe Duffy 9ef8259393
Merge pull request #2002 from pulumi/joeduffy/1991_dockerfile
Add a Dockerfile for the Pulumi CLI
2018-09-29 16:59:35 -07:00
joeduffy b6724c7892 Lock to specific dep version
This changes the Dockerfile to install the same specific dep version
we use in CI. To ensure we don't end up duplicating logic, it refactors
the versions themselves into a separate sourceable script that's shared
between both the Dockerfile and our existing CI scripts.
2018-09-29 16:33:21 -07:00
joeduffy 162157c1a7 Add a Dockerfile for the Pulumi CLI
This introduces a Dockerfile for the Pulumi CLI. This makes it
easier to develop and test the engine in a self-contained environment,
in addition to being suitable for running the actual CLI itself.

For instance,

    $ docker run pulumi/pulumi -e "PULUMI_ACCESS_TOKEN=x" up

will run the Pulumi program mounted under the /app volume. This will
be used in some upcoming CI/CD scenarios.

This uses multi-stage builds, and Debian Stretch as the base, for
relatively fast and lean build times and resulting images. We are
intentional about restoring dep packages independent of the actual
source code so that we don't end up needlessly re-depping, which can
consume quite a bit of time. After fixing
https://github.com/pulumi/pulumi/issues/1986, we should explore an
Alpine base image option.

I made the decision to keep this image scoped to just the Go builds.
Therefore, none of the actual SDK packages themselves are built, just
the engine, CLI, and language plugins for Node.js, Python, and Go.
It's possible to create a mega-container that has all of these full
environments so that we can rebuild them too, but for now I figured
it was better to rely on package management for them.

Another alternative would have been to install released binaries,
rather than building them. To keep the useful flow for development,
however, I decided to go the build route for now. If we build at the
same hashes, the resulting binaries "should" be ~identical anyhow.

I've created a pulumi/pulumi Docker Hub repo that we can publish this
into. For now, there is no CI publishing of the image.

This fixes pulumi/pulumi#1991.
2018-09-29 11:48:21 -07:00
Joe Duffy 04e588e33d
Merge pull request #2001 from pulumi/joeduffy/1991_global_non_interactive
Make --non-interactive a global flag
2018-09-29 11:30:08 -07:00
joeduffy 4168666600 Reject logins for non-interactive when envvar is unset
This change stops attempting to pop a web browser in non-interactive
sessions. Instead, the PULUMI_ACCESS_TOKEN environment variable must
be set. Otherwise, any attempt to use the CLI will yield

    $ pulumi --non-interactive preview
    error: PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions

This is the behavior we want for Docker-based invocations of the CLI,
and so is part of pulumi/pulumi#1991.
2018-09-29 10:55:19 -07:00
joeduffy 992aff2065 Move interactive checking into pkg/util/cmdutil 2018-09-29 10:49:14 -07:00
joeduffy 0e98091bd7 Make --non-interactive a global flag
Right now, we only support --non-interactive in a few places (up,
refresh, destroy, etc). Over time, we've added it to more (like new).
And now, as we're working on better Docker support (pulumi/pulumi#1991),
we want to support this more globally, so we can, for example, avoid
popping up a web browser inside a Docker contain for logging in.

So, this change makes --non-interactive a global flag. Because it is
a persistent flag, it still works in the old positions, so this isn't
a breaking change to existing commands that use it.
2018-09-29 10:41: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
Joe Duffy 936a53f96d
Support some stack operations w/out a Pulumi.yaml (#1998)
These commands ought to work even when you don't have a Pulumi.yaml:

    $ pulumi stack ls --all
    $ pulumi stack rm some-random-stack

They didn't previously, now they do. This fixes pulumi/pulumi#1556.
2018-09-28 14:30:20 -07:00
Joe Duffy 511e830c5c
Delete a dead example (#1996) 2018-09-28 12:10:50 -07:00
Sean Gillespie 6338875b72
Fix pulumi/pulumi#1995 (#1997)
The diff display code was not expecting that it would be possible for
resource properties to transition from being an archive to being an
asset, or the other way around. This commit prints out a reasonable diff
if this situation occurs instead of crashing.
2018-09-28 11:46:43 -07:00
Luke Hoban a66a1ae698
Add link to full installation instructions (#1994)
Fixes #1928.
2018-09-28 07:03:28 -07:00
Sean Gillespie ed0353e251
Process deletions conservatively in parallel (#1963)
* Process deletions conservatively in parallel

This commit allows the engine to conservatively delete resources in
parallel when it is sure that it is legal to do so. In the absence of a
true data-flow oriented step scheduler, this approach provides a
significant improvement over the existing serial deletion mechanism.

Instead of processing deletes serially, this commit will partition the
set of condemned resources into sets of resources that are known to be
legally deletable in parallel. The step executor will then execute those
independent lists of steps one-by-one until all steps are complete.

* CR: Make ResourceSet a normal map

* Only use the dependency graph if we can trust it

* Reverse polarity of pendingDeletesAreReplaces

* CR: un-export a few types

* CR: simplify control flow in step generator when scheduling

* CR: parents are dependencies, fix loop index

* CR: Remove ParentOf, add new test for parent dependencies
2018-09-27 15:49:08 -07:00
Matt Ellis d9e3c2c91d Restore build-sdk.sh script
It was not intended to be deleted as part of #1992, we just wanted to
delete `dist/install.sh`
2018-09-26 21:49:19 -07:00
Joe Duffy 197b239741
Merge pull request #1992 from pulumi/ellismg/remove-install-script
Remove install script from SDK tarball
2018-09-26 18:09:17 -07:00
Matt Ellis f91e1ba5c5 Remove install script from SDK tarball
Pulumi used to have a much more complicated install process, whereas
today, this is no longer the case. You simply unpack pulumi to a
folder of your choice, add it to the `$PATH` and then go.

The `install.sh` was writtten back when Pulumi had to be installed
into its own directory. It assumed that it "owned" this directory and
when the script hit an error would clean up its half processed state
before trying to exit. While this was fine out of the box (since we
default to installing to `/usr/local/pulumi`) if you overrode the
install location to just say `/usr/local` *and* we hit an error in the
script, the script would try to remove everything from `/usr/local` as
part of cleaning itself up.

Since we no longer need any of this extra install logic, we'll just
remove `install.sh` completely. The SDK tarball will now contain a
single top level directory (named `pulumi`) with all of our binaries
under it. Manual installs will now just mean unpacking the tarball
somewhere and putting that `pulumi` folder on your path, or as a
simplification, copying all the binaries from the `pulumi` folder into
an existing folder that is already on your path.

This also removes the need to ever ask the user to `sudo` during an
install. Users now have complete control over where they put our
binaries, which is exactly what you want from a manual install
process.
2018-09-26 14:05:56 -07:00
CyrusNajmabadi 177f0f7ca1
Fix computation of the isKnown bit for an Output (when the apply function returns an Output itself). (#1974) 2018-09-25 21:29:27 -07:00
CyrusNajmabadi 5d34e380ab
Prevent the same resource header from appearing multiple times during diagnostics. (#1985) 2018-09-25 10:58:22 -07:00
CyrusNajmabadi 431f5b3450
Fix rtti check. (#1983) 2018-09-24 20:06:31 -07:00
Matt Ellis d51e04f501 Write warnings from the Pulumi service
API calls agains the Pulumi service may start setting a new header,
`X-Pulumi-Warning`. The value of this header should be presented to
the user as a warning.

The Service will use this to provide additional information to the
user without having the CLI have to know about every specific warning
path.
2018-09-24 16:59:15 -07:00
CyrusNajmabadi d305b30f21 Revert RunError behavior. Introduce new ResourceError for errors assiated with a resource. (#1981)
* Revert RunError behavior.  Introduce new ResourceError for errors associated with a resource.

* Fix docs.

* Use resource error.

* Use ResourceError in more places.

* Use ResourceError in a few more places.

* Throw a resource error.

* Make required.

* Revert this.

* Lint.

* Only report errors once.

* Better comment.
2018-09-24 16:57:20 -07:00
Joe Duffy 4060851324
Merge pull request #1976 from pulumi/joeduffy/no_same_asterisk
Make a smattering if CLI UX improvements
2018-09-24 15:51:23 -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
joeduffy b06a02f03c Use go-humanize instead of lame hand-pluralization 2018-09-24 14:40:14 -07:00
CyrusNajmabadi 04fe445c22
Allow Error instances to be reported against a resource. (#1980) 2018-09-24 13:42:16 -07:00
joeduffy 3468393490 Make a smattering of CLI UX improvements
Since I was digging around over the weekend after the change to move
away from light black, and the impact it had on less important
information showing more prominently than it used to, I took a step
back and did a deeper tidying up of things. Another side goal of this
exercise was to be a little more respectful of terminal width; when
we could say things with fewer words, I did so.

* Stylize the preview/update summary differently, so that it stands
  out as a section. Also highlight the total changes with bold -- it
  turns out this has a similar effect to the bright white colorization,
  just without the negative effects on e.g. white terminals.

* Eliminate some verbosity in the phrasing of change summaries.

* Make all heading sections stylized consistently. This includes
  the color (bright magenta) and the vertical spacing (always a newline
  separating headings). We were previously inconsistent on this (e.g.,
  outputs were under "---outputs---"). Now   the headings are:
  Previewing (etc), Diagnostics, Outputs, Resources, Duration, and Permalink.

* Fix an issue where we'd parent things to "global" until the stack
  object later showed up. Now we'll simply mock up a stack resource.

* Don't show messages like "no change" or "unchanged". Prior to the
  light black removal, these faded into the background of the terminal.
  Now they just clutter up the display. Similar to the elision of "*"
  for OpSames in a prior commit, just leave these out. Now anything
  that's written is actually a meaningful status for the user to note.

* Don't show the "3 info messages," etc. summaries in the Info column
  while an update is ongoing. Instead, just show the latest line. This
  is more respectful of width -- I often find that the important
  messages scroll off the right of my screen before this change.

    For discussion:

        - I actually wonder if we should eliminate the summary
          altogether and always just show the latest line. Or even
          blank it out. The summary feels better suited for the
          Diagnostics section, and the Status concisely tells us
          how a resource's update ended up (failed, succeeded, etc).

        - Similarly, I question the idea of showing only the "worst"
          message. I'd vote for always showing the latest, and again
          leaving it to the Status column for concisely telling the
          user about the final state a resource ended up in.

* Stop prepending "info: " to every stdout/stderr message. It adds
  no value, clutters up the display, and worsens horizontal usage.

* Lessen the verbosity of update headline messages, so we now instead
  of e.g. "Previewing update of stack 'x':", we just say
  "Previewing update (x):".

* Eliminate vertical whitespace in the Diagnostics section. Every
  independent console.out previously was separated by an entire newline,
  which made the section look cluttered to my eyes. These are just
  streams of logs, there's no reason for the extra newlines.

* Colorize the resource headers in the Diagnostic section light blue.

Note that this will change various test baselines, which I will
update next. I didn't want those in the same commit.
2018-09-24 08:43:46 -07:00
Thomas Schersach cb9cb7da94 Reworked gen-bash-completion into a more generic completion command (#1967)
## Why ?

I'm using Zsh (and I'm not the only one 🤣). Pulumi having Zsh completions is great. I will also add completions to the Homebrew Formula when this is merged.

## Why not use Cobra `GenZshCompletion`

It's currently not good enough. Maybe it will be when spf13/cobra#646 is done.

## Implementation

I did the same thing `kubectl` does for Zsh completion. Meaning using the bash completion generated by Cobra and adapting it to a zsh format. The resulting zsh completion file is not perfect (compared to one's where you have a short command description in the output) but it's good enough I think. 

I also changed the file output to a stdout output. I think it's better than outputting to a file and it will make adding completions in Homebrew straightforward. I don't know if the previous `gen-bash-completion` is used in any Pulumi project so this may break things.
2018-09-24 06:25:16 -07:00
CyrusNajmabadi e498cab239
Use test helper. (#1977) 2018-09-22 22:44:49 -07:00
joeduffy 8643bfec22 Don't print redundant "previewing"/"updating" prelude
Now that we're showing SpecUnimportant as regular text, the extra
"Previewing"/"Updating" line that we show really stands out as being
superfluous. For example, we previously said:

    Updating stack 'docker-images'
    Performing changes:

        ...

This change eliminates that second line, so we just have:

    Updating stack 'docker-images':

        ...
2018-09-22 13:34:43 -07:00
joeduffy be9ead855d Eliminate the same prefix
Recently, we eliminated bright black text, which IMHO makes the
"same" lines really stand out more than we want them to. This is
partly just due to the heavyweight nature of the "*" character,
which we precede every line with. This has the effect of making it
toughter to scan the update to see what's going to happen. The goal
of SpecUnimportant (bright black) was that we wanted to draw less
attention to certain elements of the CLI text -- and have them fade
into the background (apparently it was too successful at this ;-))

So, this change eliminates the "*" prefix for same operations
altogether. It reads better to my eyes and keeps the original intent.
2018-09-22 13:34:43 -07:00
Joe Duffy a977749b3d
Merge pull request #1907 from pulumi/chrsmith/1826/always-upload-previews
Always upload previews
2018-09-22 13:34:31 -07:00
Chris Smith 677af7fe18 Wire through ApplierOptions 2018-09-21 13:57:57 -07:00
CyrusNajmabadi 2b610ce577
Actually export type. (#1971) 2018-09-21 11:58:58 -07:00
Pat Gavlin 8f55a379f6
Return errors for unknown/invalid path archives. (#1970)
- Attempting to read an archive with an unknown type now returns an
  error
- Attempting to read a path archive that is neither a known archive
  format or a directory now returns an error

Fixes #1529.
Fixes #1953.
2018-09-21 11:53:39 -07:00
Chris Smith 3984cd96d7 Persist all previews, even those immediately before update 2018-09-21 11:41:31 -07:00
Chris Smith 9c042a3a5b Always upload previews 2018-09-21 11:38:12 -07:00
CyrusNajmabadi 08bfb69f7b
Move to an options-bag for computeCodePaths. (#1969) 2018-09-21 11:29:05 -07:00
Luke Hoban 375b75be84
Fix requireObject docs (#1961)
Fixes #1958
2018-09-21 07:58:14 -07:00
Joe Duffy d04acf4da1
Remember lazy stack selection (#1964)
If you run an operation that requires a stack, but you don't have
one selected, you'll be prompted. This happens all over the place.
Sadly, your selection at this prompt is not remembered (unless you
opt to create a new one), meaning you'll just keep getting prompted.

The fix is simple: we just ignored the setCurrent bool previously;
we need to respect it and call the SetCurrentStack function.

This fixes pulumi/pulumi#1831.
2018-09-21 07:45:23 -07:00