Commit graph

279 commits

Author SHA1 Message Date
Evan Boyle 5ae4149af5
Add support for "go run" style execution (#3503) 2019-11-14 09:25:55 -08:00
Pat Gavlin bd2de540b2 Update the CHANGELOG for v1.5.2 2019-11-13 09:31:37 -08:00
Pat Gavlin a7f61a59b0
Reimplement Output for Go. (#3496)
- Use a mutex + condition variable instead of a channel for
  synchronizaiton in order to allow multiple calls to resolve/reject
- Properly handle outputs that are resolved to other outputs, especially
  if those outputs are not of exactly type Output
- Remove the Value() methods that allowed prompt access to output values
- Add variants of `Apply` that take a context parameter
- Ensure that resource outputs properly incorporate their resource as
  a dependency
- Make `Output` a plain struct. Uninitialized outputs will be treated as
   resolved and unknown. This makes conversions between output
   types more ergonomic.

Contributes to #3492.
2019-11-12 14:20:06 -08:00
Pat Gavlin 137fd54f1c
Propagate inputs to outputs during preview. (#3327)
These changes restore a more-correct version of the behavior that was
disabled with #3014. The original implementation of this behavior was
done in the SDKs, which do not have access to the complete inputs for a
resource (in particular, default values filled in by the provider during
`Check` are not exposed to the SDK). This lack of information meant that
the resolved output values could disagree with the typings present in
a provider SDK. Exacerbating this problem was the fact that unknown
values were dropped entirely, causing `undefined` values to appear in
unexpected places.

By doing this in the engine and allowing unknown values to be
represented in a first-class manner in the SDK, we can attack both of
these issues.

Although this behavior is not _strictly_ consistent with respect to the
resource model--in an update, a resource's output properties will come
from its provider and may differ from its input properties--this
behavior was present in the product for a fairly long time without
significant issues. In the future, we may be able to improve the
accuracy of resource outputs during a preview by allowing the provider
to dry-run CRUD operations and return partially-known values where
possible.

These changes also introduce new APIs in the Node and Python SDKs
that work with unknown values in a first-class fashion:
- A new parameter to the `apply` function that indicates that the
  callback should be run even if the result of the apply contains
  unknown values
- `containsUnknowns` and `isUnknown`, which return true if a value
  either contains nested unknown values or is exactly an unknown value
- The `Unknown` type, which represents unknown values

The primary use case for these APIs is to allow nested, properties with
known values to be accessed via the lifted property accessor even when
the containing property is not fully know. A common example of this
pattern is the `metadata.name` property of a Kubernetes `Namespace`
object: while other properties of the `metadata` bag may be unknown,
`name` is often known. These APIs allow `ns.metadata.name` to return a
known value in this case.

In order to avoid exposing downlevel SDKs to unknown values--a change
which could break user code by exposing it to unexpected values--a
language SDK must indicate whether or not it supports first-class
unknown values as part of each `RegisterResourceRequest`.

These changes also allow us to avoid breaking user code with the new
behavior introduced by the prior commit.

Fixes #3190.
2019-11-11 12:09:34 -08:00
Luke Hoban ac929028ab
Update CHANGELOG.md 2019-11-09 08:24:17 -08:00
Justin Van Patten 05cb51421d
pulumi policy publish: Use the name of the Policy Pack from code (#3459) 2019-11-07 09:24:34 -08:00
Pat Gavlin 69e04367a5 Update the CHANGELOG for 1.5.1. 2019-11-07 07:36:50 -08:00
Pat Gavlin 3c832c33f5 Update the CHANGELOG for 1.5.0 2019-11-06 12:57:36 -08:00
Luke Hoban 25206c5ea8 Add an experimental pulumi watch command (#3391)
Adds a new experimental `pulumi watch` CLI command which can be used for inner loop development on a Pulumi stack.  This command is only available currently via `PULUMI_EXPERIMENTAL=true` while in active development.

The `watch` command does the following:
1. Watches the workspace (the tree rooted at the `Pulumi.yaml` file) for changes
2. Triggers an `update` to the stack whenever there is a change
3. Streams output containing summaries of key update events as well as logs from any resources under management into a combined CLI output

Part of https://github.com/pulumi/pulumi/issues/3448.

The PULUMI_EXPERIMENTAL flag also makes`query` and `policy` available.
2019-11-06 12:56:29 -08:00
Joe Duffy 9b1df6f9e6
Run the version check in parallel (#3441)
I noticed that we block startup on performing the version check.
Although we cache the latest version from the server for 24 hours,
this check also runs the `brew --prefix pulumi` command which
(at least for me) takes between 0.5-1s on average. Thus, running it
in parallel, which requires no shared state, saves us that amount
of time in the end to end execution time. Notably, this shortens the
amount of time from command start to the first "previewing..." message.

This does change the user experience: rather than reporting the
new version up front, we report it at the end after running the
requested command (both on success and failure). This is what I'd
have assumed we'd want anyway, and what many other tools do, but
it's entirely reasonable if folks object to the change in UX.
2019-11-06 13:44:27 -05:00
Evan Boyle 9506b69c8b
error instead of panic when different resources use the same alias (#3457) 2019-11-06 08:49:13 -08:00
Praneet Loke 1fe3f0f46e
Use the update access token for renew_lease calls instead of user access token (#3348)
* Change RenewUpdateLease to use the update access token as the Bearer token.

* Deprecate the Token property in RenewUpdateLeaseRequest.
2019-11-05 13:32:31 -08:00
Alex Clemmer 038f920dc3 Make streamInvoke gracefully-cancellable from SDKs
The @pulumi/pulumi TypScript SDK exposes `streamInvoke`, which returns a
(potentially infinite) stream of responses. This currently is _assumed_
to be infinite, in that there is no way to signal cancellation, and
prevents Pulumi from being able to clean up when we're finished using
the results of the `streamInvoke`.

This commit will introduce a `StreamInvokeResult` type, which is an
`AsyncIterable` that also exposes a `cancel` function, whih does just
this.

Use it like this:

    // `streamInvoke` to retrieve all updates to any `Deployment`, enumerate 0
    // updates from the stream, then `cancel` giving the Kubernetes provider to
    // clean up and close gracefully.
    const deployments = await streamInvoke("kubernetes:kubernetes:watch", {
        group: "apps", version: "v1", kind: "Deployment",
        break;
    });
    deployments.cancel();
2019-11-05 10:47:48 -08:00
Pat Gavlin 29049ecaf3 Update the CHANGELOG for 1.4.1 2019-11-01 14:17:55 -07:00
Justin Van Patten c08714ffb4
Support lists and maps in config (#3342)
This change adds support for lists and maps in config. We now allow
lists/maps (and nested structures) in `Pulumi.<stack>.yaml` (or
`Pulumi.<stack>.json`; yes, we currently support that).

For example:

```yaml
config:
  proj:blah:
  - a
  - b
  - c
  proj:hello: world
  proj:outer:
    inner: value
  proj:servers:
  - port: 80
```

While such structures could be specified in the `.yaml` file manually,
we support setting values in maps/lists from the command line.

As always, you can specify single values with:

```shell
$ pulumi config set hello world
```

Which results in the following YAML:

```yaml
proj:hello world
```

And single value secrets via:

```shell
$ pulumi config set --secret token shhh
```

Which results in the following YAML:

```yaml
proj:token:
  secure: v1:VZAhuroR69FkEPTk:isKafsoZVMWA9pQayGzbWNynww==
```

Values in a list can be set from the command line using the new
`--path` flag, which indicates the config key contains a path to a
property in a map or list:

```shell
$ pulumi config set --path names[0] a
$ pulumi config set --path names[1] b
$ pulumi config set --path names[2] c
```

Which results in:

```yaml
proj:names
- a
- b
- c
```

Values can be obtained similarly:

```shell
$ pulumi config get --path names[1]
b
```

Or setting values in a map:

```shell
$ pulumi config set --path outer.inner value
```

Which results in:

```yaml
proj:outer:
  inner: value
```

Of course, setting values in nested structures is supported:

```shell
$ pulumi config set --path servers[0].port 80
```

Which results in:

```yaml
proj:servers:
- port: 80
```

If you want to include a period in the name of a property, it can be
specified as:

```
$ pulumi config set --path 'nested["foo.bar"]' baz
```

Which results in:

```yaml
proj:nested:
  foo.bar: baz
```

Examples of valid paths:

- root
- root.nested
- 'root["nested"]'
- root.double.nest
- 'root["double"].nest'
- 'root["double"]["nest"]'
- root.array[0]
- root.array[100]
- root.array[0].nested
- root.array[0][1].nested
- root.nested.array[0].double[1]
- 'root["key with \"escaped\" quotes"]'
- 'root["key with a ."]'
- '["root key with \"escaped\" quotes"].nested'
- '["root key with a ."][100]'

Note: paths that contain quotes can be surrounded by single quotes.

When setting values with `--path`, if the value is `"false"` or
`"true"`, it will be saved as the boolean value, and if it is
convertible to an integer, it will be saved as an integer.

Secure values are supported in lists/maps as well:

```shell
$ pulumi config set --path --secret tokens[0] shh
```

Will result in:

```yaml
proj:tokens:
- secure: v1:wpZRCe36sFg1RxwG:WzPeQrCn4n+m4Ks8ps15MxvFXg==
```

Note: maps of length 1 with a key of “secure” and string value are
reserved for storing secret values. Attempting to create such a value
manually will result in an error:

```shell
$ pulumi config set --path parent.secure foo
error: "secure" key in maps of length 1 are reserved
```

**Accessing config values from the command line with JSON**

```shell
$ pulumi config --json
```

Will output:

```json
{
  "proj:hello": {
    "value": "world",
    "secret": false,
    "object": false
  },
  "proj:names": {
    "value": "[\"a\",\"b\",\"c\"]",
    "secret": false,
    "object": true,
    "objectValue": [
      "a",
      "b",
      "c"
    ]
  },
  "proj:nested": {
    "value": "{\"foo.bar\":\"baz\"}",
    "secret": false,
    "object": true,
    "objectValue": {
      "foo.bar": "baz"
    }
  },
  "proj:outer": {
    "value": "{\"inner\":\"value\"}",
    "secret": false,
    "object": true,
    "objectValue": {
      "inner": "value"
    }
  },
  "proj:servers": {
    "value": "[{\"port\":80}]",
    "secret": false,
    "object": true,
    "objectValue": [
      {
        "port": 80
      }
    ]
  },
  "proj:token": {
    "secret": true,
    "object": false
  },
  "proj:tokens": {
    "secret": true,
    "object": true
  }
}
```

If the value is a map or list, `"object"` will be `true`. `"value"` will
contain the object as serialized JSON and a new `"objectValue"` property
will be available containing the value of the object.

If the object contains any secret values, `"secret"` will be `true`, and
just like with scalar values, the value will not be outputted unless
`--show-secrets` is specified.

**Accessing config values from Pulumi programs**

Map/list values are available to Pulumi programs as serialized JSON, so
the existing
`getObject`/`requireObject`/`getSecretObject`/`requireSecretObject`
functions can be used to retrieve such values, e.g.:

```typescript
import * as pulumi from "@pulumi/pulumi";

interface Server {
    port: number;
}

const config = new pulumi.Config();

const names = config.requireObject<string[]>("names");
for (const n of names) {
    console.log(n);
}

const servers = config.requireObject<Server[]>("servers");
for (const s of servers) {
    console.log(s.port);
}
```
2019-11-01 13:41:27 -07:00
Pat Gavlin d56dedd0f6
Print a tree view in pulumi stack. (#3430)
Just what it says on the tin.
2019-10-31 08:37:03 -07:00
Pat Gavlin 23a84df254
Add targeted replaces to update. (#3418)
Allow the user to specify a set of resources to replace via the
`--replace` flag on the CLI. This can be combined with `--target` to
replace a specific set of resources without changing any other
resources. `--target-replace` is shorthand for `--replace urn --target urn`.

Fixes #2643.
2019-10-30 17:16:55 -07:00
Azamat c5bd24aa30 Add helm to pulumi/pulumi dockerhub container (#3294) 2019-10-30 15:30:35 -06:00
Pat Gavlin c383810bf8
Omit unknowns in resources in stack outputs during preview. (#3427)
If a stack output includes a `Resource`, we will as of a recent change
always show the output diff, but this diff will potentially include
unknowns, leading to spurious output like:

```
+ namePrefix : output<string>
```

These changes supress these diffs by adding a special key to the POJO
we generate for resources *during preview only* that indicates that the
POJO represents a Pulumi resource, then stripping all adds of unknown
values from diffs for objects marked with that key.

Fixes #3314.
2019-10-30 11:36:03 -07:00
Pat Gavlin 8fdb2ab20b
Verify statefile integrity during import. (#3422)
Issue an error if the statefile fails to verify unless the `--force`
flag was passed.

Fixes #3222.
2019-10-29 14:54:55 -07:00
Pat Gavlin 3d35eebb58
Fix another colorizer bug. (#3417)
If a maximum length was specified and the string did not end in a
colorization directive, the maximum length was not respected.

Fixes #3374.
2019-10-29 10:55:30 -07:00
CyrusNajmabadi 394c91d7f6
Add **preview** .NET Core support for pulumi. (#3399) 2019-10-25 16:59:50 -07:00
Pat Gavlin 06d4dde889 Update the CHANGELOG for v1.4.0 2019-10-24 10:11:44 -07:00
Pat Gavlin 76a0079641
Fix two colorization issues. (#3385)
- The length of the text content (i.e. the content of a colorized string
  that is not control sequences) was not being correctly tracked. This
  caused the "status" column of the progress display to overflow.
- Colorization was unconditionally disabled on Windows. When we were
  using loreley, we had set the global colorization flag s.t.
  colorization on Windows _should_ have been disabled, but we overrode
  this flag each time we actually colorized anything.

Fixes #3378.
2019-10-21 16:05:45 -07:00
Ryan Campbell 665b4caa89 Update python FileAsset to accept os.PathLike in addition to str. (#3368)
This should fix #2896.
2019-10-18 14:31:59 -07:00
Pat Gavlin fa20d88e12 Update the CHANGELOG for 1.3.4 2019-10-18 13:47:35 -07:00
Pat Gavlin 1ae6629d81 Prepare the CHANGELOG for v1.3.3 2019-10-17 15:10:30 -07:00
CyrusNajmabadi 8272a48447
Update changelist. 2019-10-16 11:58:11 -07:00
CyrusNajmabadi 91addf2feb
New approach to move us to using deasync as little as possible (and with as little impact to users as possible). (#3325) 2019-10-14 22:08:06 -07:00
Luke Hoban 893e51d0ce
Add Python resource transformations support (#3319)
Adds Python support for resource transformations aligned with the existing NodeJS support in #3174.

This PR also moves processing of transformations to earlier in the resource construction process (for both NodeJS and Python) to ensure that invariants established in the constructor cannot be violated by transformations. This change can technically be a breaking change, but given that (a) the transformations features was just released in 1.3.0 and (b) the cases where this is a breaking change are uncommon and unlikely to have been reliable anyway - it feels like a change we should make now.

Fixes #3283.
2019-10-14 19:35:00 -05:00
Pat Gavlin 97803a6591 Prepare the CHANGELOG for 1.3.1. 2019-10-10 10:33:50 -07:00
Pat Gavlin 834e583c95
Revert "Propagate inputs to outputs during preview. (#3245)" (#3324)
This reverts commit 80504bf0bc.
2019-10-10 10:33:05 -07:00
Pat Gavlin 7778d7ae84 Prepare the CHANGELOG for 1.3.0. 2019-10-09 11:50:21 -07:00
Mikhail Shilkov 69743fe2bf Make the path to .pulumi folder configurable with an ENV variable (#3300)
Introduces `PULUMI_HOME` environment variable which points to a path to the path to `.pulumi` folder. Defaults to `<user's home dir> + ".pulumi"` if not specified.

Fixes #2966. In addition to plugins, it "moves" the credentials file, templates, workspaces.

`bin` folder is intact: to move it, we need to adjust all installation scripts to respect `PULUMI_HOME` and put executables in the proper `bin` folder.
2019-10-08 15:01:46 -07:00
Pat Gavlin 22799879e8 Fix the CHANGELOG. 2019-10-08 14:50:00 -07:00
Chris Smith 97d769000d
Support renaming stack projects (#3292)
* Support renaming stack projects

* Update CHANGELOG.md

* Address PR feedback
2019-10-03 09:13:13 -07:00
Pat Gavlin ecd028104c
Fetch CLI verisons from Homebrew where applicable. (#3290)
If the CLI seems to have been installed using Homebrew, do not consult
the service for the latest version. Instead, consult the Homebrew JSON
API.

Fixes #3230.
2019-10-01 13:34:42 -07:00
CyrusNajmabadi 52884096e9
Add support for updating a subset of resources in the stack (i.e. --target) (#3251) 2019-09-30 23:41:56 -07:00
Pat Gavlin 80504bf0bc
Propagate inputs to outputs during preview. (#3245)
These changes restore a more-correct version of the behavior that was
disabled with #3014. The original implementation of this behavior was
done in the SDKs, which do not have access to the complete inputs for a
resource (in particular, default values filled in by the provider during
`Check` are not exposed to the SDK). This lack of information meant that
the resolved output values could disagree with the typings present in
a provider SDK. Exacerbating this problem was the fact that unknown
values were dropped entirely, causing `undefined` values to appear in
unexpected places.

By doing this in the engine and allowing unknown values to be
represented in a first-class manner in the SDK, we can attack both of
these issues.

Although this behavior is not _strictly_ consistent with respect to the
resource model--in an update, a resource's output properties will come
from its provider and may differ from its input properties--this
behavior was present in the product for a fairly long time without
significant issues. In the future, we may be able to improve the
accuracy of resource outputs during a preview by allowing the provider
to dry-run CRUD operations and return partially-known values where
possible.

These changes also introduce new APIs in the Node and Python SDKs
that work with unknown values in a first-class fashion:
- A new parameter to the `apply` function that indicates that the
  callback should be run even if the result of the apply contains
  unknown values
- `containsUnknowns` and `isUnknown`, which return true if a value
  either contains nested unknown values or is exactly an unknown value
- The `Unknown` type, which represents unknown values

The primary use case for these APIs is to allow nested, properties with
known values to be accessed via the lifted property accessor even when
the containing property is not fully know. A common example of this
pattern is the `metadata.name` property of a Kubernetes `Namespace`
object: while other properties of the `metadata` bag may be unknown,
`name` is often known. These APIs allow `ns.metadata.name` to return a
known value in this case.

In order to avoid exposing downlevel SDKs to unknown values--a change
which could break user code by exposing it to unexpected values--a
language SDK must indicate whether or not it supports first-class
unknown values as part of each `RegisterResourceRequest`.

These changes also allow us to avoid breaking user code with the new
behavior introduced by the prior commit.

Fixes #3190.
2019-09-30 11:03:58 -07:00
Luke Hoban 9374c374c3
Transformations (#3174)
Adds the ability to provide `transformations` to modify the properties and resource options that will be used for any child resource of a component or stack.

This offers an "escape hatch" to modify the behaviour of a component by peeking behind it's abstraction.  For example, it can be used to add a resource option (`additionalSecretOutputs`, `aliases`, `protect`, etc.) to a specific known child of a component, or to modify some input property to a child resource if the component does not (yet) expose the ability to control that input directly.  It could also be used for more interesting scenarios - such as:
1. Automatically applying tags to all resources that support them in a stack (or component)
2. Injecting real dependencies between stringly-referenced  resources in a Helm Chart 
3. Injecting explicit names using a preferred naming convention across all resources in a stack
4. Injecting `import` onto all resources by doing a lookup into a name=>id mapping

Because this feature makes it possible to peek behind a component abstraction, it must be used with care in cases where the component is versioned independently of the use of transformations.  Also, this can result in "spooky action at a distance", so should be used judiciously.  That said - this can be used as an escape hatch to unblock a wide variety of common use cases without waiting on changes to be made in a component implementation.  

Each transformation is passed the `resource`, `name`, `type`, `props` and `opts` that are passed into the `Resource` constructor for any resource descended from the resource that has the transformation applied.  The transformation callback can optionally return alternate versions of the `props` and `opts` to be used in place of the original values provided to the resource constructor.

Fixes #2068.
2019-09-29 11:27:37 -07:00
Pat Gavlin dd8155ae20 Prepare the CHANGELOG for 1.2.0 2019-09-26 13:27:57 -07:00
Praneet Loke a0a86155c1
Add the config array option to the preview command. (#3271)
* Add the config array option to the preview command.

* Update changelog
2019-09-25 17:45:36 -07:00
Praneet Loke 4404dfb470
Add codefresh CI detection. Thanks to @fernandocarletti. (#3270)
* Add codefresh CI detection. Thanks to @fernandocarletti.
2019-09-25 14:41:13 -07:00
CyrusNajmabadi c1ff9c37f8
Delete specific target (#3244) 2019-09-19 19:28:14 -07:00
Pat Gavlin 40b0f8cbab
Cache ciphertext for secret properties. (#3183)
This caching is enabled by wrapping the `secrets.Manager` returned by
`DefaultSecretsProvider.OfType` in an outer `secrets.Manager` that
cooperates with `stack.{Serialize,Deserialize}PropertyValue`. Ciphertext
is cached on a per-secret-instance basis (i.e. not a per-plaintext-value
basis). Cached ciphertext is only reused if the plaintext for the secret
value has not changed. Entries are inserted into the cache upon both
encryption and decryption so that values that originated from ciphertext
and that have not changed can aoid re-encryption.

Contributes to #3178.
2019-09-18 15:52:31 -07:00
CyrusNajmabadi f788eb8fc1
Add support for refreshing specific targets. (#3225) 2019-09-17 18:14:10 -07:00
Erin Krengel 938c2e8bd8
Fix parsing of Gitlab urls w subgroups (#3239) 2019-09-16 20:35:23 -07:00
Pat Gavlin 82204230e1
Improve tracing support. (#3238)
* Fix some tracing issues.

- Add endpoints for `startUpdate` and `postEngineEventsBatch` so that
  spans for these invocations have proper names
- Inject a tracing span when walking a plan so that resource operations
  are properly parented
- When handling gRPC calls, inject a tracing span into the call's
  metadata if no span is already present so that resource monitor and
  engine spans are properly parented
- Do not trace client gRPC invocations of the empty method so that these
  calls (which are used to determine server availability) do not muddy
  the trace. Note that I tried parenting these spans appropriately, but
  doing so broke the trace entirely.

With these changes, the only unparented span in a typical Pulumi
invocation is a single call to `getUser`. This span is unparented
because that call does not have a context available. Plumbing a context
into that particular call is surprisingly tricky, as it is often called
by other context-less functions.

* Make tracing support more flexible.

- Add support for writing trace data to a local file using Appdash
- Add support for viewing Appdash traces via the CLI
2019-09-16 14:16:43 -07:00
Pat Gavlin 5af13f9a4f Prepare the CHANGELOG for v1.1.0 2019-09-11 13:56:48 -07:00
Mikhail Shilkov 6ac21fc430 Fix the pulumi new --stack option (#3131)
* Fix the pulumi new --stack option

* Changelog

* Restore the existing stack check with an added guard
2019-09-11 18:40:04 +02:00