Commit graph

435 commits

Author SHA1 Message Date
Luke Hoban eb32039013
Add replaceOnChanges resource option (#7226)
Adds a new resource option to force replacement when certain properties report changes, even if the resource provider itself does not require a replacement.

Fixes #6753.

Co-authored-by: Levi Blackstone <levi@pulumi.com>
2021-07-01 13:32:08 -06:00
Justin Van Patten 84b574f0df
Initial support for resource methods (authoring from Node.js, calling from Python) (#7363)
Adds initial support for resource methods (via a new `Call` gRPC method similar to `Invoke`), with support for authoring methods from Node.js, and calling methods from Python.
2021-06-30 07:48:56 -07:00
Justin Van Patten e966c65f69
Fix pylint issues (#7389) 2021-06-29 21:35:25 -07:00
Evan Boyle 634e97cd55
Include config secret info in Construct calls (#7358) 2021-06-24 15:38:01 -07:00
Anton Tayanovskyy b16d50085b
Fix hanging deployments and improve errmsgs for programs with incorrect typings for output values (#7049)
* Do not hang but propagate exception when it happens in resolve_outputs

* Add an integration test for the issue

* Better error message

* Add CHANGELOG_PENDING entry

* Update sdk/python/lib/pulumi/runtime/rpc.py

Co-authored-by: Justin Van Patten <jvp@justinvp.com>

* Address PR feedback and tighten path param typing

* Given Windows builder is failing, allow 2x time for the test

* Give some more time to the Windows runner

* Attempt to solve differently

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-06-23 11:27:17 -04:00
Justin Van Patten 48bbc28d9e
[sdk/go] Specify known when creating outputs for construct (#7343)
If an input is an unknown value or contains unknowns, specify `false` for `known` when creating the output.
2021-06-21 09:51:41 -07:00
Luke Hoban 965d23ba2a
[sdk/python] Ensure Output objects are not iterable (#7288)
Although `Output` objects can never correct support iteration, Python will see the implementation of `__getitem__` and try to iterate the object, leading to an infinite loop.  To prevent this, we need to explicitly implement `__iter__` and make it return a `TypeError` to prevent iteration (and offer a useful error message).

Fixes #5028.
2021-06-15 09:25:24 +10:00
Justin Van Patten 63e129a386
[sdk/python] Reduce log.debug calls for improved performance (#7295)
`log.debug` messages are part of an update and get sent to the service. Reducing the number of `log.debug` calls can significantly improve the performance of a program. This commit changes the debug logging in the Python SDK to be similar to the debug logging in the Node.js SDK.

 - An `excessive_debug_output` variable has been added (that can be set to `True` during debugging), but otherwise will avoid a large number of `log.debug` calls.
- Some unhelpful/redundant `log.debug` calls have been deleted.
2021-06-14 10:24:01 -07:00
Paul Stack 57347188fb
[sdk/python] Fix linting errors due to missing types files (#7257) 2021-06-09 19:14:59 +03:00
Luke Hoban 26e252f241
Ensure Output.from_input({}) returns {} instead of [] (#7254)
Fixes #7252.
2021-06-09 19:48:10 +10:00
Luke Hoban bd6410e2fb
[sdk/python] Avoid exponential complexity for from_input/all (#7175)
These mutually recursive functions unintentionally had exponential complexity in nesting depth of objects, arg types and most likely arrays.

Remove the exponential complexity by avoiding direct recursion of from_input on itself, and relying on mutual recursion with all alone to reduce nested substructure.

Also simplify the implementation to aid readability.

Fixes pulumi/pulumi-kubernetes#1597.
Fixes pulumi/pulumi-kubernetes#1425.
Fixes pulumi/pulumi-kubernetes#1372.
Fixes #3987.
2021-06-01 13:11:22 +10:00
Justin Van Patten d6b7762102
Temporarily disable config secrets warning (#7129)
Temporarily disable the new config secret warning to avoid unactionable warnings from provider `config` modules. We'll re-enable the warning when we've addressed that issue.
2021-05-24 16:06:27 -07:00
Justin Van Patten f973fbcf58
[sdk/nodejs|python] Add GetSchema support to providers (#6892) 2021-05-19 07:11:18 -07:00
Justin Van Patten 480173a57f
[sdk/python] Warn when a secret config is read as a non-secret (#7078) 2021-05-18 15:00:30 -07:00
Justin Van Patten a61e79eb0d
[sdk/nodejs] Warn when a secret config is read as a non-secret (#6896) 2021-05-18 09:48:08 -07:00
Anton Tayanovskyy 493bac4c18
Make virtualenv paths relative to root when main points elsewhere (#6966)
* Propagate workspace.Project metadata to plugin init

* Get to a working fix

* Propagate Root via plugin context

* Propagate root instead of yaml path

* Revert out unnecessary parameter propagation

* Root is now always absolute at this point; simplify code and docs

* Drop python conditional and propagate unused -root to all lang hosts

* Add tests that fail before and pass after

* Lint

* Add changelog entry
2021-05-14 13:41:55 -04:00
Komal 17fae620af
Skip flaky python test (#7035) 2021-05-12 09:29:13 -07:00
Anton Tayanovskyy 2288f8b7fb
Fix issue with lazy_import affecting pulumi-eks (#7024)
* Fix issue with lazy_import in presense of modules-as-attrs

* Temporary inline _lazy_import into generated code for smooth updates

* Add CHANGELOG entry

* Rename _lazy_import to lazy_import

* Comments on short-circuit behavior

* Comment fix
2021-05-11 22:48:08 -04:00
Komal 3bac1d68b7
Move comment in python SDK (#7028) 2021-05-11 17:23:18 -07:00
Komal 3ef2648f45
Use test-org from env var (#7016) 2021-05-11 08:41:21 -07:00
Anton Tayanovskyy d55327db50
Fix tests that used to be skipped on missing async lib (#6941) 2021-05-10 13:27:20 -04:00
Komal 59992cff97
[automation/python] - Export ProjectBackend class (#6984) 2021-05-06 19:43:31 -07:00
Justin Van Patten 3746028c38
[sdk/python] Don't error when dict input value has a mismatched type (#6949)
Pulumi 3.0 raises an error when a dict value is passed as an input but the type annotation does not accept a dict. Unfortunately, this prevents historical cases where a dict value is allowed but the type annotation doesn't match. We need to fix the type annotations, but in the meantime, we should not raise an error in the SDK for such cases as it breaks existing programs.
2021-05-03 08:47:55 -07:00
Justin Van Patten 81db03ea2a
Fix Python test file names (#6947)
I'd run these tests individually locally, but they need to start with `test_` to be picked up by pytest.
2021-04-30 20:22:25 -07:00
Justin Van Patten 8574d40dda
[sdk/python] Fix type-related regression on Python 3.6 (#6942)
Pulumi 3.0 uses type annotations for input values to determine whether dict keys should be translated from snake_case to camelCase or not. This additional inspection of types did not work correctly on Python 3.6 due to some missing functionality on that version of Python which we need to provide an implementation for. Specifically, when inspecting `Union` args to determine whether or not a value is intended to be an input class or user-defined dict. To address the issue, this change improves how we get the args for `Union` types when running on Python 3.6 to behave the same way as later versions of Python (for our purposes). Existing tests fail on Python 3.6 before this change, and pass after.
2021-04-30 11:50:42 -07:00
Justin Van Patten 69d50ced27
[sdk/python] Address issues when using resource subclasses (#6890)
We were only looking at the current resource class's type/name metadata for camelCase <=> snake_case property name translations which prevented it from working correctly when using a subclass of a resource. This change addresses this by looking at metadata of the current class and any base classes.

Additionally, to help resolve forward references when getting type hints, we'd pass along the current resource class's globals, which doesn't work correctly when using a subclass of a resource. This change also addresses this, by using the globals of the current class and any base classes.
2021-04-30 10:07:23 -07:00
Komal 1ed3445ed4
[automation/*] - Optionally skip Automation API version check (#6882)
Co-authored-by: James Nugent <jen20@apple.com>
2021-04-27 20:54:27 -07:00
Ville Penttinen daa6045381
[automation/*] Add support for getting stack outputs using Workspace (#6859) 2021-04-26 16:32:30 -07:00
Komal 33f403e7c5
Fix python mock args (#6863) 2021-04-26 13:22:10 -07:00
Komal 5dba5227cc
[sdk/python] - Fix python lint errors (#6872) 2021-04-26 08:56:15 -07:00
Komal 288d67d78b
[auto/*] - Bump min version (#6852) 2021-04-22 16:17:49 -07:00
Komal f523d25868
[automation/python] - Fix deserialization of UpdateSummary (#6838) 2021-04-22 09:00:12 -07:00
Komal 61ce479241
Re-add [BREAKING] - Standardize stack select behavior (#6300) (#6840)
Co-authored-by: Paul Stack <public@paulstack.co.uk>
2021-04-22 14:10:39 +01:00
Anton Tayanovskyy 13f63e9648
Fix bug in semver usage by enabling typechecking (#6833)
* Fix bug in semver usage by enabling typechecking

* Add CHANGELOG note
2021-04-21 15:48:57 -04:00
Komal 967cff8550
Remove references to automation api being in alpha (#6828) 2021-04-21 08:44:04 -07:00
Ismayil 4bafeee700
Fixes #6775: Duplicated Go modules (#6800) 2021-04-19 08:24:51 -07:00
stack72 9a8b17396d Ensuring the minimum version of the CLI is 3.0.0 for the Automation API in 3.0 release 2021-04-19 09:12:06 +01:00
Pat Gavlin 1cc084dc0e
Fix inconsistent object type naming. (#6686)
See #6200 for a complete description of the issue. In short, we generate
inconsistent names for object types depending on whether or not they are
transitively reachable from resources or functions, which risks
unintentional breaking changes due to schema updates.

1. Name "input" types differently: `TArgs` for a type that is used in
   resource inputs, having `Input<T>` properties, and `T` for a type
   that is used in invoke inputs. The same schema type can produce both.

2. Always keep the name `T` for output types, avoid appending `Result` to
   the name.

3. As needed, introduce a flag in the existing providers' schemas to avoid
   breaking changes. Consider removing it on a major version bump.

Fixes #6200.
2021-04-15 19:03:28 -07:00
Anton Tayanovskyy b77f32930c
Remote component py SDK (#6715)
* Python support for authoring resource providers for multi-lang

* Support for passing prompt values to Python resource providers
2021-04-15 14:49:51 -04:00
Komal 4dcc0d631e
[automation/python] - Fix stack settings serialization (#6776) 2021-04-15 11:41:25 -07:00
Levi Blackstone 9d4d274b13
[sdk/python] Handle providers for RegisterResourceRequest (#6771)
Resolve providers references and include the resulting refs in the
providers field of RegisterResourceRequest that was added in
d297db3.
2021-04-14 14:56:26 -06:00
Paul Stack f6fea7fafb [cli] Removing the deprecated pulumi history command (#6724) 2021-04-14 19:32:18 +01:00
Paul Stack e955a6b06a Refactor Mock newResource and call to accept property bag rather than individual args (#6672) 2021-04-14 19:32:18 +01:00
Justin Van Patten 1112c513c0 [sdk/python] Improved dict key translation support (#6695)
This change addresses Python dictionary key translation issues. When the
type of `props` passed to the resource is decorated with `@input_type`,
the type's and resource's property name metadata will be used for dict
key translations instead of the resource's `translate_input_property`
and `translate_output_property` methods.

The generated provider SDKs will be updated to opt-in to this new
behavior:

- FIX: Keys in user-defined dicts will no longer be unintentionally
  translated/modified.

- BREAKING: Dictionary keys in nested output classes are now
  consistently snake_case. If accessing camelCase keys from such output
  classes, move to accessing the values via the snake_case property
  getters (or snake_case keys). Generated SDKs will log a warning
  when accessing camelCase keys.

When serializing inputs:

  - If a value is a dict and the associated type is an input type, the
    dict's keys will be translated based on the input type's property
    name metadata.

  - If a value is a dict and the associated type is a dict (or Mapping),
    the dict's keys will _not_ be translated.

When resolving outputs:

  - If a value is a dict and the associated type is an output type, the
    dict's keys will be translated based on the output type's property
    name metadata.

  - If a value is a dict and the associated type is a dict (or Mapping),
    the dict's keys will _not_ be translated.
2021-04-14 19:32:18 +01:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
pulumi-bot 3082ebe275 Ensuring that Pulumi automation api is minimum 3.0.0 CLI version 2021-04-14 19:32:18 +01:00
Paul Stack 3fad2e5329 Removing x namespace from go/python/nodejs automation packages (#6518) 2021-04-14 19:32:18 +01:00
Levi Blackstone d297db3d59
[sdk/proto] Add providers field to RegisterResourceRequest (#6761) 2021-04-13 15:19:24 -06:00
Komal 0c4e1a33e0
[automation/python - Expose structured logging (#6527) 2021-04-13 12:58:19 -07:00
Komal 33ceb1b70e
[automation/python] - Fix (de)serialization of StackSettings (#6749) 2021-04-12 15:50:53 -07:00
Evan Boyle 3d5ede69af
Set main for default projects in Automation API (#6743) 2021-04-09 20:30:11 -07:00
Ville Penttinen d93e5acf67
[automation/dotnet] Expose WorkspaceStack.GetOutputsAsync (#6699) 2021-04-07 16:23:38 -07:00
Komal 7f226c1cb6
Fix serializing bug if output contains 'items' property (#6705) 2021-04-05 20:36:56 -07:00
Komal 5254e3f01d
[python/sdk] - Fix serialization bug if output contains 'items' property (#6701) 2021-04-05 12:39:56 -07:00
Pat Gavlin 55ecf7a81e
Run SDK lint jobs (#6674)
Just what it says on the tin. Fixes #6628.
2021-04-01 11:23:47 -07:00
Komal 55a0c1fc8e
[automation/go,nodejs,python] - Don't roundtrip project settings if file already exists. (#6669) 2021-03-31 11:00:11 -07:00
Komal 7671e85440
[automation/go,nodejs,python] - Respect existing project settings (#6655) 2021-03-31 07:51:11 -07:00
Komal 7d10e8c5be
Fix mypy errors (#6656) 2021-03-30 19:11:13 -07:00
Komal 35321159fc
[sdk/python] - Await all async tasks (#6606) 2021-03-30 10:56:17 -07:00
Pat Gavlin 7c5ec6815e
Make data sources catchable in Python (#6504)
The current logic lets unhandled errors in the RPC invocation
unahandled in the async loop, which crashes the process due to
the way we await completion of RPCs before exiting the process
in Python. Instead of doing that, we can just marshal them back
to the synchronous awaiter as part of the calling convention,
and have that awaiter (which is called by the invoke methods)
re-raise the exception. This should fix pulumi/pulumi#3611.
2021-03-29 12:07:43 -07:00
Komal e5223492c7
[automation/python] - Fix passing of extra environment variables (#6639) 2021-03-29 11:48:17 -07:00
Justin Van Patten 872d9cb849
[sdk/python] Fix mypy errors (#6627) 2021-03-26 15:41:08 -07:00
Komal 60cc4be9d3
[automation/*] - Add min version test for prerelease (#6612) 2021-03-24 14:00:33 -07:00
Anton Tayanovskyy 4e5828a890
Avoid double-quailfying venv folder path (#6599)
* Avoid double-quailfying venv folder path

* Replace `path` with `filepath`

* Add a Python integration test to cover venv auto-creation

* Merged

* Fix spelling

Co-authored-by: Justin Van Patten <jvp@justinvp.com>

* Make AbsPath and RelPath test variants

* Fix issue on Windows backslash paths

* Debug windows test failure: more logging and aggressive YAML escaping

* Use filepath.IsAbs instead of path.IsAbs

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-03-24 15:51:46 -04:00
Levi Blackstone 7f42d42b2b
[automation/python] Fix Settings file save (#6605)
The Project and Stack save routines were erroneously
dumping the Python objects rather than the __dict__
property, which resulted in some extra annotations
in the resulting YAML files. Some parsers don't handle
these annotations correctly, and consider the resulting
YAML file to be invalid.
2021-03-23 19:26:34 -06:00
Komal 5e5c6ffb50
[automation/nodejs,go,python] - Expose pulumiVersion as string (#6604) 2021-03-23 15:09:50 -07:00
Komal b187ce18c2
[automation/python] - Implement min version checking (#6589) 2021-03-23 08:35:11 -07:00
Anton Tayanovskyy 22f332e094
Fix docstring on node log.error and other SDK equivalents (#6573)
* Fix docstring of log.error across SDKs to explain non-termination

* Accept PR feedback, briefer docstrings.
2021-03-18 13:57:10 -04:00
Paul Stack 1d3c9edb6c
Ensure that make brew works as expected rather than passing empty version (#6566)
Fixes:#6565

As part of #6460, the logic for determing the version of the build was
moved to be a dependency on pulumictl.

Unfortunately, the homebrew installs use the "make dist" command to
build + install Pulumi to the user maching and as that would have a
dependency on pulumictl and it not existing on the user machine, it
would pass an empty version to the ldflag

This then manifested to the user as:

```
▶ pulumi version
warning: A new version of Pulumi is available. To upgrade from version '0.0.0' to '2.22.0', run
   $ brew upgrade pulumi
or visit https://pulumi.com/docs/reference/install/ for manual instructions and release notes.
```

We are able to mitigate this behaviour by bringing back the get-version
script and using that script as part of the make brew installation

We can see that the versions are the same between the 2 different
installation techniques

```
make dist <------- uses pulumict
DIST:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=2.24.0-alpha.1616029310+787eb70a" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
DIST:
BUILD:
```

```
make brew <----- uses the legacy script
▶ make brew
BREW:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=v2.24.0-alpha.1616029310+g787eb70a2" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
BREW:
```

A full post mortem will be carried out to ensure we mitigate these
types of errors going forward and that we are able to better test
these types of situations
2021-03-18 02:07:02 +00:00
Ville Penttinen 66f5d50a50
[automation/dotnet,nodejs,python] Specify exec-kind for refresh & destroy (#6530)
dotnet, nodejs and python automation APIs did not specify exec-kind for
refresh or destroy operations. This is now added following the same
logic from the go automation API.
2021-03-16 14:24:32 -07:00
Paul Stack c48ba37fcf
Migrate the version calculation to use pulumictl (#6460) 2021-03-10 19:03:29 +00:00
Meno Abels fad0393288
[sdk/python] mypy was not found (#6478) 2021-03-09 15:02:27 -08:00
Justin Van Patten 0b1414dc6d
[sdk/python] Fix mocks issue when passing a resource more than once (#6479)
This change avoids `RuntimeError: There is no current event loop in thread '<thread_name>'` errors when passing a resource as an input multiple times when using mocks.

The problem is that when using mocks, we deserialize the gRPC inputs before passing them to the user's mock methods. Deserializing inputs doesn't typically require an event loop, however, during deserialization of resource references, we end up creating some instances of `Future`, which does require an event loop to be present for the current thread. If this is done multiple times for a resource, it's possible that `deserialize_properties` will be called on an asyncio thread that doesn't yet have an event loop, resulting in the error being raised.

The error does not occur when only passing the resource reference once because typically the thread (e.g. `asyncio_0`) used in that case will have already had an event loop created for it due to the use of the internal `_syncawait` when _serializing_ the source resource's properties, which ensures an event loop is set for the thread.

The fix is to ensure an event loop is created for the thread in the mocks implementation before calling `deserialize_properties`.
2021-03-09 13:48:24 -08:00
Paul Stack 20e84dfe9e
Upgrading Go to 1.16.x (#6470) 2021-03-09 20:05:23 +00:00
Komal 48bc267445
[automation/python] - Add missing options to preview and up (#6450) 2021-03-02 10:53:39 -08:00
Komal 4a59900920
Enable python automation API tests on Windows (#6424) 2021-02-24 17:28:23 -08:00
Komal 24e07ab507
[automation/python] - Use TemporaryFile and seek() (#6421) 2021-02-24 17:21:24 -08:00
Mike Chen 256e8284d0
[automation] - Add diff to up and preview in automation API (#6413)
Co-authored-by: Mike Chen <mikechen@ip-192-168-1-8.ec2.internal>
2021-02-23 17:38:28 -08:00
Komal 8b665f7131
[automation] - Remove summary from PreviewResult (#6405) 2021-02-23 17:07:16 -08:00
Komal 5f4e687a1d
[automation] - Consume config set-all and rm-all commands (#6388) 2021-02-19 22:59:18 -08:00
Komal ca5ab18f6d
[sdk/python] - Allow Output.all with no inputs (#6381) 2021-02-18 10:11:13 -08:00
Komal a6b6437b49
[Automation] Fix python nested config parsing (#6349) 2021-02-17 10:16:35 -08:00
Komal b6f548a599
[sdk/python] - Define __all__ for better autocomplete. (#6351) 2021-02-17 09:09:10 -08:00
Justin Van Patten f111a53337
Look for python binary first on Windows (#6317)
We previously looked for `python3` and fallback to `python` on all systems. However, our Windows CI images include a `python3.exe` symlink to `python.exe` which does not work with `venv`. So on Windows, just look for `python` first, falling back to `python3`. (The default python.org Windows installation only includes `python.exe`).
2021-02-11 11:34:07 -08:00
Komal 1a9050eaa6
[sdk/python] - Allow kwargs in Output.all() to create a dict (#6269) 2021-02-11 08:52:46 -07:00
Evan Boyle 8e58f5d682
Add pagination to pulumi stack history (#6292)
replaces the unreleased `--limit` flag with `--page` and `--page-size` to support full pagination
2021-02-09 16:20:01 -08:00
Evan Boyle eefc104c2b
Add --limit flag to pulumi stack history and consume from automation api (#6257)
Adds a `--limit` flag to `pulumi stack history. This allows limiting to the last few entries rather than fetching the entirety of a stack's update history (which can be quite slow for stacks with lots of updates). Example: `pulumi stack history --limit 1` fetches the last history entry only. 

`stack.up` and related operations in the Automation API have been updated to consume this change, drastically reducing overhead.
2021-02-08 10:49:57 -08:00
Komal f374b8a953
[python/sdk] - Correctly handle outputs with properties named "values" (#6264)
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-02-05 17:16:13 -07:00
Komal 3a3b96de72
[sdk/python] - Gracefully handle monitor shutdown (#6249) 2021-02-04 20:28:39 -07:00
Justin Van Patten 2779de38ea
[sdk/python] from_input: Unwrap nested outputs in input types (#6221)
`Output.from_input` deeply unwraps nested output values in dicts and lists, but doesn't currently do that for the more recently added "input types" (i.e. args classes). This leads to errors when using args classes with output values with `Provider` resources, which uses `Output.from_input` on each input property and then serializes the value to JSON in an `apply`. This changes fixes `Output.from_input` to recurse into values within args classes to properly unwrap any nested outputs.
2021-01-29 15:44:00 -08:00
Komal 216fd2bed5
Fix the rendering of ResourceOptions.merge (#6206) 2021-01-26 15:44:12 -07:00
Komal 0f06e03931
Docstring fixups (#6194) 2021-01-25 12:22:17 -07:00
Komal 51521bbe73
Improve automation-api docs (#6178) 2021-01-22 15:12:41 -07:00
Vivek Lakshmanan 68b655bba6 Test fixes for other languages due to change in schema. 2021-01-20 11:29:01 -08:00
Paul Stack 1cff1a4bcf
[sdk/python] Adding pulumi.unsecret and pulumi.is_secret (#6111) 2021-01-14 20:37:05 +00:00
Komal dd66d8d2ab
Remove annotations import (#6109) 2021-01-14 12:36:11 -08:00
Komal 89b1d0d2c7
[automation-api/python] - Support recovery workflow (#6037) 2021-01-12 19:27:21 -08:00
Komal 059402483b
[Automation API] Python Implementation (#5979)
Co-authored-by: evanboyle <evan@pulumi.com>
2021-01-12 16:55:59 -08:00
Komal ae7d95eb87
[sdk/python] - Don't log if debug and no engine (#6067) 2021-01-07 15:23:23 -08:00
Komal d0676c19a3
Fix virtual env path (#5992) 2020-12-21 17:46:56 -08:00