Commit graph

2518 commits

Author SHA1 Message Date
Joe Duffy 12e5e46c73
Handle blank project names in 'new' (#5504)
The logic for validating prompted values in 'new' wasn't quite right,
leading to the possibility of creating Pulumi.yaml files with blank
project names.

This manifests in various ways and I've hit it a number of times
over the past few months because of the way we handle project/stack
name conflicts in 'new' -- which itself is a bit annoying too:

https://github.com/pulumi/pulumi/blob/master/pkg/cmd/pulumi/new.go#L206-L207

Because we substitue a default value of "", and because the prompting
logic assumed default values are always valid, we would skip validation
and therefore accept a blank Pulumi.yaml file.

This generates an invalid project which causes errors elsewhere, such as

    error: failed to load Pulumi project located at ".../Pulumi.yaml":
        project is missing a 'name' attribute

I hit this all the time with our getting started guide because I've
gone through it so many times and have leftover stacks from prior
run-throughs. I wouldn't be surprised if a lot of people hit this.

The solution here validates all values, including the default.

Note also that we failed to validate the value used by 'new --yes'
which meant you could bypass all validation by passing --yes, leading
to similar outcomes.

I've added a couple new tests for these cases. There is a risk we
depend on illegal default values somewhere which will now be rejected,
but that would seem strange, and assuming the tests pass, I would
assume that's not true. Let me know if that's wrong.

Fixes pulumi/pulumi#3255.
2020-10-05 13:40:24 -07:00
Mikhail Shilkov 98f04cd2fc
Ensure top-level precedence to avoid flaky tests (#5508) 2020-10-05 19:50:51 +02:00
Mikhail Shilkov 3a2d7356a2
Quit if a static passphrase is invalid (#5507) 2020-10-05 14:57:48 +01:00
Luke Hoban 3be1ea9592
Fix panic with logs (#5503)
Fixes #5112.
2020-10-02 14:09:34 -07:00
Justin Van Patten 9bcf02e7ed
Support remote components in Python (#5375) 2020-09-30 14:09:20 -07:00
Levi Blackstone 38172999e7
[codegen] Extract common test logic (#5480) 2020-09-30 14:41:52 -06:00
Levi Blackstone 64602798b1
[codegen/python] Don't generate get methods for ComponentResources (#5459) 2020-09-30 10:16:25 -06:00
Komal 59b906eb76
Update nodejs gen-tests (#5477) 2020-09-29 16:00:03 -07:00
Levi Blackstone f048c04782
[codegen/nodejs] Add support for ResourceType and isComponent (#5454) 2020-09-25 13:35:27 -06:00
Levi Blackstone 9363f606b6
[codegen/schema] Add IsComponent to resource schema (#5395)
Add support for ComponentResources to the schema by
adding a new IsComponent field to the Resource spec.
2020-09-23 18:23:46 -06:00
Levi Blackstone 81580289a7
[codegen/python] Handle ResourceType (#5444) 2020-09-23 13:39:25 -06:00
Pat Gavlin 3278b6bf91
Simplify types more precisely. (#5440)
Instead of simplifying any module that ends with `/<name>`, only simplify
types where `<name>` matches the type name portion after camel-casing.
This continues to simplify tfbridge types like `aws:s3/bucket:Bucket`,
but would not simplify a type like `aws:s3:Bucket`.
2020-09-22 10:34:16 -07:00
Levi Blackstone 3ea59ebbb8
[codegen/schema]: Add ResourceType to support resource refs (#5325) 2020-09-22 11:09:27 -06:00
Komal a334b60193
Only allow type-matching enum values (#5417)
* Only allow type-matching enum values

* More tests and fixes
2020-09-21 12:23:04 -07:00
Justin Van Patten 988ebd8b8e
[codegen/docs] Don't emit API links in Azure NextGen resource docs (#5421)
We're not going to generate language-specific API docs for the Azure NextGen provider, only resource docs. This change makes it so the resource docs do not emit any links to nonexistent API docs.
2020-09-20 11:56:52 -07:00
Luke Hoban a2a64e55d0
Support recursive object types in pkg/codegen model (#5404)
Fixes #5228.
2020-09-18 17:29:21 -07:00
Vivek Lakshmanan 5027eddce6
Merge pull request #5415 from pulumi/vl/ImportBasePath
[codegen] Allow ImportBasePath to override presumed golang import path
2020-09-18 16:16:13 -07:00
Vivek Lakshmanan a7680884eb Allow ImportBasePath to override presumed golang import path 2020-09-18 12:48:14 -07:00
Sean Holung c6dcb67677
Add pulumi console command (#5368) 2020-09-18 12:47:18 -07:00
Vivek Lakshmanan 2a23af6892 Fix panics when running invokes with modules containing slashes 2020-09-18 11:15:56 -07:00
Mikhail Shilkov 428225f992
[codegen/nodejs] Format dashed import for invokes (#5399) 2020-09-17 18:23:54 +02:00
Komal 92a7d717a4
[codegen/schema] - Expand ObjectTypeSpec to ComplexTypeSpec (#5379)
Co-authored-by: Mikhail Shilkov <github@mikhail.io>
2020-09-16 13:47:40 -07:00
Mikhail Shilkov 0d38c6737e
[codegen] Tweak docs and example generation for azure-nextgen (#5390)
[codegen] Tweak docs and example generation so that azure-nextgen is represented correctly
2020-09-16 20:11:56 +02:00
Mikhail Shilkov 573b95afaf
Add missing provider names for docs (#5374) 2020-09-16 11:28:34 +02:00
Evan Boyle 0e3666cc36
Automation API - add recovery APIs (cancel/export/import) (#5369) 2020-09-15 14:20:58 -07:00
Mikhail Shilkov da1f25928d
[codegen] Adjust Go/Python package naming for Azure NextGen (#5373) 2020-09-15 13:56:58 +02:00
Mikhail Shilkov 07a923e494 Revert Go input/output generation 2020-09-15 12:36:04 +02:00
Mikhail Shilkov 3a16cf55f0
[codegen/dotnet] Don't append Result to mixed output type names (#5321) 2020-09-15 09:33:41 +02:00
Mikhail Shilkov bbf403ba85
Do not generate unused input/output types in Go (#5345)
Do not generate unused input/output types in Go
2020-09-15 09:33:13 +02:00
Pat Gavlin 855f1fd1cd
Revise host mode. (#5317)
* Revise host mode.

The current implementation of host mode uses a `pulumi host` command and
an ad-hoc communication protocol between the engine and client to
connect a language host after the host has begun listening. The most
significant disadvantages of this approach are the communication
protocol (which currently requires the use of stdout), the host-specific
command, and the difficulty of accommodating the typical program-bound
lifetime for an update.

These changes reimplement host mode by adding engine support for
connecting to an existing language runtime service rather than launching
a plugin. This capability is provided via an engine-specific language
runtime, `client`, which accepts the address of the existing languge
runtime service as a runtime option. The CLI exposes this runtime via
the `--client` flag to the `up` and `preview` commands, which similarly
accepts the address of an existing language runtime service as an
argument. These changes also adjust the automation API to consume the
new host mode implementation.
2020-09-14 17:40:17 -07:00
Justin Van Patten 46c7c327dd
Install plugin dependencies (#5353)
When installing a plugin, if it contains a `PulumiPlugin.yaml` file with a `runtime` value of `nodejs` or `python`, install dependencies for the plugin.

For Node.js, `npm install` is run (or `yarn install` if `PULUMI_PREFER_YARN` is set).

For Python, a virtual environment is created and deps installed into it.
2020-09-14 13:54:26 -07:00
Justin Van Patten 5164725cb5
[codegen/python] Remove panic from PyName (#5341)
The codegen updates have been run against all providers, so there's no longer a need to keep the panic.
2020-09-14 08:42:01 -07:00
Justin Van Patten 5e06da464a
[codege/python] Use int as the type annotation for integers (#5309) 2020-09-11 14:56:29 -07:00
Justin Van Patten 4dd40e4490
[codegen/python] Use pulumi.runtime.to_json (#5308)
Non-string provider inputs must be projected as JSON formatted strings. The current codegen simply calls `json.dumps` for such properties, but this does not work for the new input types, which aren't JSON serializable.

To address this, make use of the new `pulumi.runtime.to_json` utility function, which is capable of serializing raw dicts and input types as JSON.
2020-09-11 14:27:36 -07:00
Paul Stack 9a46dad7d0
Add the ability to set the passphrase secrets provider to read from a passphrase file (#5327)
* Addthe ability to set the passphrase secrets provider to read from a passphrase file

* Feedback about removing newlines
2020-09-11 22:25:47 +01:00
Justin Van Patten dee923d99c
[codegen/python] Emit array types as Sequence (#5283)
We currently emit array types as `List[T]` for Python, but `List[T]` is invariant, which causes type checkers like mypy to produce errors when values like `["foo", "bar"]` are passed as args typed as `List[pulumi.Input[str]]`. Instead, we should move to using `Sequence[T]` which is covariant, and does not have this problem.

We actually already do this for `Dict` vs. `Mapping`, emitting map types as `Mapping[str, T]` rather than `Dict[str, T]` because `Mapping[str, T]` is covariant. This change makes us consistent for array types.
2020-09-10 14:54:27 -07:00
Vivek Lakshmanan e84e0401f0
Speed up doc generation by avoiding repeated python language import (#5277)
Fixes https://github.com/pulumi/pulumi/issues/5184
2020-09-10 16:12:09 +02:00
Lee Briggs 0ac075ef8f
add initial pull-request workflow (#5276)
* add initial pull-request workflow

* run SDK test all

* add SDK tests

* fixup make targets

* add dist target

* revert back to 5 updates

* disable test

* add issue for test disabling
2020-09-09 13:37:03 -07:00
Pat Gavlin 2585b86aa4
Initial support for remote component construction. (#5280)
These changes add initial support for the construction of remote
components. For now, this support is limited to the NodeJS SDK;
follow-up changes will implement support for the other SDKs.

Remote components are component resources that are constructed and
managed by plugins rather than by Pulumi programs. In this sense, they
are a bit like cloud resources, and are supported by the same
distribution and plugin loading mechanisms and described by the same
schema system.

The construction of a remote component is initiated by a
`RegisterResourceRequest` with the new `remote` field set to `true`.
When the resource monitor receives such a request, it loads the plugin
that implements the component resource and calls the `Construct`
method added to the resource provider interface as part of these
changes. This method accepts the information necessary to construct the
component and its children: the component's name, type, resource
options, inputs, and input dependencies. It is responsible for
dispatching to the appropriate component factory to create the
component, then returning its URN, resolved output properties, and
output property dependencies. The dependency information is necessary to
support features such as delete-before-replace, which rely on precise
dependency information for custom resources.

These changes also add initial support for more conveniently
implementing resource providers in NodeJS. The interface used to
implement such a provider is similar to the dynamic provider interface
(and may be unified with that interface in the future).

An example of a NodeJS program constructing a remote component resource
also implemented in NodeJS can be found in
`tests/construct_component/nodejs`.

This is the core of #2430.
2020-09-07 19:33:55 -07:00
Mikhail Shilkov 53b48cef2f
Exclude two more names from PyName (#5285) 2020-09-03 18:02:21 +02:00
Albert Zhong 69c57f8b47
Add ignorePyNamePanic python flag (#5268) 2020-09-02 16:25:19 -07:00
Justin Van Patten d583bcb915
[codegen/nodejs] Remove unnecessary ctor overload (#5274)
An extra constructor overload was recently added to pass undefined state from
`get` for resources that do not have any state inputs (notably Kubernetes
resources). This ended up breaking PaC's `validateResourceOfType`, which relies
on type inference in common usage to determine the resource's args type based
on the signature of the constructor.

This constructor overload isn't necessary. Instead, we can remove it and modify
how the constructor is called inside `get`. This also makes it so we're not
exposing details about `get`'s implementation in the public API.
2020-09-02 09:09:41 -06:00
Levi Blackstone 5ec0b985d4
[codegen/nodejs] Fix omitted output properties in constructor (#5273)
Changed the codegen in 6fd72dc0 but missed a condition that
is causing incorrect code in pulumi-kubernetes. This change
correctly generates inputs in both conditional branches.
2020-09-01 17:56:38 -06:00
Levi Blackstone 6fd72dc0db
[codegen/nodejs] Fix constructors to populate inputs on get (#5272) 2020-09-01 16:37:03 -06:00
Lee Briggs f5a54cf6bb
add more tests 2020-08-31 19:01:23 -07:00
Lee Briggs ed94132080
make function name clearer 2020-08-31 18:57:05 -07:00
Lee Briggs 0459767ceb
handle cases with no subpackages 2020-08-31 18:54:14 -07:00
Lee Briggs 6c2f7994fa
refactor and add tests 2020-08-31 16:08:15 -07:00
Lee Briggs 759019a7ad
use string index to calc package name 2020-08-31 15:36:02 -07:00
Lee Briggs 40745c126c
improve go mod replace logic
this commit updates the way we do the go mod replace during tests
2020-08-31 13:45:10 -07:00