Commit graph

268 commits

Author SHA1 Message Date
Pat Gavlin b14d259365
Split large events into multiple log entries. (#2092)
Just what it says on the tin. The splitting is implemented s.t.
colorization commands are never split across multiple log entries.
2018-10-23 14:59:30 -07:00
Praneet Loke 052bc69a52
Add gitlab metadata - Part 1 (#2090)
* Introduce new metadata keys `vcs.repo`, `vcs.kind` and `vcs.owner` to keep the keys generic for any vcs. Expanded the git SSH regex to account for bitbucket's .org domain.

* Introduce new stack tags keys with the same theme of detecting the vcs.
2018-10-23 14:53:52 -07:00
Sean Gillespie e70c5d385e
Enable gzip compression on the wire (#2074)
* Enable gzip compression on the wire

This change allows the Pulumi API client to gzip requests sent to the
Pulumi service if requested using the 'GzipCompress' http option.

This change also sets the Accept-Encoding: gzip header for all requests
originating from the CLI, indicating to the service that it is free to
gzip responses. The 'readBody' function is used in the API client to
read a response's body, regardless of how it is encoded.

Finally, this change sets GzipCompress: true on the
'PatchUpdateCheckpoint' API call, since JSON payloads in that call tend
to be large and it has become a performance bottleneck.

* spelling

* CR feedback:

1. Clarify and edit comments
2. Close the gzip.Reader when reading bodies
3. Log the payload size when logging compression ratios
2018-10-23 14:11:40 -07:00
Luke Hoban 2ec066261b
Print the correct console URL in pulumi stack ls (#2075)
The cloudBackend's StackConsoleURL now returns a full URL instead of a path.

Fixes #2043.
2018-10-18 16:39:01 -07:00
Sean Gillespie dfdb10393a
Fix a panic on shutdown (#2050)
Last-minute events coming through the engine could cause the goroutine
iterating over engineEvents to write to displayEvents after it has
already been closed by the main goroutine.
2018-10-12 10:29:47 -07:00
Chris Smith 00bb0952c0
Add git head ref name to update metadata (#2033)
* Check git status from project repo, not cwd

* Add git head ref name to update metadata

* Reuse some test code
2018-10-08 11:13:21 -07:00
Joe Duffy c5a86ae7c2
Add an option to suppress displaying stack outputs (#2029)
This adds an option, --suppress-outputs, to many commands, to
avoid printing stack outputs for stacks that might contain sensitive
information in their outputs (like key material, and whatnot).

Fixes pulumi/pulumi#2028.
2018-10-06 14:13:02 -07:00
CyrusNajmabadi 84c2a23acc
Don't print out the 'info' column when there is nothing to display. (#2027) 2018-10-05 13:03:30 -07:00
CyrusNajmabadi 16ae1f2a81
Fix rendering of the 'outputs:' header in the diff view. (#2020) 2018-10-03 13:06:20 -07:00
Joe Duffy 423c995dfd
Default an update's message to the Git commit title (#2009)
There is a seldom-used capability in our CLI, the ability to pass
-m to specify an update message, which we will then show prominently.

At the same time, we already scrape some interesting information from
the Git repo from which an update is performed, like the SHA hash,
committer, and author information. We explicitly didn't want to scrape
the entire message just in case someone put sensitive info inside of it.

It seems safe -- indeed, appealing -- to use just the title portion
as the default update message when no other has been provided (the
majority case). We'll work on displaying it in a better way, but this
strengthens our GitOps/CI/CD story.

Fixes pulumi/pulumi#2008.
2018-10-02 10:49:41 -07:00
Joe Duffy fb18032a42
Emit the "using token" login message to stderr (#2006)
It's not good practice to dirty up the stdout stream with messages
like this. In fact, I questioned whether we should be emitting
*anything* here, but given that this is often used in unattended
environments, coupled with the fact that it's easy to accidentally set
this and then wonder why `pulumi login` is silently returning, led
me to keep it in (for now, at least).
2018-10-01 19:49:42 -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
CyrusNajmabadi 5d34e380ab
Prevent the same resource header from appearing multiple times during diagnostics. (#1985) 2018-09-25 10:58:22 -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
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
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
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
Chris Smith 677af7fe18 Wire through ApplierOptions 2018-09-21 13:57:57 -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
Sean Gillespie d3f59831d2
Add URN to dummy row for new events (#1957) 2018-09-19 14:29:16 -07:00
CyrusNajmabadi 4f9db82a43
Stop using black/white colors directly when printing out console text. They can have issues with light/dark terminals. (#1951) 2018-09-19 01:40:03 -07:00
Sean Gillespie d80db466a6
Display diff when Protect bit changes (#1949)
It's useful to show a diff whenever a user toggles the protect bit on a
resource, so they can be sure that it has actually occured.
2018-09-17 15:03:06 -07:00
Sean Gillespie b98c5bb0d9
Fix preview display for replacements (#1945)
* Fix preview display for replacements

* Make gometalinter happy
2018-09-17 10:50:11 -07:00
Chris Smith 792c316e5e
Change backend.ListStacks to return a new StackSummary interface (#1931)
* Have backend.ListStacks return a new StackSummary interface

* Update filestake backend to use new type

* Update httpstate backend to use new type

* Update commands to use new type

* lint

* Address PR feedback

* Lint
2018-09-13 20:54:42 -07:00
Matt Ellis 3642cca98f Don't print junk when a unrecognized URL is passed to pulumi login
In order to present a message with a link to a user's access tokens in
the service, we have to convert the API server's URL to the URL for
the console.  We understand how to do this for servers that look like
our servers (i.e. their host name is `api.<whatever>`), but in general
we can't do this.

Rewrite the code such that we only print a message about how to find
your access tokens (and offer browser based login) only in cases where
we are able to construct a URL to the console.

Fixes #1930
2018-09-13 19:36:00 -07:00
Sean Gillespie 3d5f005c95
Fix several output-related issues (#1919)
* Revert "Don't show stack outputs when update fails (#1916)"

This reverts commit e3f89e82aa.

* Be more precise about printing outputs

This commit prints outputs only if they are known to be complete. This
avoids massive red diffs during previews and when component resources
fail to call registerResourceOutputs.

* CR: Clean up large boolean expression and comment

* CR: boolean compromise
2018-09-11 16:44:06 -07:00
Sean Gillespie a35aba137b
Retire pending deletions at start of plan (#1886)
* Retire pending deletions at start of plan

Instead of letting pending deletions pile up to be retired at the end of
a plan, this commit eagerly disposes of any pending deletions that were
pending at the end of the previous plan. This is a nice usability win
and also reclaims an invariant that at most one resource with a given
URN is live and at most one is pending deletion at any point in time.

* Rebase against master

* Fix a test issue arising from shared snapshots

* CR feedback

* plan -> replacement

* Use ephemeral statuses to communicate deletions
2018-09-10 16:48:14 -07:00
Sean Gillespie 33d0c585bb
Use optional parent event stream for cancellation (#1912)
* Close cancellation source before closing events

The cancellation source logs cancellation messages to the engine event
channel, so we must first close the cancellation source before closing
the channel.

* CR: Fix race in shutdown of signal goroutine
2018-09-10 16:42:22 -07:00
Sean Gillespie e3f89e82aa
Don't show stack outputs when update fails (#1916)
* Don't show stack outputs when update fails

It is basically guaranteed that stack outputs are going to be
meaningless if a plan fails, so this commmit doesn't display them if an
error has occured.

* CR: expand on comment
2018-09-10 16:16:31 -07:00
Pat Gavlin 8fdc80a7dc
Check for input diffs when eliding same steps. (#1905)
It is possible for the inputs of a "same" resource to have changed even
if the contents of the input bags are different if the resource's
provider deems the physical change to be semantically irrelevant.
2018-09-07 15:10:02 -07:00
Justin Van Patten 2dd13292a3
Consolidate some new and up functionality (#1884)
Previously `new` was operating under the assumption that it was always
going to be creating a new project/stack, and would always prompt for
these values. However, we want to be able to use `new` to pull down the
source for an existing stack. This change adds a `--stack` flag to `new`
that can be used to specify an existing stack. If the specified stack
already exists, we won't prompt for the project name/description, and
instead just use the existing stack's values. If `--stack` is specified,
but doesn't already exist, it will just use that as the stack name
(instead of prompting) when creating the stack. `new` also now handles
configuration like `up <url>`: if the stack is a preconfigured empty
stack (i.e. it was created/configured in the Pulumi Console via Pulumi
Button or New Project), we will use the existing stack's config without
prompting. Otherwise we will prompt for config, and just like `up
<url>`, we'll use the existing stack's config values as defaults when
prompting, or if the stack didn't exist, use the defaults from the
template.

Previously `up <url>`'s handling of the project name/description wasn't
correct: it would always automatically use the values from the template
without prompting. Now, just like `new`:

 - When updating an existing stack, it will not prompt, and just use the
   existing stack's values.

 - When creating a new stack, it will prompt for the project
   name/description, using the defaults from the template.

This PR consolidates some of the `new`/`up` implementation so it shares
code for this functionality. There's definitely opportunities for a lot
more code reuse, but that cleanup can happen down the line if/when we
have the cycles.
2018-09-06 12:45:56 -07:00
Sean Gillespie f83d32390c
Don't close eventChannel when panicking (#1891)
* Don't close eventChannel when panicking

The state of the system is completely unknown when panicking and in
general it's not safe to infer whether or not it is safe to close a
channel when in this tate.

* CR feedback

* Spelling
2018-09-05 17:50:48 -07:00
joeduffy c1967129e7 Fix integration tests
This fixes the integration tests:

* Expect and allow the update header.

* Don't print the local permalink if there's an error.
2018-09-05 11:39:58 -07:00
joeduffy b1f7cf7050 Fix a few lint warnings 2018-09-05 08:25:23 -07:00
joeduffy 7ecc08d75d Print a link to the local stack's checkpoint file
Similar to how we print a URL at the end of each cloud-based
update, we now print a link to the stack's checkpoint file after
each update.
2018-09-05 07:33:18 -07:00
joeduffy 95e917441a Implement preview-then-update for local stacks
This change implements the same preview behavior we have for
cloud stacks, in pkg/backend/httpbe, for local stacks, in
pkg/backend/filebe. This mostly required just refactoring bits
and pieces so that we can share more of the code, although it
does still entail quite a bit of redundancy. In particular, the
apply functions for both backends are now so close to being
unified, but still require enough custom logic that it warrants
keeping them separate (for now...)
2018-09-05 07:33:18 -07:00
joeduffy bf51d7594a Refactor display logic out of pkg/backend/filestate
This simply refactors all the display logic out of the
pkg/backend/filestate package. This helps to gear us up to better unify
this logic between the filestate and httpstate backends.

Furthermore, this really ought to be in its own non-backend,
CLI-specific package, but I'm taking one step at a time here.
2018-09-05 07:33:18 -07:00
joeduffy d28f0cb7b6 Alter the login prompt
This change alters the login prompt slightly, so that it is more
obvious that alternative methods exist.

Before this change, we would say:

    $ pulumi login
    We need your Pulumi account to identify you.
    Enter your access token from https://app.pulumi.com/account
        or hit <ENTER> to log in using your browser            :

After this change, we say this instead:

    $ pulumi login
    Manage your Pulumi stacks by logging in.
    Run `pulumi login --help` for alternative login options.
    Enter your access token from https://app.pulumi.com/account
        or hit <ENTER> to log in using your browser            :

Also updated the help text to advertise this a bit more prominently.
2018-09-05 07:32:42 -07:00
joeduffy feaea31f7b Rename backend packages
This renames the backend packages to more closely align with the
new direction for them. Namely, pkg/backend/cloud becomes
pkg/backend/httpstate and pkg/backend/local becomes
pkg/backend/filestate. This also helps to clarify that these are meant
to be around state management and so the upcoming refactoring required
to split out (e.g.) the display logic (amongst other things) will make
more sense, and we'll need better package names for those too.
2018-09-05 07:32:42 -07:00
joeduffy 126d31c9c2 Simplify logging into the local backend
As part of making the local backend more prominent, this changes a few
aspects of how you use it:

* Simplify how you log into a specific cloud; rather than
  `pulumi login --cloud-url <url>`, just say `pulumi login <url>`.

* Use a proper URL scheme to denote local backend usage. We have chosen
  file://, since the REST API backend is of course always https://.
  This means that you can say `pulumi login file://~` to use the local
  backend, with state files stored in your home directory. Similarly,
  we support `pulumi login file://.` for the current directory.

* Add a --local flag to the login command, to make local logins a
  bit easier in the common case of using your home directory. Just say
  `pulumi login --local` and it is sugar for `pulumi login file://~`.

* Print the URL for the backend after logging in; for the cloud,
  this is just the user's stacks page, and for the local backend,
  this is the path to the user's stacks directory on disk.

* Tidy up the documentation for login a bit to be clearer about this.

This is part of pulumi/pulumi#1818.
2018-09-05 07:32:42 -07:00
Matt Ellis 9ec695dda0 Reformat call to action when we fail to launch browser for login
The existing message put the URL to visit and some explanation text on
the same line, which makes it a little harder to copy only the URL
into a browser. If this extra text ends up being copied as well as the
URL it can lead to failures later, when we try to decode the query
string as part of the OAuth flow.

It's easy enough to fix by just putting the URL on its own line, split
off from the text itself.

Fixes #1832
2018-09-04 14:28:29 -07:00
Joe Duffy fd852754fd
Merge pull request #1848 from pulumi/joeduffy/1551_refresh_text_clarification
Clarify refresh text
2018-09-02 11:58:50 -07:00
joeduffy 4827c7fb29 Update some text/colors
This changes two things:

1) Per PR feedback, change the text to "N changes found during refresh."

2) Colorize the parenthetical "No resources will be modified" message;
   it looked a little odd being plain colored.
2018-09-02 11:26:39 -07:00
Alex Clemmer dea68b8b37 Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.

In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.

The original commit message in that PR was:

> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 15:56:53 -07:00
Alex Clemmer 9e58fd1aaa Revert "Plumb LogRequest.IsStatus through the logging subsystem"
This reverts commit 3066cbcbd7.
2018-08-31 15:56:53 -07:00
Alex Clemmer 3066cbcbd7 Plumb LogRequest.IsStatus through the logging subsystem 2018-08-30 17:17:20 -07:00
Pat Gavlin 0634c1852a
Fix some potential bugs in the refresher. (#1845)
- Create all refresh steps before issuing any. This is important as the
  state update loop expects all steps to exist.
- Check for cancellation later in the refresher.

This also fixes races in the SnapshotManager and the test journal that
could cause panics during cancellation.
2018-08-29 21:00:05 -07:00
joeduffy cd5707f483 Clarify refresh text
The wording for refresh doesn't accurately convey that the operations
aren't actually mutating your resources, but instead are simply changing
your checkpoint state. This change (hopefully) helps in two ways:

First, put text just before the prompt:

Do you want to perform this refresh?
No resources will be modified as part of this refresh; just your stack's state will be.

Second, alter the summary ever-so-slightly, from:

info: 2 changes performed:
    ~ 2 resources updated
      3 resources unchanged

to:

info: 2 changes refreshed:
    ~ 2 resources updated
      3 resources unchanged

This reads just slightly better, and removes any sense of panic I might
have otherwise had that my refresh just did something wrong.

As I was in here, since I had to pass UpdateKind information to new
places, I cleaned up the situation where we had three mostly-similar
enums (but which actually diverged) and several areas where we were
using untyped strings for this same information. Now there's just one.

This fixes pulumi/pulumi#1551.
2018-08-29 17:09:14 -07:00