Commit graph

324 commits

Author SHA1 Message Date
Pat Gavlin 2f554d5cdc
Fix an assert in the Go SDK. (#3794)
This assert is not correct in the case of pointer input types, in
particular `pulumi.stringPtr`. Though these types are not assignable,
they are convertible.
2020-01-23 13:07:47 -08:00
Erin Krengel 0d0641278c
Remove version req for disable; Add --latest to enable (#3784) 2020-01-22 15:17:00 -08:00
Pat Gavlin 567a515296 Update the CHANGELOG for 1.9.0 2020-01-22 11:56:40 -08:00
Pat Gavlin f168bdc1c2
Redesign the Go SDK resource/input/output system. (#3506)
The redesign is focused around providing better static typings and
improved ease-of-use for the Go SDK. Most of the redesign revolves
around three pivots:
- Strongly-typed inputs, especially for nested types
- Struct-based resource and invoke APIs
- Ease-of-use of Apply

1. Strongly-typed inputs

Input is the type of a generic input value for a Pulumi resource.
This type is used in conjunction with Output to provide polymorphism
over strongly-typed input values.

The intended pattern for nested Pulumi value types is to define an
input interface and a plain, input, and output variant of the value
type that implement the input interface.

For example, given a nested Pulumi value type with the following shape:

```
type Nested struct {
    Foo int
    Bar string
}
```

We would define the following:

```
var nestedType = reflect.TypeOf((*Nested)(nil)).Elem()

type NestedInput interface {
    pulumi.Input

    ToNestedOutput() NestedOutput
    ToNestedOutputWithContext(context.Context) NestedOutput
}

type Nested struct {
    Foo int `pulumi:"foo"`
    Bar string `pulumi:"bar"`
}

type NestedInputValue struct {
    Foo pulumi.IntInput `pulumi:"foo"`
    Bar pulumi.StringInput `pulumi:"bar"`
}

func (NestedInputValue) ElementType() reflect.Type {
    return nestedType
}

func (v NestedInputValue) ToNestedOutput() NestedOutput {
    return pulumi.ToOutput(v).(NestedOutput)
}

func (v NestedInputValue) ToNestedOutputWithContext(ctx context.Context) NestedOutput {
    return pulumi.ToOutputWithContext(ctx, v).(NestedOutput)
}

type NestedOutput struct { *pulumi.OutputState }

func (NestedOutput) ElementType() reflect.Type {
    return nestedType
}

func (o NestedOutput) ToNestedOutput() NestedOutput {
    return o
}

func (o NestedOutput) ToNestedOutputWithContext(ctx context.Context) NestedOutput {
    return o
}

func (o NestedOutput) Foo() pulumi.IntOutput {
    return o.Apply(func (v Nested) int {
        return v.Foo
    }).(pulumi.IntOutput)
}

func (o NestedOutput) Bar() pulumi.StringOutput {
    return o.Apply(func (v Nested) string {
        return v.Bar
    }).(pulumi.StringOutput)
}
```

The SDK provides input and output types for primitives, arrays, and
maps.

2. Struct-based APIs

Instead of providing expected output properties in the input map passed
to {Read,Register}Resource and returning the outputs as a map, the user
now passes a pointer to a struct that implements one of the Resource
interfaces and has appropriately typed and tagged fields that represent
its output properties.

For example, given a custom resource with an int-typed output "foo" and
a string-typed output "bar", we would define the following
CustomResource type:

```
type MyResource struct {
    pulumi.CustomResourceState

    Foo pulumi.IntOutput    `pulumi:"foo"`
    Bar pulumi.StringOutput `pulumi:"bar"`
}
```

And invoke RegisterResource like so:

```
var resource MyResource
err := ctx.RegisterResource(tok, name, props, &resource, opts...)
```

Invoke arguments and results are also provided via structs, but use
plain-old Go types for their fields:

```
type MyInvokeArgs struct {
    Foo int `pulumi:"foo"`
}

type MyInvokeResult struct {
    Bar string `pulumi:"bar"`
}

var result MyInvokeResult
err := ctx.Invoke(tok, MyInvokeArgs{Foo: 42}, &result, opts...)
```

3. Ease-of-use of Apply

All `Apply` methods now accept an interface{} as the callback type.
The provided callback value must have one of the following signatures:

	func (v T) U
	func (v T) (U, error)
	func (ctx context.Context, v T) U
	func (ctx context.Context, v T) (U, error)

T must be assignable from the ElementType of the Output. If U is a type
that has a registered Output type, the result of the Apply will be the
corresponding Output type. Otherwise, the result of the Apply will be
AnyOutput.

Fixes https://github.com/pulumi/pulumi/issues/2149.
Fixes https://github.com/pulumi/pulumi/issues/3488.
Fixes https://github.com/pulumi/pulumi/issues/3487.
Fixes https://github.com/pulumi/pulumi-aws/issues/248.
Fixes https://github.com/pulumi/pulumi/issues/3492.
Fixes https://github.com/pulumi/pulumi/issues/3491.
Fixes https://github.com/pulumi/pulumi/issues/3562.
2020-01-18 10:08:37 -05:00
Evan Boyle faa6d95178
update changelog for #3704 (#3770) 2020-01-17 15:26:41 -08:00
Praneet Loke 0fd131fb9e
Add a new BuildNumber property to the backend metadata bag and CI vars (#3766)
* Add a new metadata property for BuildNumber. Update Travis and GitLab to set both Build ID and Build Number. Add link to env vars doc for Codefresh.

* Update changelog

* Update CI vars detection test.

* Add PR number to changelog.
2020-01-17 10:47:49 -08:00
Praneet Loke 39a4abe32d
Fix the pipeline ID and PR URL for GitLab CI (#3763)
* Use Merge Request Instance ID instead of the Merge Request ID for GitLab CI.

* Use GitLab Pipeline Instance ID as the BuildID for GitLab CI.

* Update the changelog.

* Update the test for GitLab CI detection.
2020-01-16 14:59:12 -08:00
Erin Krengel 223e0c5e83
Add policy ls (#3753) 2020-01-16 12:04:51 -08:00
Erin Krengel 77bcba412e
Add permalink to policy publish (#3757) 2020-01-15 17:08:14 -08:00
Mike Metral 1f192d024e Lock dep ts-node to v8.5.4 2020-01-10 12:18:46 -05:00
Erin Krengel 0ba101fdba
Improvements to pulumi policy (#3688) 2020-01-03 14:16:39 -08:00
Mikhail Shilkov 66de4a48b7
First-class Stack component for .NET (#3618)
First-class Stack component for .NET
2019-12-23 08:31:12 +01:00
Luke Hoban 6525d17b7b
Update CHANGELOG.md 2019-12-22 11:49:49 -08:00
Luke Hoban a2ed4c56ad
Update CHANGELOG.md 2019-12-20 14:17:58 -08:00
Pat Gavlin 7b9e05eb6a Update the CHANGELOG for 1.8.1 2019-12-20 14:05:00 -08:00
Pat Gavlin bf9424d7e4 Update the CHANGELOG for 1.8.0 2019-12-19 18:43:06 -08:00
Praneet Loke c87f161cf0
Fix logic to determine PRNumber and BuildURL for Az Pipelines. (#3677)
* Fix logic to determine PRNumber and BuildURL for Az Pipelines.

* Update changelog

* Set the BranchName to the PR source branch if PRNumber is not empty.
2019-12-19 17:17:54 -05:00
CyrusNajmabadi 342b80b768
Add a supported api for components to indicate that they are asynchronously constructed. (#3676) 2019-12-17 15:34:30 -08:00
CyrusNajmabadi f4fc00ad0e
Output.apply should lift resources from inner Outputs to the top level output. (#3663) 2019-12-17 14:11:45 -08:00
Luke Hoban 0ae81f6654
Bring pulumi preview in-line with pulumi up (#3675)
Adds support to `pulumi preview` to match `pulumi up` for:
* `refresh`
* `target`
* `replace`
* `target-replace`
* `target-dependents`

Fixes #3674.
2019-12-17 13:31:12 -08:00
Chris Smith 7818c219e8
Add .NET Core SDK to pulumi/pulumi container (#3616)
* Add tests for the pulumi/actions container

* Add .NET Core SDK to pulumi/pulumi container

* Address PR feedback

* Update CHANGELOG.md
2019-12-17 11:05:19 -08:00
CyrusNajmabadi 7cbdf58105
Update to TypeScript 3.7 (#3627) 2019-12-17 11:00:45 -08:00
Justin Van Patten 10a960ea4b
PaC: Support Config/getProject/getStack/isDryRun (#3612)
Add support for using `Config`, `getProject()`, `getStack()`, and
`isDryRun()` from Policy Packs.
2019-12-16 22:51:02 +00:00
Luke Hoban 35f16f3e42
Update CHANGELOG.md 2019-12-16 11:23:27 -08:00
PLACE c01ba59684 added support for using GOOGLE_CREDENTIALS for gs:// filestate authentication (#2906)
* added support for using GOOGLE_CREDENTIALS environment variable for authenticating with gs:// file state

* modified the change to fix #2791 as well

* fixed a small bug

* fixed linter error

* added code comments

* Update pkg/backend/filestate/gcpauth.go

Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>

* Parse provided backend url to check if scheme is gs://

* Update changelog
2019-12-16 17:47:31 +00:00
Pat Gavlin 03e0005fe0 Update the CHANGELOG for v1.7.1 2019-12-13 15:37:16 -08:00
CyrusNajmabadi 9151d48ee3
Fix typing for 'Lifted<T>' to work better across versions of TS (#3658) 2019-12-13 11:18:19 -08:00
Luke Hoban 57b19ce403
Improve CHANGELOG formatting 2019-12-11 10:22:29 -08:00
Pat Gavlin 6cb1cf8b03 Update the CHANGELOG for 1.7.0 2019-12-11 09:36:18 -08:00
CyrusNajmabadi bb8b1a5fd4
Fix changelog (#3623) 2019-12-09 15:16:22 -08:00
CyrusNajmabadi 048acc24f7
Allow users to export a top-level function to serve as the entrypoint to their pulumi app. (#3321) 2019-12-09 11:28:20 -08:00
Pat Gavlin e09cbc708e Update the CHANGELOG for v1.6.1 2019-11-26 14:52:32 -08:00
Evan Boyle 1ca50d4b89
Propagate parent and providers for go SDK calls (#3563) 2019-11-26 13:23:34 -08:00
Evan Boyle c83e4f9ca6
Fix go SDK ReadResource (#3581) 2019-11-25 15:31:12 -08:00
Evan Boyle a47103b49d
fix go sdk delete before replace implementation (#3572) 2019-11-25 14:10:06 -08:00
Justin Van Patten 3c1bdff5fd
Allow relative paths to --policy-pack (#3565)
A regression was introduced when we added support for non-Node.js Pulumi programs to run Policy Packs. With that change, we now pass the Policy Pack's full path as the plugin's pwd (so that it would load the `@pulumi/pulumi/cmd/run-policy-pack` Node module from the Policy Pack's node_modules rather than the program's node_modules), but we also pass the path to the policy pack as well. If the path is a full rooted path, this would work fine, and that's what our tests do. However, if a relative path is specified, then it will be looking to load the Policy Pack relative to the pwd, which doesn't produce a correct path leading to failures trying to load the Policy Pack.

Since the pwd is the policy pack path, we can simply pass the path as `"."` to the analyzer plugin, and it will load the policy pack in its pwd.
2019-11-22 17:24:35 +00:00
Justin Van Patten fbe96394a1
Add ability to opt-in to using yarn instead of npm (#3556)
This change adds support for setting `PULUMI_PREFER_YARN` to true to opt-in to preferring `yarn` over `npm` when installing Node.js dependencies (and publishing Policy Packs). If `PULUMI_PREFER_YARN` is truthy, but `yarn` cannot be found on `$PATH`, we fallback to using `npm`. If `npm` can't be found on `$PATH`, we provide a more helpful error message.
2019-11-21 20:59:48 +00:00
Pat Gavlin 35b32f20c3 Update the CHANGELOG for 1.6.0 2019-11-20 10:53:04 -08:00
CyrusNajmabadi d4aa5fe20d Switch to 'console.log' for our hang warning. Add warning to synchronous StackReference calls. (#3456)
Codepaths which could result in a hang will print a message to the console indicating the problem, along with a link to documentation on how to restructure code to best address it.

`StackReference.getOutputSync` and `requireOutputSync` have been deprecated as they may cause hangs on some combinations of Node and certain OS platforms. `StackReference.getOutput` and `requireOutput` should be used instead.
2019-11-19 12:51:14 -08:00
Maciej Lisiewski bcdd27e092 Updates grpc package to 1.24.2 for js sdk (#3512)
Fixes building grpc package with gcc8 and newer
Fixes building grpc package for node 13.x
Matches minor grpc release (1.24.x) to version used by dotnet sdk
2019-11-19 11:56:26 -08:00
Paul Stack c4e74d8ffc
Validate stack name on stack init with non default secrets provider (#3519)
Fixes: #3248

Before, we got a panic. in the createStack, when we had a non-default
secrets provider, we were assuming the name of the stack was correct
if we were in non-interactive mode

This commit adds a guard against this by doing a final validation of
the stack name *before* we even get into the createStack func

This means, that we get the following (and not the panic)

```
▶ pulumi stack init -s "org/" --secrets-provider="gcpkms://"
error: A stack name may only contain alphanumeric, hyphens, underscores, and periods
```
2019-11-19 16:58:23 +01:00
CyrusNajmabadi 1908a18d20 Loosen resource targeting restrictions. (#3426)
- If an untargeted create would not affect the inputs of any targeted
  resources, do not fail the update. Untargeted creates that are
  directly dependend on by targeted resources will still cause failures
  that inform the user to add the untargeted resources to the --target
  list.
- Users may now pass the `--target-dependents` flag to allow targeted
  destroys to automatically target dependents that must be destroyed in
  order to destroy an explicitly targeted resource.
2019-11-18 20:28:25 -08:00
Evan Boyle 8547ede659
Add Go support for config.*Object (#3526) 2019-11-18 18:53:27 -08:00
Evan Boyle 3ac8dd5285
Add support to the go sdk for IgnoreChanges (#3514) 2019-11-18 16:47:19 -08:00
stack72 25aeb237ca Move from go 1.12.x to go 1.13.x 2019-11-18 14:49:31 +01:00
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