Commit graph

756 commits

Author SHA1 Message Date
joeduffy 250bcb9751 Add a --json flag to the preview command
This change adds a --json flag to the preview command, enabling
basic JSON serialization of preview plans. This effectively flattens
the engine event stream into a preview structure that contains a list
of steps, diagnostics, and summary information. Each step contains
the deep serialization of resource state, in addition to metadata about
the step, such as what kind of operation it entails.

This is a partial implementation of pulumi/pulumi#2390. In particular,
we only support --json on the `preview` command itself, and not `up`,
meaning that it isn't possible to serialize the result of an actual
deployment yet (thereby limiting what you can do with outputs, etc).
2019-04-25 17:36:31 -07:00
PLACE 70bc0436ed Add support for state in cloud object storage (S3, GCS, Azure) (#2455) 2019-04-24 20:55:39 -07:00
Sean Gillespie 2d875e0004
Remove uses of plugins in the snapshot (#2662) 2019-04-23 09:53:44 -07:00
Levi Blackstone bdc687e654
Add a note about quoting to state delete doc (#2641) 2019-04-11 16:10:28 -06:00
Matt Ellis ccd958777c Don't print error prefix when a confirmation prompt is declined
Use `result.Result` in more places, so when a confirmation prompt is
declined, we just return `result.Bail()` after printing a message
without the `error: ` prefix.

Fixes #2070
2019-03-26 15:17:18 -07:00
Dominik-K 3324dc3249 cmd/state_delete: document URN in help (#2475)
Documenting positional arguments must be done manually, still: https://github.com/spf13/cobra/issues/395
2019-03-26 09:59:52 -07:00
CyrusNajmabadi c6d87157d9
Use result.Result in more places. (#2568) 2019-03-19 16:21:50 -07:00
CyrusNajmabadi ecb50b9b85
Use interface for 'result.Result' (#2569) 2019-03-19 12:40:10 -07:00
Matt Ellis a1bb16407d Add pulumi stack rename
`pulumi stack rename` allows you to change the name of an existing
stack. This operation is non-distructive, however it is possible that
the next update will show additional changes to resources, if the
pulumi program uses the value of `getStack()` as part of a resource
name.
2019-03-19 11:04:33 -07:00
CyrusNajmabadi 5d66bea92a
Add in some top-down usage of result.Result (#2556) 2019-03-13 18:00:49 -07:00
Justin Van Patten 7d7e104ee3
Stop running up as part of pulumi new (#2539)
Originally, `pulumi new` did not run `up` after generating a project. To
help users get a deployed stack as quickly as possible, we changed
`pulumi new` to run an initial deployment at the end of its operation.
Users would first see a preview and get to decide whether to proceed
with an initial deployment, and then continue to iterate from there.

Note that this would only happen for nodejs projects
(TypeScript/JavaScript). We would not run `up` for Python projects as we
require the user to run `pip install` in a virtualenv, so we'd print
instructions with the necessary commands the user must run instead.

Running `up` as part of `pulumi new` for nodejs projects has ended up
being more confusing than helpful for new users, and annoying for
experienced users. New users aren't expecting `pulumi new` to run an
initial deployment after generating the project (they haven't even
looked at the project source yet). Experienced users find it frustrating
as you typically want to just generate the project, and don't want to
have to wait for the preview just to decline running the update.

This change reverts `pulumi new` back to not running `up` automatically
for nodejs projects. Instead, like with Python projects, at the end of
the operation, we print instructions to the user to run `pulumi up` to
deploy the project.
2019-03-11 12:32:40 -07:00
Justin Van Patten 2e60ba0305 Hook up stderr when running brew command
Noticed that I'd missed this right after merging.
2019-03-06 22:45:55 -08:00
Justin Van Patten 7784c94c88
Show brew upgrade when installed with Homebrew (#2519)
Show `brew upgrade pulumi` as the upgrade message when the currently
running pulumi executable is on macOS and running from the brew install
directory.
2019-03-06 10:56:44 -08:00
Luke Hoban 3402bc8b4c
Doc edits to cmd (#2505) 2019-03-02 11:04:09 -08:00
Matt Ellis bdaf9f8361 Provide a hint about stack name format when creating stacks
This makes creating a stack in an organization a little more
discoverable.

Contributes To: #2421
2019-02-26 10:09:06 -08:00
Luke Hoban c974bff8e0 Display current logged in user
See pulumi/docs#826.
2019-02-01 11:27:49 -08:00
Matt Ellis dc6945f078 Don't include the project name in the sugessted stack name
When stack names had to be unique across an entire organization, we
had a convention that stack names would be prefixed by the project
name, to prevent collisions.

Now that stack names are scoped within a project, we no longer need to
include the project name in the stack name. So when running `pulumi
new` to scaffhold a new project, just recommend the name `dev` for the
stack to create instead of `<project-name>-dev`.

Fixes #1417
2019-01-24 16:56:54 -08:00
Justin Van Patten dee2c37d9d
pulumi new improvements (#2379)
Some changes to `pulumi new` to improve the experience:

 - Color the default values for config differently to make them stand
   out better
 - Mention that `new` will also perform an initial deployment
 - Add more vertical whitespace between steps in the process
 - Print message indicating the "Installing dependencies" step is
   complete
 - After "project is ready to go", add a note about doing an initial
   deployment
 - Output follow-up command to run when an update fails
 - Go back to showing the `npm install` output as `npm` doesn't always
   return an error code when it runs into problems
2019-01-23 08:57:48 -08:00
Matt Ellis 9384102a93 Add --json to pulumi history 2019-01-22 15:42:29 -08:00
Matt Ellis 24e6158378 Add --json to pulumi plugin ls 2019-01-22 15:42:29 -08:00
Matt Ellis 27988d8085 Change pulumi config --json output format
We haven't shipped this yet, and it feels like returning a dictionary
where the keys are config keys and the value is an object that tells
you if it is a secret or not (and its value if it is secret and you
have passed `--show-secrets`) is going to be better overall.
2019-01-22 14:28:35 -08:00
Matt Ellis 5cfd44c73a Add --json to pulumi config get and pulumi config
This supports using `--json` to get configuration information in a
structured way.

The objects we return have the following schema:

```
{
    name: string;
    value: string?;
    secret: bool;
}
```

In the case of `pulumi config` when --show-secrets is not passed, and
there are secret values, the `value` property of the object for that
configuration value will not be set. This differs from the normal
rendering where we show `[secret]`.

Contributes To #496
2019-01-22 10:39:37 -08:00
Matt Ellis 9d63f0a8a2 Do upfront validation during pulumi new
- Ensure new projects have a project name in line with what we'd like
  to enforce going forward

- Do more aggresive validation during the interactive prompts during
  `pulumi new`

- Fix an issue where the interactive prompt rendered weridly when
  there was a validation error

Contributes to #1988
Fixes #1441
2019-01-17 09:14:22 -08:00
Matt Ellis 7254b33634 Revert "Include TLS1.2 dance in copy pastable upgrade command on Windows"
This reverts commit fe6567a9a7.

We've decided to change get.pulumi.com to not require this, so
reverting the change to make the already long command no longer than
needed.
2019-01-16 16:47:53 -08:00
Justin Van Patten 05cd79ef40
Remove template section from Pulumi.yaml (#2363)
We currently leave behind the template section inside Pulumi.yaml after
`pulumi new`. While we may eventually make use of it, we're not
currently using it, so it's cleaner to just remove it for now.
2019-01-16 13:52:06 -08:00
Matt Ellis fe6567a9a7 Include TLS1.2 dance in copy pastable upgrade command on Windows
We upgraded get.pulumi.com to require TLS1.2. Because powershell does
not support this out of the box, we had to augment the install command
to also enable support for TLS1.2. While we did this on pulumi.io in
our documentation, we also print a similar message on Windows when the
CLI is out of date.

This change augments the message to include enabiling TLS 1.2 during
the invocation.
2019-01-16 13:36:39 -08:00
diana-slaba bf300038d4
Initial stack history command (#2270)
* Initial stack history command

* Adding use of color pkg, adding background colors to color pkg, and removing extra stack output

* gofmt-ed colors file

* Fixing format and removing JSON output

* Fixing nits, changing output for environment, and adding some tests

* fixing failing history test
2019-01-14 18:19:24 -08:00
Justin Van Patten 5d3d8c01dd
Add commands for managing stack tags (#2333)
Adds `pulumi stack tag` commands for managing stack tags.
2019-01-04 13:23:47 -08:00
Matt Ellis 59a54f1802
Add --stack argument to a few missing commands (#2278)
As of this change, all of the stack specific commands for `pulumi` now
allow passing `--stack` to operate on a different stack from the
default one.

Fixes #1648
2018-12-10 10:10:43 -08:00
Matt Ellis ad78f3ef59 Improve error message when Pulumi.yaml can't be found
Fixes #2234
2018-12-06 14:04:01 -08:00
Matt Ellis bb1fa36a47
Enable ANSI colorization in Windows terminal (#2269)
Before the windows console will understand ANSI colorization codes the
terminal must be put in a special mode by passing
ENABLE_VIRTUAL_TERMINAL_PROCESSING to SetConsoleMode. This was
happening as a side effect of term.StdStreams() from a docker package,
which we did before displaying the update data. However, any
colorization done before that call would just show the raw ANSI escape
codes.

Call this helper much earlier (i.e. as soon as the CLI starts up) so
any messages that we print will have the correct colorization applied
to them.

Fixes #2214
2018-12-04 16:58:32 -08:00
CyrusNajmabadi d93e930856
Provide an actual 'table' printing routine so that we can appropriate choose columns widths dynamically. (#2266) 2018-12-02 00:22:07 -08:00
Pat Gavlin 9c5526e7dd
Add a --config-file option for stack ops (#2258)
This option allows the user to override the file used to fetch and store
configuration information for a stack. It is available for the config,
destroy, logs, preview, refresh, and up commands.

Note that this option is not persistent: if it is not specified, the
stack's default configuration will be used. If an alternate config file
is used exclusively for a stack, it must be specified to all commands
that interact with that stack.

This option can be used to share plaintext configuration across multiple
stacks. It cannot be used to share secret configuration, as secrets are
associated with a particular stack and cannot be decryptex by other
stacks.
2018-11-30 15:11:05 -08:00
Sean Gillespie 1bf41cb37d
Don't attempt to install packages for Python new (#2225)
* Don't attempt to install packages for Python new

Global installation of packages is almost always not what a user will
want when running 'pulumi new'. This commit instead prints out the
commands that a user should run in order to create a new virtualenv and
install the required Pulumi packages within it.

* CR feedback
2018-11-21 15:01:57 -08:00
Joe Duffy 1e9f5b96f2
Merge pull request #2164 from pulumi/ellismg/update-tools
Update to Go 1.11 and golangci-lint
2018-11-10 17:32:14 -08:00
Matt Ellis 8a21844ed8 Correctly handle in progress updates in pulumi stack ls
When an update is in progress, `pulumi stack ls` was showing the LAST
UPDATE time as "a long while ago" because the service API returns 0 as
the last update time.

Handle this case correctly, displaying "in progress" for the update
time. When using JSON output, we don't include the update time (just
like a stack that has never been updated) but we do set the
`updateInProgress` property of the returned object

Fixes #2042
2018-11-09 14:34:16 -08:00
Matt Ellis 4442f22377 Add --preserve-config to pulumi stack rm
This allows you to keep the configuration file for a stack on disk,
even if you are removing the stack from the backend.

Fixes #2152
2018-11-09 14:33:18 -08:00
Matt Ellis 992b048dbf Adopt golangci-lint and address issues
We run the same suite of changes that we did on gometalinter. This
ended up catching a few new issues, some of which were addressed and
some of which were baselined.
2018-11-08 14:11:47 -08:00
Justin Van Patten 4defd64e0a
Support specifying template names to pulumi up (#2177)
`pulumi up <arg>` does not currently support template names like `pulumi
new`; `up` is hard-coded to only support URLs to templates. This
prevents us from displaying shorter `$ pulumi up ...` commands in the
Pulumi Console when the URL is to one of our standard Pulumi templates.
In such cases, we'd like to be able to show the command with just the
template name instead of a full URL to the template in the
pulumi/templates repo.

This changes `up` to support the standard Pulumi template names
just like `new`.

Also, while making changes here, if a URL specified to `up` contains
multiple templates in subdirectories, allow the user to choose the
template, just like with `new`.
2018-11-08 10:43:10 -08:00
Justin Van Patten d3ec63cd1d
Use proj description when there's no template desc (#2179)
Whenever we need to display a template description, if the Pulumi.yaml
doesn't have it, but has a project description, just use the project
description. This will allow us to avoid having the same description for
both the project and template in our examples.
2018-11-08 10:42:26 -08:00
Justin Van Patten e1d1366f3b
Don't show new prelude when -g is specified (#2178)
The new command shouldn't show you the "this command will walk you
through" prelude when using the `-g` command -- it's not helpful and
generally looks confusing.
2018-11-08 10:42:00 -08:00
Chris Smith 0a76923c64
Add CircleCI support (#2143) 2018-11-01 11:20:31 -07:00
Joe Duffy 9aedb234af
Tidy up some data structures (#2135)
In preparation for some workspace restructuring, I decided to scratch a
few itches of my own in the code:

* Change project's RuntimeInfo field to just Runtime, to match the
  serialized name in JSON/YAML.

* Eliminate the no-longer-used Context and NoDefaultIgnores fields on
  project, and all of the associated legacy PPC-related code.

* Eliminate the no-longer-used IgnoreFile constant.

* Remove a bunch of "// nolint: lll" annotations, and simply format
  the structures with comments on dedicated lines, to avoid overly
  lengthy lines and lint suppressions.

* Mark Dependencies and InitErrors as `omitempty` in the JSON
  serialization directives for CheckpointV2 files. This was done for
  the YAML directives, but (presumably accidentally) omitted for JSON.
2018-11-01 08:28:11 -07:00
Matt Ellis 4ba5901aaf Add --json to pulumi logs
When outputing JSON, if we have a fixed number of log entries (i.e. we
are not `--follow`'ing, we wrap each entry in array. Otherwise, we
just emit each log entry as an object at top level.

As part of this change, I've adopted a slightly more precise time
output format in `pulumi stack ls` when using JSON output. These times
now match the default output from `console.log(new Date())`
2018-10-29 12:43:52 -07:00
Sean Gillespie ca540cc736 Use math.MaxInt32 to signal unbounded parallelism
Downlevel versions of the Pulumi Node SDK assumed that a parallelism
level of zero implied serial execution, which current CLIs use to signal
unbounded parallelism. This commit works around the downlevel issue by
using math.MaxInt32 to signal unbounded parallelism.
2018-10-29 12:27:03 -07:00
Matt Ellis 74672857fd Remove pulumi archive and archive uploading code
In the past, we had a mode where the CLI would upload the Pulumi
program, as well as its contents and do the execution remotely.

We've since stopped supporting that, but all the supporting code has
been left in the CLI.

This change removes the code we had to support the above case,
including the `pulumi archive` command, which was a debugging tool to
generate the archive we would have uploaded (which was helpful in the
past to understand why behavior differed between local execution and
remote execution.)
2018-10-26 18:03:58 -07:00
Matt Ellis 19cf3c08fa Add --json flag to pulumi stack ls
We've had multiple users ask for this, so let's do it proactively
instead of waiting for #496

Fixes #2018
2018-10-26 13:13:50 -07:00
Matt Ellis db1c646c94 Don't error in pulumi stack output when there is no root resource
We used to issue an error when you ran `pulumi stack output` for a
stack with with no root resource (e.g. one that hadn't been stood up
yet or one that had been stood up but then destoryed).

Instead, just follow the normal case for a stack that has a root
resource, but has no outputs.

Fixes #2016
2018-10-25 15:00:38 -07:00
Chris Smith f324a460e9
Remove references to Pulumi private clouds (#2095)
* Remove TODO for issue since fixed in PPCs.

* Update issue reference to source

* Update comment wording

* Remove --ppc arg of stack init

* Remove PPC references in int. testing fx

* Remove vestigial PPC API types
2018-10-24 13:50:35 -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
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
Chris Smith eba044e061
Handle malformed commit messages (#2069) 2018-10-18 11:10:36 -07:00
Sean Gillespie 3e9b210edd
Default to unbounded parallelism (#2065)
Some providers (namely Kubernetes) require unbounded parallelism in
order to function correctly. This commit enables the engine to operate
in a mode with unbounded parallelism and switches to that mode by
default.
2018-10-17 15:33:26 -07:00
Chris Smith 3264012061
Get commit message and branch from CI if unavailable (#2062)
* Get commit message and branch from CI if unavailable

* Add tests
2018-10-16 15:37:02 -07:00
Sean Gillespie 730a929c2b
Add new 'pulumi state' command for editing state (#2024)
* Add new 'pulumi state' command for editing state

This commit adds 'pulumi state unprotect' and 'pulumi state delete', two
commands that can be used to unprotect and delete resources from a
stack's state, respectively.

* Simplify LocateResource

* CR: Print yellow 'warning' before editing state

* Lots of CR feedback

* CR: Only delete protected resources when asked with --force
2018-10-15 09:52:55 -07:00
Matt Ellis 19944b9c89 Add note about create a stack in an organization to the help
Fixes #1421
2018-10-08 17:04:04 -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
Chris Smith f1b5dd7386
Check git status from project repo, not cwd (#2032) 2018-10-08 10:05:06 -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 4ec76981f6
Bring back support for the 'auto' value for colorization. (#2023) 2018-10-04 16:20:01 -07:00
Joe Duffy 5ed33c6915
Add GitLab CI support (#2013)
This change adds GitLab CI support, by sniffing out the right
variables (equivalent to what we already do for Travis).

I've also restructured the code to share more logic with our
existing CI detection code, now moved to the pkg/util/ciutil
package, and will be fleshing this out more in the days to come.
2018-10-02 16:08:03 -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
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 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
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
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
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
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
James Nugent 6af4ebe384 Allow any configured CI to use the GitHub app (#1947)
This commit adds checks for a set of predefined environment variables:

- PULUMI_CI_SYSTEM
- PULUMI_CI_BUILD_ID
- PULUMI_CI_BUILD_TYPE
- PULUMI_CI_BUILD_URL
- PULUMI_CI_PULL_REQUEST_SHA

If PULUMI_CI_SYSTEM is set in the environment, CI configuration is
extracted from the remaining variables for sending to the backend, and
disables the checks for supported systems (currently only Travis CI).

This increases the flexibility of the Pulumi CLI by not requiring
specific support for particular CI systems to be added, provided the
necessary environment variables are configured for the job - this should
be possible for at least TeamCity, Jenkins, AWS CodeBuild, Azure DevOps
Pipelines, and likely most other systems.

This should not replace native support for detecting more CI systems in
future, however, since it requires more work of the user.
2018-09-18 09:50:29 -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
Thomas Schersach 0b728a1c3c Added short description to pulumi root cmd (#1925)
* Added short description to pulumi root cmd

* Fixed formatting
2018-09-13 06:45:52 -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
Joe Duffy df6d337302
Improve Pulumi command help (#1896)
This change improves the root command help text for the CLI. It
advertises common commands and includes a more prominent link to
our project website. Fixes pulumi/pulumi#1652.
2018-09-06 13:55:12 -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
Joe Duffy 373bc25cfd
Merge pull request #1875 from pulumi/joeduffy/1818_local_backend
Improve the local backend
2018-09-05 13:00:26 -07:00
Justin Van Patten b46820dbef
Move away from ${PROJECT} and ${DESCRIPTION} (#1873)
We generally want examples and apps to be authored such that they are
clonable/deployable as-is without using new/up (and want to
encourage this). That means no longer using the ${PROJECT} and
${DESCRIPTION} replacement strings in Pulumi.yaml and other text files.
Instead, good default project names and descriptions should be specified
in Pulumi.yaml and elsewhere.

We'll use the specified values as defaults when prompting the user, and
then directly serialize/save the values to Pulumi.yaml when configuring
the user's project. This does mean that name in package.json (for nodejs
projects) won't be updated if it isn't using ${PROJECT}, but that's OK.

Our templates in the pulumi/templates repo will still use
${PROJECT}/${DESCRIPTION} for now, to continue to work well with v0.15
of the CLI. After that version is no longer in use, we can update the
templates to no longer use the replacement strings and delete the code
in the CLI that deals with it.
2018-09-05 08:00:57 -07:00
joeduffy 68ccfce38c Merge with up changes 2018-09-05 07:40:42 -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
Justin Van Patten 01c14acd63
Fix new's auto-up to display things interactively (#1854)
* Fix new's auto-up to display things interactively

This change fixes `new` to check whether things should be done
interactively, and passes the information along when auto running `up`
so that the standard interactive output is displayed.

When running non-interactively, we'll now auto-accept all prompts as if
`--yes` was passed.

* Add --non-interactive flag
2018-09-04 10:57:28 -07:00
Justin Van Patten 9cb163f26b
Fix up to save -c config values for non-url case (#1855)
Previously, we were only saving config values specified on the command line (via --config/-c) for the URL case. This change fixes things to save these config values for the non-URL path.
2018-08-31 16:38: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
Justin Van Patten c29776e561
Support project config keys in templates and -c (#1841)
Previously, we only supported config keys that included a ':' delimiter
in config keys specified in the template manifest and in `-c` flags to
`new` and `up`. This prevented the use of project keys in the template
manifest and made it more difficult to pass such keys with `-c`,
effectively preventing the use of `new pulumi.Config()` in project code.

This change fixes this by allowing config keys that don't have a
delimiter in the template manifest and `-c` flags. In such cases, the
project name is automatically prepended behind the scenes, the same as
what `pulumi config set` does.
2018-08-30 14:56:13 -07:00
Justin Van Patten 1f8938e234
Run up automatically at the end of new (#1808)
We already walk through creating a stack and prompting for required
config, and then tell the user to run `pulumi up` to do an initial
deployment. Instead, just proceed with the `up` automatically.
2018-08-27 16:41:20 -07:00
Justin Van Patten 15aca4e9d8
Make new output an error if the directory isn't empty (#1810)
This allows us to get rid of the `mkdir <dir> && cd <dir>` instructions in all our tutorials before `pulumi new`, because anyone who runs `pulumi new` in a non-empty directory will be forced to create a new directory in order to proceed.
2018-08-27 08:06:06 -07:00
Pat Gavlin 73f4f2c464
Reimplement refresh. (#1814)
Replace the Source-based implementation of refresh with a phase that
runs as the first part of plan execution and rewrites the snapshot in-memory.

In order to fit neatly within the existing framework for resource operations,
these changes introduce a new kind of step, RefreshStep, to represent
refreshes. RefreshSteps operate similar to ReadSteps but do not imply that
the resource being read is not managed by Pulumi.

In addition to the refresh reimplementation, these changes incorporate those
from #1394 to run refresh in the integration test framework.

Fixes #1598.
Fixes pulumi/pulumi-terraform#165.
Contributes to #1449.
2018-08-22 17:52:46 -07:00
Matt Ellis ad2d51898c Don't use :config: token when sending values to the service
The fact that we include the `:config:` portion of a configuration
name when sending to the service is an artifact of history. It was
needed back when we needed to support deploying using a new CLI
against a PPC that had older packages embeded in it.

We don't have that sort of problem anymore, so we can stop sending
this data.
2018-08-22 16:41:46 -07:00
Sean Gillespie 3cba431ada
Show a better error message when decrypting fails (#1815)
* Show a better error message when decrypting fails

It is most often the case that failing to decrypt a secret implies that
the secret was transferred from one stack to another via copying the
configuration. This commit introduces a better error message for this
case and instructs users to explicitly re-encrypt their encrypted keys
in the context of the new stack.

* Spelling

* CR: Grammar fixes
2018-08-22 15:32:54 -07:00
Matt Ellis acf0fb278a Fix wierd interactions due to Cobra and glog
The glog package force the use of golang's underyling flag package,
which Cobra does not use. To work around this, we had a complicated
dance around defining flags in multiple places, calling flag.Parse
explicitly and then stomping values in the flag package with values we
got from Cobra.

Because we ended up parsing parts of the command line twice, each with
a different set of semantics, we ended up with bad UX in some
cases. For example:

`$ pulumi -v=10 --logflow update`

Would fail with an error message that looked nothing like normal CLI
errors, where as:

`$ pulumi -v=10 update --logflow`

Would behave as you expect. To address this, we now do two things:

- We never call flag.Parse() anymore. Wacking the flags with values we
  got from Cobra is sufficent for what we care about.

- We use a forked copy of glog which does not complain when
  flag.Parse() is not called before logging.

Fixes #301
Fixes #710
Fixes #968
2018-08-20 14:08:40 -07:00
Luke Hoban e4b0de098b
Tweak help text for pulumi stack rm -f (#1789)
Fixes #1187.
2018-08-20 12:32:58 -07:00
Justin Van Patten 05de09fcc8
Add -g shorthand for --generate-only (#1797) 2018-08-20 10:33:41 -07:00
Matt Ellis e51e159d18 Warn when pulumi is out of date
Before running commands, ask the service for version information about
the CLI and warn the user to upgrade in some cases.

Fixes #1686
2018-08-13 13:18:02 -07:00
Sean Gillespie 491bcdc602
Add a list of in-flight operations to the deployment (#1759)
* Add a list of in-flight operations to the deployment

This commit augments 'DeploymentV2' with a list of operations that are
currently in flight. This information is used by the engine to keep
track of whether or not a particular deployment is in a valid state.

The SnapshotManager is responsible for inserting and removing operations
from the in-flight operation list. When the engine registers an intent
to perform an operation, SnapshotManager inserts an Operation into this
list and saves it to the snapshot. When an operation completes, the
SnapshotManager removes it from the snapshot. From this, the engine can
infer that if it ever sees a deployment with pending operations, the
Pulumi CLI must have crashed or otherwise abnormally terminated before
seeing whether or not an operation completed successfully.

To remedy this state, this commit also adds code to 'pulumi stack
import' that clears all pending operations from a deployment, as well as
code to plan generation that will reject any deployments that have
pending operations present.

At the CLI level, if we see that we are in a state where pending
operations were in-flight when the engine died, we'll issue a
human-friendly error message that indicates which resources are in a bad
state and how to recover their stack.

* CR: Multi-line string literals, renaming in-flight -> pending

* CR: Add enum to apitype for operation type, also name status -> type for clarity

* Fix the yaml type

* Fix missed renames

* Add implementation for lifecycle_test.go

* Rebase against master
2018-08-10 21:39:59 -07:00
Justin Van Patten 9d84f2e249
Initial support for passing URLs to new and up (#1727)
* Initial support for passing URLs to `new` and `up`

This PR adds initial support for `pulumi new` using Git under the covers
to manage Pulumi templates, providing the same experience as before.

You can now also optionally pass a URL to a Git repository, e.g.
`pulumi new [<url>]`, including subdirectories within the repository,
and arbitrary branches, tags, or commits.

The following commands result in the same behavior from the user's
perspective:
 - `pulumi new javascript`
 - `pulumi new https://github.com/pulumi/templates/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/master/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/HEAD/templates/javascript`

To specify an arbitrary branch, tag, or commit:
 - `pulumi new https://github.com/pulumi/templates/tree/<branch>/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/<tag>/templates/javascript`
 - `pulumi new https://github.com/pulumi/templates/tree/<commit>/templates/javascript`

Branches and tags can include '/' separators, and `pulumi` will still
find the right subdirectory.

URLs to Gists are also supported, e.g.:
`pulumi new https://gist.github.com/justinvp/6673959ceb9d2ac5a14c6d536cb871a6`

If the specified subdirectory in the repository does not contain a
`Pulumi.yaml`, it will look for subdirectories within containing
`Pulumi.yaml` files, and prompt the user to choose a template, along the
lines of how `pulumi new` behaves when no template is specified.

The following commands result in the CLI prompting to choose a template:
 - `pulumi new`
 - `pulumi new https://github.com/pulumi/templates/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/master/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/HEAD/templates`

Of course, arbitrary branches, tags, or commits can be specified as well:
 - `pulumi new https://github.com/pulumi/templates/tree/<branch>/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/<tag>/templates`
 - `pulumi new https://github.com/pulumi/templates/tree/<commit>/templates`

This PR also includes initial support for passing URLs to `pulumi up`,
providing a streamlined way to deploy installable cloud applications
with Pulumi, without having to manage source code locally before doing
a deployment.

For example, `pulumi up https://github.com/justinvp/aws` can be used to
deploy a sample AWS app. The stack can be updated with different
versions, e.g.
`pulumi up https://github.com/justinvp/aws/tree/v2 -s <stack-to-update>`

Config values can optionally be passed via command line flags, e.g.
`pulumi up https://github.com/justinvp/aws -c aws:region=us-west-2 -c foo:bar=blah`

Gists can also be used, e.g.
`pulumi up https://gist.github.com/justinvp/62fde0463f243fcb49f5a7222e51bc76`

* Fix panic when hitting ^C from "choose template" prompt

* Add description to templates

When running `pulumi new` without specifying a template, include the template description along with the name in the "choose template" display.

```
$ pulumi new
Please choose a template:
  aws-go                  A minimal AWS Go program
  aws-javascript          A minimal AWS JavaScript program
  aws-python              A minimal AWS Python program
  aws-typescript          A minimal AWS TypeScript program
> go                      A minimal Go program
  hello-aws-javascript    A simple AWS serverless JavaScript program
  javascript              A minimal JavaScript program
  python                  A minimal Python program
  typescript              A minimal TypeScript program
```

* React to changes to the pulumi/templates repo.

We restructured the `pulumi/templates` repo to have all the templates in the root instead of in a `templates` subdirectory, so make the change here to no longer look for templates in `templates`.

This also fixes an issue around using `Depth: 1` that I found while testing this. When a named template is used, we attempt to clone or pull from the `pulumi/templates` repo to `~/.pulumi/templates`. Having it go in this well-known directory allows us to maintain previous behavior around allowing offline use of templates. If we use `Depth: 1` for the initial clone, it will fail when attempting to pull when there are updates to the remote repository. Unfortunately, there's no built-in `--unshallow` support in `go-git` and setting a larger `Depth` doesn't appear to help. There may be a workaround, but for now, if we're cloning the pulumi templates directory to `~/.pulumi/templates`, we won't use `Depth: 1`. For template URLs, we will continue to use `Depth: 1` as we clone those to a temp directory (which gets deleted) that we'll never try to update.

* List available templates in help text

* Address PR Feedback

* Don't show "Installing dependencies" message for `up`

* Fix secrets handling

When prompting for config, if the existing stack value is a secret, keep it a secret and mask the prompt. If the template says it should be secret, make it a secret.

* Fix ${PROJECT} and ${DESCRIPTION} handling for `up`

Templates used with `up` should already have a filled-in project name and description, but if it's a `new`-style template, that has `${PROJECT}` and/or `${DESCRIPTION}`, be helpful and just replace these with better values.

* Fix stack handling

Add a bool `setCurrent` param to `requireStack` to control whether the current stack should be saved in workspace settings. For the `up <url>` case, we don't want to save. Also, split the `up` code into two separate functions: one for the `up <url>` case and another for the normal `up` case where you have workspace in your current directory. While we may be able to combine them back into a single function, right now it's a bit cleaner being separate, even with some small amount of duplication.

* Fix panic due to nil crypter

Lazily get the crypter only if needed inside `promptForConfig`.

* Embellish comment

* Harden isPreconfiguredEmptyStack check

Fix the code to check to make sure the URL specified on the command line matches the URL stored in the `pulumi:template` config value, and that the rest of the config from the stack satisfies the config requirements of the template.
2018-08-10 18:08:16 -07:00
Sean Gillespie a09d9ba035
Default to a parallelism fanout of 10 (#1756)
* Default to a parallelism fanout of 10

* Add dependsOn to double_pending_delete tests to force serialization
2018-08-10 14:16:59 -07:00
Matt Ellis afa27cf52c Consider the key name as part of secret detection
Many non-secrets are actually pretty high entropy, at least according
to `zxcvbn`. For example: "Hello, Pulumi Timers!" would actually cause
us to say: "this looks like a secret", much in the same way that
"correct horse battery staple" is high entropy according to that
package.

In addition to considering the entropy of the value, gosec (the linter
we copied this logic from) also considers the name of the value that
is being assigned to.

In that spirit, let's only do this check when the config key name
actually looks like it is something we'd want to warn the user about.

We use the same regular expression as `gosec`.

Fixes #1732
2018-08-09 19:10:14 -07:00
Chris Smith 2d93bb8693
Remove PPC-specific codepaths (#1741) 2018-08-08 19:26:51 -07:00
Chris Smith 83bdc60f81
Add a few more CI env vars (#1738) 2018-08-08 14:12:47 -07:00
Matt Ellis d5e3e8fe9e Move git related warnings back to glog statements
In #1341 we promoted a class of errors in fetching git metadata from
glog messages to warnings printed by the CLI. On the asumption that
when we got warnings here they would be actionable.

The major impact here is that when you are working in a repository
which does not have a remote set to GitHub (common if you have just
`git init`'d a repository for a new project) or you don't call your
remote `origin` or you use some other code provider, we end up
printing a warning during every update.

This change does two things:

- Restructure the way we detect metadata to attempt to make progress
  when it can. We bias towards returning some metadata even when we
  can't determine the complete set of metadata.
- Use a multierror to track all the underlying failures from our
  metadata probing and move it back to a glog message.

Overall, this feels like the right balance to me. We are retaining the
rich diagnostics information for when things go wrong, but we aren't
warning about common cases.

We could, of course, try to tighten our huristics (e.g. don't warn if
we can't find a GitHub remote but do warn if we can't compute if the
worktree is dirty) but it feels like that will be a game of
whack-a-mole over time and when warnings do fire its unlikely they
will be actionable.

Fixes #1443
2018-08-07 18:10:34 -07:00
Pat Gavlin a222705143
Implement first-class providers. (#1695)
### First-Class Providers
These changes implement support for first-class providers. First-class
providers are provider plugins that are exposed as resources via the
Pulumi programming model so that they may be explicitly and multiply
instantiated. Each instance of a provider resource may be configured
differently, and configuration parameters may be source from the
outputs of other resources.

### Provider Plugin Changes
In order to accommodate the need to verify and diff provider
configuration and configure providers without complete configuration
information, these changes adjust the high-level provider plugin
interface. Two new methods for validating a provider's configuration
and diffing changes to the same have been added (`CheckConfig` and
`DiffConfig`, respectively), and the type of the configuration bag
accepted by `Configure` has been changed to a `PropertyMap`.

These changes have not yet been reflected in the provider plugin gRPC
interface. We will do this in a set of follow-up changes. Until then,
these methods are implemented by adapters:
- `CheckConfig` validates that all configuration parameters are string
  or unknown properties. This is necessary because existing plugins
  only accept string-typed configuration values.
- `DiffConfig` either returns "never replace" if all configuration
  values are known or "must replace" if any configuration value is
  unknown. The justification for this behavior is given
  [here](https://github.com/pulumi/pulumi/pull/1695/files#diff-a6cd5c7f337665f5bb22e92ca5f07537R106)
- `Configure` converts the config bag to a legacy config map and
  configures the provider plugin if all config values are known. If any
  config value is unknown, the underlying plugin is not configured and
  the provider may only perform `Check`, `Read`, and `Invoke`, all of
  which return empty results. We justify this behavior becuase it is
  only possible during a preview and provides the best experience we
  can manage with the existing gRPC interface.

### Resource Model Changes
Providers are now exposed as resources that participate in a stack's
dependency graph. Like other resources, they are explicitly created,
may have multiple instances, and may have dependencies on other
resources. Providers are referred to using provider references, which
are a combination of the provider's URN and its ID. This design
addresses the need during a preview to refer to providers that have not
yet been physically created and therefore have no ID.

All custom resources that are not themselves providers must specify a
single provider via a provider reference. The named provider will be
used to manage that resource's CRUD operations. If a resource's
provider reference changes, the resource must be replaced. Though its
URN is not present in the resource's dependency list, the provider
should be treated as a dependency of the resource when topologically
sorting the dependency graph.

Finally, `Invoke` operations must now specify a provider to use for the
invocation via a provider reference.

### Engine Changes
First-class providers support requires a few changes to the engine:
- The engine must have some way to map from provider references to
  provider plugins. It must be possible to add providers from a stack's
  checkpoint to this map and to register new/updated providers during
  the execution of a plan in response to CRUD operations on provider
  resources.
- In order to support updating existing stacks using existing Pulumi
  programs that may not explicitly instantiate providers, the engine
  must be able to manage the "default" providers for each package
  referenced by a checkpoint or Pulumi program. The configuration for
  a "default" provider is taken from the stack's configuration data.

The former need is addressed by adding a provider registry type that is
responsible for managing all of the plugins required by a plan. In
addition to loading plugins froma checkpoint and providing the ability
to map from a provider reference to a provider plugin, this type serves
as the provider plugin for providers themselves (i.e. it is the
"provider provider").

The latter need is solved via two relatively self-contained changes to
plan setup and the eval source.

During plan setup, the old checkpoint is scanned for custom resources
that do not have a provider reference in order to compute the set of
packages that require a default provider. Once this set has been
computed, the required default provider definitions are conjured and
prepended to the checkpoint's resource list. Each resource that
requires a default provider is then updated to refer to the default
provider for its package.

While an eval source is running, each custom resource registration,
resource read, and invoke that does not name a provider is trapped
before being returned by the source iterator. If no default provider
for the appropriate package has been registered, the eval source
synthesizes an appropriate registration, waits for it to complete, and
records the registered provider's reference. This reference is injected
into the original request, which is then processed as usual. If a
default provider was already registered, the recorded reference is
used and no new registration occurs.

### SDK Changes
These changes only expose first-class providers from the Node.JS SDK.
- A new abstract class, `ProviderResource`, can be subclassed and used
  to instantiate first-class providers.
- A new field in `ResourceOptions`, `provider`, can be used to supply
  a particular provider instance to manage a `CustomResource`'s CRUD
  operations.
- A new type, `InvokeOptions`, can be used to specify options that
  control the behavior of a call to `pulumi.runtime.invoke`. This type
  includes a `provider` field that is analogous to
  `ResourceOptions.provider`.
2018-08-06 17:50:29 -07:00
Matt Ellis ce5eaa8343 Support TypeScript in a more first-class way
This change lets us set runtime specific options in Pulumi.yaml, which
will flow as arguments to the language hosts. We then teach the nodejs
host that when the `typescript` is set to `true` that it should load
ts-node before calling into user code. This allows using typescript
natively without an explicit compile step outside of Pulumi.

This works even when a tsconfig.json file is not present in the
application and should provide a nicer inner loop for folks writing
typescript (I'm pretty sure everyone has run into the "but I fixed
that bug!  Why isn't it getting picked up?  Oh, I forgot to run tsc"
problem.

Fixes #958
2018-08-06 14:00:58 -07:00
Sean Gillespie 48aa5e73f8
Save resources obtained from ".get" in the snapshot (#1654)
* Protobuf changes to record dependencies for read resources

* Add a number of tests for read resources, especially around replacement

* Place read resources in the snapshot with "external" bit set

Fixes pulumi/pulumi#1521. This commit introduces two new step ops: Read
and ReadReplacement. The engine generates Read and ReadReplacement steps
when servicing ReadResource RPC calls from the language host.

* Fix an omission of OpReadReplace from the step list

* Rebase against master

* Transition to use V2 Resources by default

* Add a semantic "relinquish" operation to the engine

If the engine observes that a resource is read and also that the
resource exists in the snapshot as a non-external resource, it will not
delete the resource if the IDs of the old and new resources match.

* Typo fix

* CR: add missing comments, DeserializeDeployment -> DeserializeDeploymentV2, ID check
2018-08-03 14:06:00 -07:00
Joe Duffy b2c91f7c24
Detect secret-like config (#1689)
Previously, we would unconditionally warn anytime you added a non-secret
config:

    $ pulumi config set aws:region us-west-2
    warning: saved config key '%s' value '%s' as plaintext;
        re-run with --secret to encrypt the value instead.
        Use --plaintext to avoid this warning

This was particularly annoying, since it is very common to store
non-secret config. For instance, the AWS region. And it was easy to tune
out because it wasn't actually warning about anything interesting.

This change, which resolves pulumi/pulumi#570, uses an approach similar
to Go's gas linter, to detect high entropy values, and issue an error.
This ensures that we only make noise on things we suspect are actually
secrets being stored in plaintext, and forces the user to pass
--plaintext. For instance, the common case issues no errors:

    $ pulumi config set aws:region us-west-2

And in the event that you store something that is secret-like:

    $ pulumi config set aws:region nq8r4B4xslzrtj0a3
    error: config value 'nq8r4B4xslzrtj0a3' looks like a secret;
        rerun with --secret to encrypt it, or --plaintext if you meant
        to store in plaintext

To suppress this, simply pass --secret (to encrypt) or --plaintext (to
override the warning).
2018-08-02 04:14:16 -07:00
Chris Smith 7aa91d69e0
Add optional CI properties to environment metadata (#1678)
* Add optional CI properties to environment metadata

* Address PR feedback
2018-07-31 21:38:07 -07:00
Joe Duffy 76eea4863a
Prefer "up" over "update" (#1672) 2018-07-31 10:22:16 -07:00
Joe Duffy f58ea68a7d
Make minor improvements to pulumi new (#1659)
After running `pulumi new`, we print a message to let the user
know the project has been created, along with next steps to actually
perform a deployment. It's easy for this to get lost among the rest
of the output, however. So, wordsmith it a little, and add some color,
to make it pop a little bit more.

Also add SuggestFor annotations so that `init` and `create` direct
you to run the `new` command (I often accidentally type `init`).
2018-07-26 15:49:12 -07:00
Justin Van Patten db6f99055d
Suppress package restore output unless it fails (#1642)
Change `pulumi new` to no longer output STDOUT and STDERR by default. Instead, only output STDOUT and STDERR if the restore command fails.
2018-07-18 13:24:58 -07:00
Justin Van Patten 4e43dec05c
Show all templates when running pulumi new (#1637)
Previously, it would only show the first 7 templates (we currently have 9 total), and you'd have to move the cursor down to the bottom to show the last 2.
2018-07-16 16:08:56 -07:00
CyrusNajmabadi 3ca56d1e82
Support the NO_COLOR env variable to suppres any colored output. (#1594)
Also, make --color a viable command option for any pulumi command.
2018-07-06 21:30:00 -07:00
Matt Ellis 5dd2f10993 Support -s in stack {export, graph, import, output}
Instead of needing you to first select the current stack to use any of
these commands, allow passing `-s <stack-name>` or `--stack
<stack-name>` to say what stack you want to operate on.

These commands still require a `Pulumi.yaml` file to be present, which
is not ideal, but would require a larger refactoring to fix. That
refactoring will happen as part of #1556.

Fixes #1370
2018-07-02 11:42:31 -07:00
Matt Ellis 2b471bda70 Add pulumi whoami
It's often helpful to understand the user the CLI thinks you are
logged in as, so let's add a command that does that.

Fixes #1507
2018-06-28 10:33:59 -07:00
Matt Ellis cfa58a4b57 Don't require PULUMI_DEBUG_COMMANDS to be set to use local backend
This was an artifact of history. Since we'll be supporting the local
backend, we don't need yet another flag guarding it (you already have
to opt in with -c local:// which is enough of a hoop).
2018-06-25 18:30:26 -07:00
Justin Van Patten 2df35f4381
Improve misleading pulumi new summary message (#1571)
Mention running `cd` (if needed) before `pulumi update`.
2018-06-25 16:26:29 -07:00
James Nugent a1e2da3b76 build: Use canonical import path for mobytime
This change fixes the following warning issued by using `go get` with
the Pulumi repository:

package github.com/moby/moby/api/types/time: code in directory
/Users/James/Code/go/src/github.com/moby/moby/api/types/time expects
import "github.com/docker/docker/api/types/time"

Moby defines canonical import paths [1] reflecting the lineage back to
the `docker/docker` repository.

[1]: https://github.com/moby/moby/blob/master/api/types/time/duration_convert.go#L1
2018-06-22 11:24:29 -07:00
Pat Gavlin dc0c604ae7
Enable fork builds. (#1495)
If we're building in CI and do not have an access token, skip any
lifecycle tests.
2018-06-11 16:01:04 -07:00
Matt Ellis 721bc9ccc6 s/docs.pulumi.com/pulumi.io/g
The docs website is moving to https://pulumi.io from
https://docs.pulumi.com
2018-06-11 15:57:47 -06:00
Justin Van Patten 6a11d049b7
Add optional --dir flag to pulumi new (#1459)
Usage:

```
pulumi new <template> --dir folderName
```

Used to specify the directory where to place the generated project.
If the directory does not exist, it will be created.
2018-06-04 13:33:58 -07:00
Joe Duffy 16fefda65f
Make the stack graph command always available (#1452)
I hadn't realized this was added as a debug-only command.  No need to
hide this, it's working and generally useful.
2018-06-02 18:13:31 -07:00
Matt Ellis 56eded0673 Revert "Pass --no-audit to npm install during pulumi new"
This reverts commit d11acf5208.
2018-05-30 15:42:10 -07:00
Sean Gillespie 924c49d7e0
Fail fast when attempting to load a too-new or too-old deployment (#1382)
* Error when loading a deployment that is not a version that the CLI understands

* Add a test for 'pulumi stack import' on a badly-versioned deployment

* Move current deployment version to 'apitype'

* Rebase against master

* CR: emit CLI-friendly error message at the two points outside of the engine calling 'DeserializeDeployment'
2018-05-25 13:29:59 -07:00
Matt Ellis 9a8f8881c0 Show manifest information for stacks
This change supports displaying manifest information for a stack and
changes the way we handle Snapshots in our backend.

Previously, every call to GetStack would synthesize a Snapshot by
taking the set of resources returned from the
`/api/stacks/<owner>/<name>` endpoint, combined with an empty
manfiest (since the service was not returning the manifest).

This wasn't great for two reasons:

1. We didn't have manifest information, so we couldn't display any of
   its information (most important the last updated time).

2. This strategy required that the service return all the resources
   for a stack anytime GetStack was called. While the CLI did not
   often need this detailed information the fact that we forced the
   Service to produce it (which in the case of stack managed PPC would
   require the service to talk to yet another service) creates a bunch
   of work that we end up ignoring.

I've refactored the code such that `backend.Stack`'s `Snapshot()` method
now lazily requests the information from the service such that we can
construct a `Snapshot()` on demand and only pay the cost when we
actually need it.

I think making more of this stuff lazy is the long term direction we
want to follow.

Unfortunately, right now, it means in cases where we do need this data
we end up fetching it twice. The service does it once when we call
GetStack and then we do it again when we actually need to get at the
Snapshot.  However, once we land this change, we can update the
service to no longer return resources on the apistack.Stack type. The
CLI no longer needs this property.  We'll likely want to continue in a
direction where `apistack.Stack` can be created quickly by the
service (without expensive database queries or fetching remote
resources) and just add additional endpoints that let us get at the
specific information we want in the specific cases when we want it
instead of forcing us to return a bunch of data that we often ignore.

Fixes pulumi/pulumi-service#371
2018-05-23 16:43:34 -07:00
Pat Gavlin 37a3317623
Put local backend support under PULUMI_DEBUG_COMMANDS. (#1408)
Just what it says on the tin.

Fixes #1398.
2018-05-22 17:02:45 -07:00
joeduffy 5967259795 Add license headers 2018-05-22 15:02:47 -07:00
Matt Ellis 0732b05c5d Remove pulumi init
`pulumi init` was part of our old identity model with the service and
is no longer used. We can now delete this code.

Fixes #1241
2018-05-22 13:37:08 -07:00
Matt Ellis d11acf5208 Pass --no-audit to npm install during pulumi new
While we wait for upstream to fix the security issue, we'll just pass
`--no-audit` to `npm install` when creating a new project. Since the
warning is against an indirect dependency of @pulumi/pulumi, we can't
actually address the issue ourselves.

Mitigates #1350
2018-05-18 15:14:10 -07:00
Pat Gavlin 64d90b263d
Merge pull request #1375 from pulumi/ResourceChangesFromBackend
Validate empty previews and updates in tests.
2018-05-16 10:44:48 -07:00
Pat Gavlin 52424f5d42 PR feedback. 2018-05-16 10:22:09 -07:00
Pat Gavlin 79ec574660 Add an --expect-no-changes flag to {preview, update}.
When this flag is specified, the CLI will return an error if `preview`
proposes changes or `update` performs changes.
2018-05-15 17:44:35 -07:00
Pat Gavlin e3020e820b Expose change summaries from the backend.
This is a smallish refactoring that exposes the resource change
summaries reported by the engine from the relevant backend methods.
2018-05-15 17:44:35 -07:00
CyrusNajmabadi 72e00810c4
Filter the logs we emit to glog so that we don't leak out secrets. (#1371) 2018-05-15 15:28:00 -07:00
Joe Duffy 369c619ab9
Skip loading language plugins when not needed (#1367)
In pulumi/pulumi#1356, we observed that we can fail during a destroy
because we attempt to load the language plugin, which now eagerly looks
for the @pulumi/pulumi package.

This is also blocking ingestion of the latest engine bits into the PPC.

It turns out that for destroy (and refresh), we have no need for the
language plugin.  So, let's skip loading it when appropriate.
2018-05-14 20:32:53 -07:00
Pat Gavlin 782a869765
Add support for passing tracing headers. (#1360)
These changes add support for adding a tracing header to API requests
made to the Pulumi service. Setting the `PULUMI_TRACING_HEADER`
environment variable or enabling debug commands and passing the
`--tracing-header` will change the value sent in this header. Setting
this value to `1` will request that the service enable distributed
tracing for all requests made by a particular CLI invocation.
2018-05-14 13:44:44 -07:00
Matt Ellis 6845f9ed20 Add pulumi config refresh to fetch most recent configuration
The newly added `pulumi config refresh` updates your local copy of the
Pulumi.<stack-name>.yaml file to have the same configuration as the
most recent deployment in the cloud.

This can be used in a varirty of ways. One place we plan to use it is
in automation to clean up "leaked" stacks we have in CI. With the
changes you'll now be able to do the following:

```
$ cd $(mktemp -d)
$ echo -e "name: who-cares\nruntime: nodejs" > Pulumi.yaml
$ pulumi stack select <leaked-stack-name>
$ pulumi config refresh -f
$ pulumi destroy --force
```

Having a simpler gesture for the above is something we'll want to do
long term (we should be able to support `pulumi destory <stack-name>`
from a completely empty folder, today you need a Pulumi.yaml file
present, even if the contents don't matter).

But this gets us a little closer to where we want to be and introduces
a helpful primitive in the system.

Contributes to #814
2018-05-14 10:28:42 -07:00
Pat Gavlin 97e38bddc8 Enable distributed tracing.
These changes add support for injecting client tracing spans into HTTP
requests to the Pulumi API. The server can then rematerialize these span
references and attach its own spans for distributed tracing.
2018-05-09 11:43:09 -07:00
Joe Duffy 131daae22d
Merge pull request #1341 from pulumi/git_committer_author_info
Capture Git committer and author info
2018-05-08 11:35:16 -07:00
Justin Van Patten e1edd1e88d
Make the default pulumi new project description empty (#1339)
Previously, we'd default to "A Pulumi project.", which isn't a helpful
description for any real project.
2018-05-08 10:46:39 -07:00
joeduffy a5c70ac7f4 Change Git failures to CLI warnings
This change moves Git failures from glog.Warnings, which we don't
really pay attention, to true CLI warnings.

This will ensure we at least get bug reports in the event that this
fails on some user machine out in the wild.  They are still non-fatal,
of course, since such a failure needn't prevent an update from happening.
2018-05-08 10:37:42 -07:00
joeduffy b6db2c5763 Capture Git committer and author info
This change captures the Git committer and author's login and email
addresses, so that we can display them prominently in the service.  At
the moment, we only attribute updates to the identity that performed the
update which, in CI scenarios, is often always the same person for an
organization.  This makes Pulumi look like a needlessly lonely place.
2018-05-08 10:31:11 -07:00
Joe Duffy 24b350ea40
Support -y as shorthand for --yes (#1340) 2018-05-08 09:55:08 -07:00
Pat Gavlin 97ace29ab1
Begin tracing Pulumi API calls. (#1330)
These changes enable tracing of Pulumi API calls.

The span with which to associate an API call is passed via a
`context.Context` parameter. This required plumbing a
`context.Context` parameter through a rather large number of APIs,
especially in the backend.

In general, all API calls are associated with a new root span that
exists for essentially the entire lifetime of an invocation of the
Pulumi CLI. There were a few places where the plumbing got a bit hairier
than I was willing to address with these changes; I've used
`context.Background()` in these instances. API calls that receive this
context will create new root spans, but will still be traced.
2018-05-07 18:23:03 -07:00
Justin Van Patten d1b49d25f8
pulumi new improvements (#1307)
* Initialize a new stack as part of `pulumi new`
* Prompt for values with defaults preselected
* Install dependencies
* Prompt for default config values
2018-05-07 15:31:27 -07:00
joeduffy 7c7f6d3ed7 Bring back preview, swizzle some flags
This changes the CLI interface in a few ways:

* `pulumi preview` is back!  The alternative of saying
  `pulumi update --preview` just felt awkward, and it's a common
  operation to want to perform.  Let's just make it work.

* There are two flags consistent across all update commands,
  `update`, `refresh`, and `destroy`:

    - `--skip-preview` will skip the preview step.  Note that this
      does *not* skip the prompt to confirm that you'd like to proceed.
      Indeed, it will still prompt, with a little warning text about
      the fact that the preview has been skipped.

    * `--yes` will auto-approve the updates.

This lands us in a simpler and more intuitive spot for common scenarios.
2018-05-06 13:55:39 -07:00