Commit graph

504 commits

Author SHA1 Message Date
Pat Gavlin b14bc09b1c
Update a misleading comment. (#8491) 2021-11-24 10:37:08 -08:00
Fraser Waters 09b7aa9186
Add String and GoString to Result (#8490)
I got fed up of assert errors in tests that looked like:
```
Expected nil, but got: &result.simpleResult{err:(*errors.fundamental)(0xc0002fa5d0)}
```

It was very hard to work out at a glance what had gone wrong and I kept
having to hook a debugger just to look at what the error was.

With GoString these now print something like:
```
Expected nil, but got: &simpleResult{err: Unexpected diag message: <{%reset%}>resource violates plan: properties changed: -zed, -baz, -foo<{%reset%}>
}
```

Which is much more useful.
2021-11-24 17:01:55 +00:00
Anton Tayanovskyy 574a6a104d
Do not FailNow() in generators (#8469) 2021-11-19 20:39:11 -05:00
Ian Wahbe 7222e5570a
[cli] check main after master (#8463)
* Allow specifying a branch with url#branch

* Probe for master and main

* Update CHANGELOG

* Fix linter errors

* Remove unnecessary feature

* Fix lint

* Update changelog to reflect new limited scope.

We only talk about the master -> main probing, because that is all the
PR does. It used to duplicate another feature.
2021-11-19 13:49:59 -08:00
Justin Van Patten ba39ed9ad4
Add tests that return failures from Call (#8424)
- [sdk/nodejs] - Allow returning failures from Call in the provider without setting result outputs.
- [sdk/go] - Allow specifying Call failures from the provider.
- Add tests that return failures from Call.
2021-11-16 08:58:46 -08:00
Anton Tayanovskyy 372ddc7e5c
Skip flaky tests for now (#8420) 2021-11-15 15:17:20 -05:00
Adam Wilczek a5f72ddbeb
Added a buildkite detector for detecting the correct env vars in CI (#7933)
* Added a buildkite detector for detecting the correct env vars in CI

* adding pending changelog entry

* fixed PR logic to actually match the Buildkite Docs and simplified if statement, Fixed a few typos in comments and added PR to CHANGELOG_PENDING.md

* made PR number fetch easier to read

* fixing typo in comment
2021-11-15 09:10:07 -08:00
Paul Stack 74ba28ad55
[CLI] Adding the ability to create a default org for backends that support orgs (#8352) 2021-11-12 20:44:51 +02:00
Ian Wahbe fbeac6fc10
Improve corrupt workspace settings experience (#8393)
* Improve corrupt workspace settings experience

This improvement comes in two parts.

1. The error message for a corrupt workspace settings file now clearly
indicates both the file and the parsing error.

2. Writing the workspace settings is now atomic. This prevents
corruption from multiple concurrent calls.

* Use builtin atomic write

* Use builtin ioutil.TempFile

* Change tmp file dir
2021-11-11 14:58:39 -08:00
Fraser Waters b58c39476f
Fix cmdutil.PrintTable to handle ansi escapes and non-byte glyphs (#8344)
Fixes two bugs in how padding was calculated in PrintTable.

Firstly we remove all ANSI escape codes from the string before measuring
how wide it is. Secondly we measure glyph count (using rivo/uniseg) not
byte or rune count of the string.

Together these fix the padding/alignment issues I saw when using
PrintTable with plan output. They also slightly change the layout of
"pulumi stack", for example the below is printed with current master and
has 6 characters of space for padding between SecurityGroup and
web-secgrp:

```
Current stack resources (4):
    TYPE                                        NAME
    pulumi:pulumi:Stack                         aws-cs-webserver-test
    ├─ aws:ec2/securityGroup:SecurityGroup      web-secgrp
    ├─ aws:ec2/instance:Instance                web-server-www
    └─ pulumi:providers:aws                     default_4_25_0
```

While printed with this commit you only get 2 characters of space for
padding (which is correct, the column gap is set to "  "):
```
Current stack resources (4):
    TYPE                                    NAME
    pulumi:pulumi:Stack                     aws-cs-webserver-test
    ├─ aws:ec2/securityGroup:SecurityGroup  web-secgrp
    ├─ aws:ec2/instance:Instance            web-server-www
    └─ pulumi:providers:aws                 default_4_25_0
```
2021-11-04 10:06:20 +00:00
Justin Van Patten f989e1cc9d
Update pkg -> sdk dependency (#8346) 2021-11-03 11:25:20 -07:00
Ian Wahbe e38876f7af
[sdk/go] Respect default parent in go aliases. (#8288)
* Respect default parent in go aliases.

* Update changelog

* Handle empty parrents correctly

* Allow specifying no parent

* clarify variable name

* Improve `Unparent` ergonomics

* Take t0yv0's suggestion

* Adopt @t0yv0's tests and doc comments.

* Make NoParent,Parent,ParentURN mutually exclusive
2021-10-28 17:25:31 -07:00
Ian Wahbe 83e24765f3
.NET & python SDKs parity for bad pulumi versions (#8297)
* .NET & python SDKs parity for bad pulumi versions

They handle invalid Pulumi CLI version gracefully.

* Make python version property lazy

* Clarify .NET logic

* Add python test for validate_pulumi_version

* Add tests for invalid versions

* Fix python test

* Fix typo

* Fix tests

* Have _validate_pulumi_version handle parsing

* Modify python and .NET to parseAndValidate

* Modify typescript and go to parseAndValidate

* fix name
2021-10-27 20:54:23 -07:00
Justin Van Patten fbf62399ca
[sdk/go] Fix regression marshaling assets/archives (#8290)
This change fixes a regression marshaling assets/archives that was introduced after adding support for marshaling output values.

For example, when setting an `Asset` on a field typed as `AssetOrAchiveInput`, in `marshalInput`, the input was being converted into an `AssetOrArchiveOutput` via the `ToAssetOrArchiveOutputWithContext`. Awaiting the output returns an `*asset` struct, which is itself an `AssetInput`, which causes infinite recursion when passed recursively to `marshalInput`.

The fix is to skip the `Input` checks in recursive calls, which is equivalent to the previous behavior before the regression was introduced.

Another issue was that when the input is converted to an output, this would result in `marshalInput` always returning an output value, even if the original passed-in value was not an output. To address this, if the output's value is known, not a secret, and has no dependencies, we can return the value itself rather than wrapping it as an output.
2021-10-27 08:44:42 -07:00
Ian Wahbe c8e117a37d
Handle invalid Pulumi CLI version (#8289)
* Handle invalid Pulumi CLI version

* Add clarifying comments and improve error message.

* Update go version of `validatePulumiVersion`
2021-10-26 16:20:45 -07:00
Carlos Tadeu Panato Junior 1c0a7e4907
reformat error message string (#8284)
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
2021-10-26 14:55:25 -06:00
Fraser Waters b39c81e4cb
Improve error message and add test for #1440 (#8268)
* Improve error message and add test for #1440

* lint

* lint

* Use %w instead of errors.Wrap
2021-10-26 16:55:52 +01:00
Komal a9a62bd761
Determine secretness by checking raw string for the secret sentinel (#8179) 2021-10-08 14:43:10 -07:00
Jeremy Dartigalongue 25f396bf49
Fix Go automation API --target / --replace args (#8109) 2021-10-04 11:55:23 -07:00
Anton Tayanovskyy 836b410911
Disable ConcurrentUpdateError test (#7953)
* Better logging from ConcurrentUpdateError test

* Disable the test
2021-10-04 13:31:31 -04:00
Praneet Loke 8f89ab6e3a
[codegen/docs] Generate a package tree that can be serialized as JSON (#8102)
* Add an initialize func. Add a new func that generates the package tree
2021-09-30 17:35:44 -07:00
Pat Gavlin 5f9d211cae
[testing] Stack context for value generation (#8108)
These changes add a context type to `resource/testing` that can be used to
generate property values that are valid with respect to certain rules. The
context represents a Pulumi stack, and contains a project name, stack name,
and a list of resources.

- URNs generated using a context will always use the context's project
  and stack name
- Resource references generated using a context will always refer to
  resources in the context's resource list
- Output values generated using a context will always pull dependencies
  from the context's resource list
2021-09-30 14:39:09 -07:00
Paul Stack 09a8cc7079
[cli] Add the ability to control auto-refresh of stacks by Pulumi.yaml (#8071)
Co-authored-by: Komal Ali <komal@pulumi.com>
2021-09-29 12:43:48 +03:00
Ian Wahbe 9df8d3a028
Bold in-progress diffs diffrently (#7918)
* Initial take on coloring in-progress diffs

* Update CHANGELOG_PENDING.md

* Add high and low color levels

* Don't print functions

* Change colorprogress to bold

* Fix @komalali's nits.

* Restore background colors comment
2021-09-28 15:16:09 -07:00
Justin Van Patten ea44ae3d0f
[sdk/go] Fix unmarshaling known output values in provider (#8082)
`ConstructInputs.CopyTo` can error when falling back to the old marshaling behavior when it's lacking an input type registration for a _known_ output value. In such cases, it tries to unmarshal a known output value, it can't unmarshal it because of a missing switch case. This change adds the missing case.
2021-09-27 18:46:30 -07:00
Justin Van Patten 9deb5ca0ec
[sdk/go] Marshal output values (#7958)
This change adds support for marshaling outputs as output values in the Go SDK.
2021-09-27 09:01:40 -07:00
Justin Van Patten 3027d01f25
Enable output values by default (#8014)
* Enable output values by default

Enable output values by default in the resource monitor and change the polarity of the envvar from `PULUMI_ENABLE_OUTPUT_VALUES` to `PULUMI_DISABLE_OUTPUT_VALUES`.

* Marshal unknown as unknown string when `!KeepOutputValues`

Marshal all unknown output values as `resource.MakeComputed(resource.NewStringProperty(""))` when not keeping output values, which is consistent with what the SDKs do.

Otherwise, when `v.OutputValue().Element` is nil, `resource.MakeComputed(v.OutputValue().Element)` will be marshaled as a null value rather than as an unknown sentinel.

* Add MarshalOptions.DontSkipOutputs and use where needed

Before we expanded the meaning of `resource.Output`, `MarshalProperties` always skipped output values:

```go
if v.IsOutput() {
    logging.V(9).Infof("Skipping output property for RPC[%s]: %v", opts.Label, key)
}
```

As part of expanding the meaning of `resource.Output`, I'd adjusted `MarshalProperties` to only skip output values when the value was unknown and when not keeping output values:

```go
if v.IsOutput() && !v.OutputValue().Known && !opts.KeepOutputValues {
    logging.V(9).Infof("Skipping output property for RPC[%s]: %v", opts.Label, key)
}
```

However, this doesn't work the way we want when marshaling properties that include unknown output values to a provider that does not accept outputs. In that case, `opts.KeepOutputValues` will be `false` because we want the marshaler to fall back to returning non-output-values (e.g. unknown sentinel value for unknown output values), but instead of getting the intended fallback values, the unknown output values are skipped (not what we want).

I suspect we may be able to delete the output value skipping in `MarshalProperties` altogether (it's odd that it is skipping `resource.Output` but not `resource.Computed`), but to avoid any unintended side effects of doing that, instead, this commit introduces a new `MarshalOptions.DontSkipOutputs` option that can be set to `true` to opt-in to not skipping output values when marshaling. The check in `MarshalProperties` now looks like this:

```go
if !opts.DontSkipOutputs && v.IsOutput() && !v.OutputValue().Known {
    logging.V(9).Infof("Skipping output property for RPC[%s]: %v", opts.Label, key)
}
```

`opts.DontSkipOutputs` is set to `true` when marshaling properties for calls to a provider's `Construct` and `Call`.

* [sdk/nodejs] Deserialize output values

This commit adds support for deserializing output values, which is needed in some cases when serialized inputs are returned as outputs in the SDK.

* [sdk/python] Deserialize output values

This commit adds support for deserializing output values, which is needed in some cases when serialized inputs are returned as outputs in the SDK.
2021-09-24 08:57:04 -07:00
Pat Gavlin 134d7cb818
[apitype] Add a JSON schema for deployments. (#8002)
This schema can be used to validate the contents of a Pulumi deployment.
If a deployment validates against this schema, it should be considered
syntactically valid, though it may contain certain classes of semantic
errors (e.g. references to unknown resources in dependency lists,
dependency cycles, etc.).

This schema is not yet used for validation in practice and may not be
entirely accurate.

These changes also add this schema (and the schemas on which it depends)
to the developer documentation. jsonschema2md.go has been updated to
support multi-file schemas.
2021-09-21 21:37:06 -07:00
Komal 3d42198991
Clean up diagnostic messages in event log (#7998)
* Don't escape characters in event log.

* Respect NO_COLOR
2021-09-21 17:22:39 -07:00
Pat Gavlin cbdecf2cd5
[testing] Add rapid generators for PropertyValues. (#8009)
And use those generators to test property value serialization and
deserialization paths.
2021-09-21 15:02:10 -07:00
Ian Wahbe 2e5fedff54
Switch from golint to revive (#8010) 2021-09-21 10:00:44 -07:00
Justin Van Patten d812d16329
[sdk/go] Unmarshal output values in component provider (#7975)
This adds support for unmarshaling output values in the CopyTo helper used when copying inputs to an args struct
2021-09-17 19:46:06 -07:00
Pat Gavlin 2dcf3806bd
[automation-api] Exclude tests from test_fast. (#7986)
The Automation API tests take long enough that thay don't really fit
into `test_fast`. These changes move those tests to `test_all`.
2021-09-16 17:33:33 -07:00
Justin Van Patten 1a4f36e97b
[sdk/go] Add RegisterInputType and register built-in types (#7928)
This change adds a `RegisterInputType` function (similar to the existing `RegisterOutputType`) that is used to register an input interface's type and its associated input type, and adds registrations for the built-in input types.

This will be used when copying inputs to an args struct for multi-lang components. When a field is typed as the input interface (e.g. `StringMapInput`) and doesn't need to be an `Output`, we can use this to lookup the non-Output type that implements the interface (e.g. `StringMap`) so it can be instantiated.

A subsequent change will update the Go SDK codegen to produce input type registrations for a provider's input types.
2021-09-15 21:12:49 -07:00
Ian Wahbe 054b3f9edc
Iwahbe/7881/thread replace on chages through sdks (#7967)
* Thread replaceOnChanges through the Go SDK

* Add replaceOnChanges to the .NET SDK

* Update CHANGELOG_PENDING.md

* Fix null error

* Update CHANGELOG_PENDING.md

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-09-15 14:29:13 -07:00
Justin Van Patten ed4b53d3ae
Add monitor feature for output values (#7870) 2021-09-15 14:16:00 -07:00
Justin Van Patten 0c0684af5c
Initial support for (un)marshaling output values (#7861)
This change expands the definition of `resource.Output` in the Go SDK with additional information about the output, i.e. dependencies and secretness, and adds support in the core Go RPC code for (un)marshaling output values.

Output values are marshaled as special objects ala archives, assets, and resource refs and are unmarshaled as `resource.Output` values.

Subsequent PRs will add:
 - A monitor feature for output values, which will initially be disabled by default but available to turn on via an envvar
 - Support for (un)marshaling output values in each language SDKs
 - A way for providers to indicate support for receiving output values
 - E2E tests
 - Turn the monitor feature on by default (w/ env var to disable) (Note: the current plan is to initially scope this to only be used when marshaling inputs to a multi-language component)
2021-09-13 09:05:31 -07:00
Benjamin Schiborr 77867f9ce4
feat: Improve error messages for (un)marshalling (#7936)
Currently whenever an issue occurs in `UnmarshalProperties` and
`MarshalProperties` the offending property is hidden and very difficult
to track down.

This commit changes the behavior. For `Assets` and `Archives` the error
message now includes the URI and for other properties it includes the
key of the `PropertyMap`.
2021-09-10 13:18:08 -07:00
Anton Tayanovskyy 27b1404d9e
Fix lint (#7915)
* Fix lint

* Fix lint of pkg folder
2021-09-07 16:41:17 -04:00
Vivek Lakshmanan 233b396f29
Merge pull request #7877 from pulumi/vl/FixAuto
[auto/go] Fix stack config loading
2021-08-31 11:32:05 -07:00
Ian Wahbe 27fc39c00a Fix spelling of environment 2021-08-31 00:54:07 -07:00
Ian Wahbe 59f88030b7 Allow failure to cleanup 2021-08-31 00:25:50 -07:00
Ian Wahbe 703104e412 Skip failing test on windows 2021-08-30 22:53:16 -07:00
Ian Wahbe 70833d3a3c Allow windows to find commands without .exe 2021-08-30 21:36:03 -07:00
Vivek Lakshmanan 9435d9ae9a Update test 2021-08-30 21:26:09 -07:00
Vivek Lakshmanan 6162004df2 Fix stack config loading 2021-08-30 20:56:08 -07:00
Ian Wahbe 8150ef0880 Improve CI error messages
Failures unique to windows require a more informative error message to
diagnose.
2021-08-30 12:55:30 -07:00
Ian Wahbe 878ab50044 Merge branch 'master' into iwahbe/2715/add-pulumi-about-command 2021-08-27 04:50:50 -04:00
Pat Gavlin 98f73cf1ed
Start in on developer documentation. (#7839)
Developer documentation is written in Markdown and can be built into
HTML, PDF, etc. using Sphinx. Diagrams are written in PlantUML and
rendered as SVGs. All developer docs live in the `developer-docs` folder
under the root of the repository.
2021-08-25 15:18:13 -07:00
Anton Tayanovskyy b667ce5d4f
Tighten up auto test (#7830)
* Tighten up a test to not fail for wrong reasons, use python helpers

* Use local in-source Python SDK for the test
2021-08-24 14:48:09 -04:00