Commit graph

486 commits

Author SHA1 Message Date
Komal 7039e67284
[codegen/nodejs] - Enums (#5472) 2020-10-07 18:13:10 -07:00
Paul Stack 5e8f219652
Reorder resource docs templates to make deprecated more prominent (#5523)
Fixes: https://github.com/pulumi/docs/issues/4340

The deprecated message sits below the examples so it is not clear
to the user that the resource / datasource is deprecated
2020-10-07 21:25:25 +01:00
Vivek Lakshmanan a0ee220243 Convert config params to outputs only if promise types are seen 2020-10-07 12:29:33 -07:00
Vivek Lakshmanan f4235f27a1 Fix config params and default handling for .NET programgen
Fixes https://github.com/pulumi/pulumi-azure-nextgen/issues/42
2020-10-07 09:59:23 -07:00
Komal b531038d33
[codegen/schema] - Add deprecation messages for enum values (#5521) 2020-10-07 09:32:00 -07:00
Vivek Lakshmanan e49ba01f8f PR comments 2020-10-06 16:13:49 -07:00
Vivek Lakshmanan ea75755d88 Add test scaffolding for azure provider 2020-10-06 16:13:30 -07:00
Vivek Lakshmanan 8f7874b3e2 Handle aliases correctly for invokes 2020-10-05 22:57:00 -07:00
Vivek Lakshmanan 739b664046 Add support for go config generation 2020-10-05 22:55:41 -07:00
Mikhail Shilkov 98f04cd2fc
Ensure top-level precedence to avoid flaky tests (#5508) 2020-10-05 19:50:51 +02: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
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 a7680884eb Allow ImportBasePath to override presumed golang import path 2020-09-18 12:48:14 -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
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
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
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
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
Mikhail Shilkov 81992485dd
Full name for aliases in .NET codegen (#5245) 2020-08-28 18:57:57 +02:00
Justin Van Patten 7eb99fe7bb
[codegen/python] Emit properties named "property" last (#5247)
This avoids conflicting with the built-in `@property` decorator function for other properties.
2020-08-28 08:55:02 -07:00
Komal 5caa5616f7
[codegen/nodejs] - Fix whitespace in genNamespace code (#5240) 2020-08-27 14:50:34 -07:00
Justin Van Patten 910aa96016
[codegen/python] Add type annotation to resource_name arg (#5217) 2020-08-25 12:07:08 -07:00
Justin Van Patten 502685ed0e
[codegen/python] Fix resource outputs type annotations (#5221)
These should be typed as `Output[T]`.
2020-08-25 11:07:22 -07:00
Mikhail Shilkov 4c42e5e850
Relax submodule generation for Node and Python (#5204) 2020-08-23 00:00:21 +02:00
Praneet Loke 072aac2c79
[codegen/docs] Lower-case the module name for Go. (#5207) 2020-08-21 15:34:57 -07:00
Mikhail Shilkov b9b3c836bc
Exclude more names from Python name validation (#5205) 2020-08-21 20:41:33 +02:00
Justin Van Patten 6292543342
[codegen/python] Fix unintended name changes from PyName and some whitespace cleanup (#5202)
If PyName(name) != PyNameLegacy(name), we panic, unless name is in an exclusion list.

Once all providers have been updated to this codegen (and we've added to `useLegacyName` and `excludeFromPanic` as appropriate), we can go back and remove the panic behavior along with the `excludeFromPanic` behavior.
2020-08-20 20:51:32 -07:00
Justin Van Patten ca7536e17f
[codgen/python] Always consider the config subpackage non-empty (#5195)
If there's a config subpackage, we had explicitly added it to the map of modules because there *are* config properties, so we know it will be non-empty. This change ensures the config subpackage is imported in the top-level package's __init__.py and that the config subpackage itself has an __init__.py emitted.
2020-08-20 11:07:09 -07:00
Evan Boyle 0f98bac105
fix unchecked type assertion (#5194) 2020-08-19 13:58:13 -07:00
Praneet Loke e3b436211d
[codegen/docs] Link to Pulumi.Input-1.html when generating the doc link for the Pulumi.Input type. (#5187) 2020-08-19 11:21:54 -07:00
Justin Van Patten 92c0d1dc30
Docgen changes for Python input/output types (#5137)
Resource doc changes for Python:

- Types are included in constructor/function args
- The property names for input/output types are now always snake_case, regardless of the generated mapping tables, to match the new input/output classes
- Some other minor tweaks to function/constructor signatures (e.g. removed the `__props__` arg, as it's not meant to be used directly; use `@staticmethod` for static `get` methods).
2020-08-19 08:34:06 -07:00
Mikhail Shilkov 6cc7b3c107
Docs for versioned modules (#5183) 2020-08-19 14:57:39 +02:00
Justin Van Patten 78edb28590
Add Python input/output classes to provider codegen (#5034)
This updates the Python codegen to emit input/output classes.
2020-08-19 01:16:47 -07:00
Vivek Lakshmanan 8777dd77ca
Merge pull request #5170 from pulumi/vl/ResourceOptions
Map python resource options to provider options
2020-08-17 17:36:05 -07:00
Vivek Lakshmanan f6fd98544d
Update pkg/codegen/python/gen.go
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2020-08-17 16:58:59 -07:00
Komal d7ce0e586c
[codegen/python] - Include single word props in casing tables. (#5181) 2020-08-17 16:44:55 -07:00
Vivek Lakshmanan 38387f1742 Set the snake case translation for provider input properties
Fixes https://github.com/pulumi/pulumi-kubernetes/issues/1244
2020-08-14 14:34:46 -07:00
Praneet Loke 99fcd359ee
[codegen/docs] Fix the case used in links for Node.js modules. (#5165) 2020-08-13 17:29:56 -07:00
Evan Boyle c9d8549ae6
[Go Program Gen] Only generate a single literal when traversing a union type (#5154) 2020-08-11 11:43:56 -07:00
Albert Zhong 2cd0c000bd
[codegen] Add codegen/go/gen_crd2pulumi, clean up codegen/nodejs/gen_crd2pulumi (#5116)
* Add codegen/go/gen_crd2pulumi

* Properly generate Go CRD resources

* generate nodejs resources

* Remove nodejs/gen_crd2pulumi.go

* Remove generating funtions
2020-08-10 10:21:50 -07:00
Komal 2f2e62e2e4
[codegen/python] - Normalize module names in program gen (#5128) 2020-08-07 09:30:07 -07:00
Mikhail Shilkov 0c9d1fdd0e
Fix C# program gen for Kubernetes examples (#5129) 2020-08-07 09:31:42 -06:00
Pat Gavlin e5f44a7b0c
Use a package map where appropriate (#5127)
* Use a package map where appropriate

* Fix imports

* handle NoneType for literal value expressions in go program gen

* add operator tests for c#, python, and node

Co-authored-by: evanboyle <evan@pulumi.com>
2020-08-06 19:09:18 -07:00
Komal ff219a2381
Use input/output classes in program gen (#5086) 2020-08-06 15:09:23 -07:00
Levi Blackstone ba18683d9a
[codegen] Generate null values for model.NoneType (#5122) 2020-08-06 14:12:27 -06:00
Evan Boyle fbf391fd4b
Merge pull request #5115 from pulumi/evan/fixKubeProgramGen
[Go Program Gen] Fix various Kubernetes issues
2020-08-05 17:30:23 -07:00
Levi Blackstone 3286aae20d
[codegen] Make schema and package available to HCL2 codegen (#5114) 2020-08-05 17:27:17 -06:00
Pat Gavlin 63db7e0d46 Use the existing contexts map. 2020-08-05 16:11:12 -07:00
evanboyle 9425016521 add todos 2020-08-05 15:50:07 -07:00
evanboyle 2c350b08d8 lint 2020-08-05 15:31:12 -07:00
evanboyle 2f71fbbf2d traverse object and tuple cons expressions for imports 2020-08-05 15:23:36 -07:00
Komal 269b537e57
[codegen/python] - Fix python resource tokens (#5107) 2020-08-05 12:50:54 -07:00
evanboyle 8af3be1e3f account for import aliases in program expressions 2020-08-05 12:44:46 -07:00
evanboyle e2e6db47f7 use import aliases in Go program gen 2020-08-05 11:42:38 -07:00
Komal d2dd990866
[codegen/python] Fix pyname bug (#4918) 2020-08-05 10:08:52 -07:00
Evan Boyle 13ee9fd4c8
tests for kubernetes program generation (#5105) 2020-08-05 09:15:36 -07:00
Albert Zhong 06fa515bf7
[codegen/nodejs] Refactor genNamespace, add crd2pulumi (#5084)
* Refractor genNamespace, add crd2pulumi

* Rename to genCRDNamespaces()

* Rename crd2pulumi genCRDNamespaces function
2020-07-31 18:29:00 -07:00
Mikhail Shilkov 044bb6bb61
Match module versions also outside the kubernetes compat flag (#5088) 2020-07-31 21:50:34 +02:00
Mikhail Shilkov 526e5264b8
Handle resource_name properties to avoid conflicts in Python codegen (#5052) 2020-07-30 16:29:36 +02:00
Lee Briggs c9fedef887
Merge pull request #4947 from pulumi/jaxxstorm/provider-info
add plugin download url metadata to package spec
2020-07-21 12:03:09 -07:00
Sean Fausett a38bbaa221
Enable SourceLink with embedded PDB (#4967) 2020-07-21 16:55:08 +02:00
Lee Briggs 3b0462f0e0
Merge branch 'master' into jaxxstorm/provider-info 2020-07-20 17:35:47 -07:00
Gabriel Diaz ffb8c2400d
Fix semicolon in python docs (#5025) 2020-07-17 21:16:30 -07:00
Praneet Loke 67525ee4b1
[codegen/schema] Skip processing a line if the block position is greater than the length of the line. (#5002) 2020-07-16 16:59:06 -07:00
Pat Gavlin 00fbbb6544
[codegen/hcl2] Fix nested apply rewrites (#5013)
Rewrites that should produce nested applies due to functions that return
eventual types were instead producing a single top-level apply. These
changes fix that by considering a function that produces an eventual
value as inspecting eventual values.
2020-07-16 10:26:10 -07:00
Komal 1a10e06588
Add a helper function to clean the codegen dir (#5018) 2020-07-15 16:11:37 -07:00
Komal 6682da5fa5
[codegen/python] Add underscores to private modules to avoid exporting them. (#4959) 2020-07-15 13:10:52 -07:00
Pat Gavlin 4961567ecf
[codegen/hcl2] Add a template trivia constructor (#5009)
Just what it says on the tin. Currently it's not possible to create a
valid value of this type because the `bytes` field is unexported. This
constructor fixes that.
2020-07-14 12:07:44 -07:00
Pat Gavlin 86599a06a6
[codegen/hcl2] Fix applies on relative traversals. (#5008)
The apply rewrite for relative traversals did not consider whether or
not the receiver was eventually-typed, and did not properly check
whether or not the relative traversal itself was eventually-typed. These
changes correct those mistakes.
2020-07-14 12:07:35 -07:00
Pat Gavlin a19843f433
[codegen/{go,nodejs,python}] Normalize modules. (#5006)
In general, a package/module name in these targets is derived from the
module portion of a type token. If the type token is not already in an
expected form--namely, all lowercase--the generated package/module names
will also be in unexpected forms. These changes normalize the module
names to lowercase s.t. the generated package/module names conform to
expectations.
2020-07-14 10:58:29 -07:00
Pat Gavlin 54c5a75e34 [codegen/{go,nodejs}] Minor fixes in SDK gen.
- NodeJS: fix get + constructor generation for types with required args
  and no state type.
- Go: fix type + import generation for properties in the root module.
2020-07-10 11:23:31 -07:00
Pat Gavlin dff1299be4
[codegen] Add a code generator for resource state. (#4982)
Add a new package, `codegen/importer`, that can generate definitions for
resource states in PCL or TS/Python/C#/Go. The pipeline is relatively
simple: given a list of resource states, generate a PCL program in
memory, bind it, and pass it to the language-specific code generator.
This builds upon the existing PCL IR, and can be used with the currently
supported code generators.

Related to #1635.
2020-07-08 19:12:37 -07:00
Komal bdc86e002a
Change how submodules are imported to work with Intellisense (#4948) 2020-07-08 18:34:59 -07:00
Komal 0ede17ced2
Remove duplicated methods (#4985) 2020-07-08 16:50:46 -07:00
Praneet Loke 1acc8231b1
[codegen/docs] Use the correct format for package name when module name is empty (#4889)
* Use the correct format for package name when module name is empty.

* Add an exclusion for Docker's Image component resource when generating the Python formal params.

* Prefix the type name with the package name when linking to Python function names.
2020-07-07 17:24:07 -07:00
Pat Gavlin d07c3698e5
[codegen/{hcl2,schema}] Abstract package loading. (#4975)
Instead of requiring a plugin host for package loading in the HCL2
binder, define a much narrower interface that exposes the ability to
fetch the schema for a package at a specific version. This interface is
defined in the schema package, which also exposes a caching loader that
is backed by provider plugins.

These changes also add some convenience methods to `*schema.Package` for
fast access to particular resources and functions.

Related to #1635.
2020-07-07 14:45:18 -07:00
Pat Gavlin 2d530e8038
[hcl2] Fix tokenless body item printing. (#4974)
In general, each item in an HCL2 body must be followed by a trailing
newline. The printer did not properly insert these newlines for body
items without any associated tokens/trivia, or with trivia that did not
include a trailing new line.

Related to #1635.
2020-07-07 13:46:26 -07:00
Levi Blackstone 9325c90946
[codegen/docs] Document kustomize API (#4960) 2020-07-07 12:54:52 -06:00
Komal 56fa087bd6
[codegen/python] pep-8 compliant spacing (#4958)
* pep-8 compliant spacing

* PR fixes
2020-07-07 11:32:48 -07:00
Paul Stack 0e9b865f68
Adding the missing providers to the docs generation titleLookup Map (#4970) 2020-07-06 15:24:51 +01:00
Levi Blackstone d611740ab0
[codegen] Set additionalSecretOutputs for secret props (#4956) 2020-07-02 13:30:10 -06:00
Lee Briggs af2580c10a
Fix incorrect packagespec field name 2020-07-02 09:40:31 -07:00
Lee Briggs c25cbf0fc8
switch terminology to plugin download URL
After a discussion about terminology, the better phrasing is to use
pluginDownloadURL
2020-07-02 09:29:19 -07:00
Lee Briggs f310c21b85
Add providerURL to package definition 2020-07-01 19:10:25 -07:00
Levi Blackstone 137f39151b
[codegen] Add Secret field to Property schema (#4943) 2020-07-01 14:17:49 -06:00
Levi Blackstone 956d362d8b
[codegen] Don't log deprecation warnings in k8s SDKs (#4942)
The k8s SDK logs deprecations warnings as part of the
provider logic, and includes a flag to suppress these
warnings. Including them in the SDKs breaks this logic.
2020-07-01 13:50:26 -06:00
Mikhail Shilkov de2a6500cd
Do not import non-existing inputs or outputs in Node.js codegen (#4937)
Do not import non-existing inputs or outputs in Node.js codegen
2020-07-01 21:47:46 +02:00
Levi Blackstone 92cb042aee
[codegen/dotnet] Add LanguageResource for downstream codegen (#4932) 2020-06-30 16:19:21 -06:00
Pat Gavlin a8a20ecb4b
[codegen/*] Add support for explicit secrets. (#4927)
- Add a new builtin function, secret, that marks its input value as
  secret
- Add support for this function to the various code generators

Fixes #4924.
2020-06-30 11:35:24 -07:00
Mikhail Shilkov bb358c4d21
Escape \x in Python comments (#4922) 2020-06-30 11:19:45 +02:00
Evan Boyle 395a68e0f6
[Go program gen]: namespaceless resources (#4915) 2020-06-29 18:10:34 -07:00
Pat Gavlin 69ba47cff2
[codegen/*] Add support for resource options. (#4925)
The PCL binder has supported resource options for some time, but these
options haven't been used or processed by the various code generators.
These options--particularly the parent and provider options0--are
critical for import codegen. These changes implement the basic set of
options, and add a note about fleshing out the rest as necessary.

One component of these changes is a new rewriter that rewrites property
references into property paths that are understood by the Pulumi engine.
This rewriter is used to preprocess the contents of the `ignoreChanges`
resource option.

These changes also hack around a weakness in the HCL2 type system:
In Go, references to resources should be typed as `hcl2.ResourceType`.
Unfortunately, this breaks the existing collection semantics associated
with resources. Because of this, the Go code generator does not have
enough information to know that it should generate a `[]pulumi.Resource`
for lists of resources. These changes hack around that limitation using
a Go-specific opaque type and some hardcoded comparisons in
`argumentTypeName`.

Fixes #4923.
2020-06-29 16:33:52 -07:00
Evan Boyle 91828b4310
[Go Program Gen] Improved handling for pulumi.Map types (#4914) 2020-06-29 15:29:41 -07:00
Mikhail Shilkov 14a3871346
Avoid stack overflow in Python codegen in case of recursive types (#4908) 2020-06-26 20:47:13 +02:00
Komal 3eacf8bf90
[codegen/python] Only add item to map if it doesn't already exist. (#4907) 2020-06-26 09:05:36 -07:00
Komal b35a94cac6
[codegen/python] - Exclude single word properties from casing tables. (#4895)
Co-authored-by: Levi Blackstone <levi@pulumi.com>
2020-06-25 11:51:57 -07:00
Komal 93fa20a44b
[codegen/python] - Only import json when needed (#4892) 2020-06-25 09:59:00 -07:00
Evan Boyle fa3000801e
skip transient test (#4886) 2020-06-24 13:53:18 -07:00
Komal ed752bc384
[codegen/python] Don't use __all__ (#4873) 2020-06-24 11:41:03 -07:00
Evan Boyle 31770c3300
go program gen: prompt array conversion, unused range vars, id handling (#4884) 2020-06-24 11:07:26 -07:00
Komal 669448ab40
[codegen/python] Use CamelCase filenames for k8s. (#4878) 2020-06-23 13:02:22 -07:00
Evan Boyle 4ea1f011c6
Merge pull request #4858 from pulumi/evan/goProgramAllApplyRewrite
Go program gen: All.Apply func rewriter
2020-06-23 11:00:20 -07:00
Evan Boyle b302dbcbca
go program gen: lift expressions where prompt optionals are required (#4875) 2020-06-23 10:59:26 -07:00
Komal 1837c0a779
[codegen/python] Allow setting constant values for props (#4864)
* Allow setting constant values for props

* PR feedback
2020-06-22 10:58:13 -07:00
Komal 9a62c92efc
[codegen/python] Add missing props to casing table (#4863) 2020-06-22 09:49:34 -07:00
Levi Blackstone 096a406691
[codegen] Generate correct opts type for ComponentResources (#4853)
The docs generator previously assumed that the opts parameter
for every resource was of the CustomResource type. This is
incorrect for the YAML and Helm overlays, which are
ComponentResources. This should be handled more generally
once our schema supports ComponentResources, but this fixes
the docs for now.
2020-06-22 10:27:17 -06:00
Levi Blackstone 282c95ee40
[codegen] Use nullish coalescing for provider defaults on k8s (#4841)
For the NodeJS k8s SDK, rather than falling back to default values
using the || operator, use the nullish coalescing operator (??).
This avoid situations where the primary value is set to false,
and then is overridden by the default value.
2020-06-22 09:38:20 -06:00
Komal 14ef36553d
[codegen/python] Add whitespace to make the linter happy (#4857) 2020-06-18 17:32:52 -07:00
evanboyle 2ba1fd608a go program gen All.Apply func rewriter 2020-06-18 17:17:51 -07:00
evanboyle 7f2a83ae5a Revert "go program gen All.Apply rewriter"
This reverts commit bdd240f522.
2020-06-18 16:57:55 -07:00
evanboyle bdd240f522 go program gen All.Apply rewriter 2020-06-18 16:56:26 -07:00
Komal 63e7388879
[codegen/python] Remaining k8s updates (#4786) 2020-06-18 15:46:17 -07:00
Evan Boyle 8b8170252b
[Go Program Gen] multiline strings, get/lookup disambiguation, webserver example (#4850) 2020-06-18 13:34:22 -07:00
Pat Gavlin 4a903f95b9
[codegen/docs] Reimplement example extraction. (#4851)
Use the schema package's Markdown parser and walk its AST to extract
examples.

These changes also rename StripNonRelevantExamples to FilterExamples.

This is preparatory work for #4159 and #4632.
2020-06-18 12:32:15 -07:00
Paul Stack 49eb06b2f0
Merge pull request #4846 from pulumi/python-deprecation-escaping
Escape deprecation messages coming from upstream TF providers
2020-06-18 08:42:26 +01:00
Evan Boyle 9cdddd2566
[Go Program Gen] Support for EKS example (#4831) 2020-06-17 17:19:39 -07:00
Pat Gavlin 3d4c6523d2
[schema/docs] Use a Markdown parser. (#4838)
In particular, use the parser to filter and extract examples. This also
sets up support for entity references in documentation that can be used
in order to render language-specific names for resources, functions,
types, and properties.

Related to #4632 and #4159.
2020-06-17 14:02:45 -07:00
stack72 0a93270ffd Escape deprecation messages coming from upstream TF providers
Fixes: #4827

Diff:

```
             if encrypted is not None:
-                warnings.warn("Rename PostgreSQL role resource attribute "encrypted" to "encrypted_password"", DeprecationWarning)
+                warnings.warn("Rename PostgreSQL role resource attribute \"encrypted\" to \"encrypted_password\"", DeprecationWarning)
                 pulumi.log.warn("encrypted is deprecated: Rename PostgreSQL role resource attribute "encrypted" to "encrypted_password"")

```
2020-06-17 20:25:06 +03:00
Komal 92e44bee6d
[codegen/python] Handle extra files (#4842) 2020-06-16 19:27:06 -07:00
Evan Boyle 2d61852e4f
Go program gen: resource range, readDir, template strings, etc (#4818) 2020-06-15 23:00:02 -07:00
Komal f9074f6bcb
[codegen/python] - Exclude nested docs for k8s (#4828) 2020-06-15 16:17:05 -07:00
Komal 481750ec5b
[codegen/python] Fix edge case in relative import (#4809) 2020-06-11 15:31:39 -07:00
Komal ea3d6aa005
[codegen/python] Don't use config for k8s (#4807) 2020-06-11 11:52:26 -07:00
Komal 5ec251ae66
[codegen/python] Fix relative import path (#4796) 2020-06-11 09:10:53 -07:00
Komal 074eb67e82
[codegen/python] Add newlines to be pep8 compliant (#4797) 2020-06-10 15:11:59 -07:00
Komal d699627ff6
[codegen/python] Fix k8s __init__.py generation (#4795)
* Fix k8s __init__.py generation

* Add comment for regex
2020-06-10 13:55:10 -07:00
Evan Boyle 45a901d3e7
Turn program gen NYIs into diagnostic errors (#4794) 2020-06-10 10:21:53 -07:00
Komal 238adf2f2f
[codegen/python] Allow import path overrides (#4787)
* Allow import path overrides

* Fix typo

* Rename ModuleToPackage to ModuleNameOverrides
2020-06-09 14:33:02 -07:00
Komal b93259c6bb
[codegen/python] Fix readme generation (#4759)
* Fix readme generation

* Allow readme text to be passed in with the package.
2020-06-08 13:07:56 -07:00
Komal 6c29b67c03
[codegen/python] Fix doc generation in python codegen (#4757) 2020-06-08 12:44:57 -07:00
Pat Gavlin 9754465b04
[codegen/nodejs/sdk] Export extra files. (#4766)
If extra files are present, make sure that appropriate modules are
created as necessary and that extra sources are exported from each
module's `index.ts`.
2020-06-07 09:21:09 -07:00
Evan Boyle 94cd67b564
[Go Program Gen] Improved type handling and invokes (#4749) 2020-06-05 18:52:00 -07:00
Levi Blackstone 7254779b28
[codegen/nodejs] Fix k8s index.ts generation (#4756) 2020-06-05 16:41:07 -06:00
Levi Blackstone 875c4dab89
[codegen/nodejs] Fix remaining issues with k8s codegen (#4325) 2020-06-05 11:11:18 -06:00
Pat Gavlin e6fb3ef0f8
[codegen/nodejs/sdk] Fix token type config getter. (#4753)
If the type of a configuration variable is a token type (i.e. a type
provided by an overlay) with the underlying type string, call
`config.get` rather than `config.getObject`. This fixes a regression in
the `aws.config.region` variable.
2020-06-04 14:51:21 -07:00
Paul Stack 58002bae62
Ensuring a property level deprecation warning is set for python codegen (#4744) 2020-06-04 11:29:23 +01:00
Levi Blackstone 8a7e10d37a
[codegen/nodejs] Refactor GeneratePackage method (#4737)
- Split out common functionality into generateModuleContextMap method
- Add LanguageResource and LanguageProperty structs for use by downstream
codegen tools
- Add LanguageResources function for use by downstream codegen tools
2020-06-03 19:20:32 -06:00
Pat Gavlin bd1c0e6d7b
[codegen/schema] Support default union types. (#4746)
Add support for union types that indicate a default type for targets
that do not support unions, or do not support unions in certain
positions (e.g. output properties). The NodeJS backend makes use of this
in combination with a new flag, `disableUnionOutputTypes`, to avoid
generating unions in output types.

These changes also refactor the various module ->
package/module/namespace mapping methods so that these entities can be
fetched by their language name rather than their token.
2020-06-02 18:15:21 -07:00
Pat Gavlin d77cda98fc
[codegen/hcl2] Fixes for RewriteConversions. (#4743)
- Typecheck in all cases where a type may have changed
- Do not perform literal conversions if the type is already correct
- Perform literal conversions before checking to see if a call to
  `__convert` is required. This catches cases such as string literals
  passed where ints are required. Without this change, that form in
  particular generates a bare number literal rather than a number
  literal wrapped in a `__convert`.
2020-06-02 12:00:35 -07:00
Pat Gavlin 962fe01734
[codegen/nodejs/sdk] Do not write reserved files. (#4742)
If the source file for a resource or function definition would collide
with a reserved filename (e.g. `index.ts`), append an underscore to its
filename (e.g. `index_.ts`).
2020-06-01 16:24:21 -07:00
Pat Gavlin 726d43a5bd
[codegen/nodejs/sdk] Split required {in,out}puts. (#4736)
These changes are necessary in order to move tfgen over to the schema
code generator.

The schema generator for tfgen has an annoying behavior for nested types
in which it does not separate input and output types. Worse, the shape
of the type that results from a collision of input and output types is
order-dependent: whichever of the two was observed last wins (note that
the shape is still determenistic, as the order in which types are
recorded is always the same). As a result, the NodeJS code generator
needs to know the set of required properties for the other aspect of the
type in order to generate proper code.

Contributes to
https://github.com/pulumi/pulumi-terraform-bridge/issues/179.
2020-06-01 11:50:10 -07:00
Levi Blackstone 9b980c14f2
Address NodeJS codegen feedback (#4734)
Follow up on feedback for https://github.com/pulumi/pulumi/pull/4730
2020-05-29 16:35:42 -06:00
Levi Blackstone 3fd51da719
Add k8s compatibility mode for NodeJS codegen (#4730) 2020-05-29 13:39:29 -06:00
Levi Blackstone d0388e5525
Only generate top-level README in NodeJS packages (#4729) 2020-05-29 13:36:16 -06:00
Mikhail Shilkov cf8b6c1237
Convert primitive types in C# program gen (#4686) 2020-05-29 12:38:53 +02:00
Pat Gavlin 75c3ccf53d
[codegen/nodejs/sdk] Minor fixes. (#4725)
- Only wrap field types in `pulumi.Input<>` in types that are part of
  the input SDK.
- Ensure that READMEs have a trailing newline.

Contributes to https://github.com/pulumi/pulumi-terraform-bridge/issues/179.
2020-05-28 16:24:48 -07:00
Levi Blackstone a8486520a3
Update NodeJS codegen to use codegen.StringSet (#4724) 2020-05-28 17:22:50 -06:00
Levi Blackstone 754a4ae51d
Fix NodeJS codegen to handle recursive types (#4723)
Track the input/output types that have been encountered
and don't recurse into previously seen types.
2020-05-28 16:37:39 -06:00
Evan Boyle 9b2c6d726d
[Go Program Gen] binary, unary, and conditional expression support (#4716) 2020-05-28 13:47:49 -07:00
Komal e2ba2a067c
Fix typo in nodejs importer (#4711) 2020-05-27 08:58:27 -07:00
Evan Boyle c8142677cc
expression tests for basic go program literals (#4709) 2020-05-27 07:32:13 -07:00
Mikhail Shilkov b6f61b45ad
Don't mark provider token string types with json attribute in C# (#4658)
Don't mark provider token string types with json attribute in C#
2020-05-27 10:14:38 +02:00
Mikhail Shilkov c66192130a
Small bug fixes in C# codegen (#4702) 2020-05-26 19:12:56 +02:00
Pat Gavlin e973ec0491
[codegen/hcl2] Fix assignability from dynamic. (#4704)
Types like output(T), promise(T), and union(T_0, ..., T_N) should be
assignable from dynamic if they contain an element type that is
assignable from dynamic.

This allows consumers to use the following code to check if some type
behaves like the dynamic type w.r.t. conversions:

```
if t.AssignableFrom(model.DynamicType) {
}
```

Fixes #4703.
2020-05-26 09:05:42 -07:00
Pat Gavlin cb8066d74a
[codegen/hcl2] Fix ForExpression.Evaluate. (#4701)
This expression was not evaluated correctly when producing a dictionary.
2020-05-26 09:05:35 -07:00
Pat Gavlin 05032d6850 [codegen/hcl2] Fix assignability from dynamic.
Types like output(T), promise(T), and union(T_0, ..., T_N) should be
assignable from dynamic if they contain an element type that is
assignable from dynamic.

This allows consumers to use the following code to check if some type
behaves like the dynamic type w.r.t. conversions:

```
if t.AssignableFrom(model.DynamicType) {
}
```

Fixes #4703.
2020-05-26 08:21:09 -07:00
Evan Boyle ea114b04ee
output generation for s3 logging example (#4681) 2020-05-26 07:07:54 -07:00
Sean Holung c538db64c8
Anchoring properties (#4488) 2020-05-22 14:53:34 -07:00
Pat Gavlin 5330c97684
[codegen/hcl2/model] Remove type caches. (#4683) 2020-05-22 10:47:34 +01:00
Mikhail Shilkov 7e3b60b3d1
Fix C# (and a bit of Node.js) program gen based on errors from AWS samples (#4673) 2020-05-22 08:46:25 +02:00
Evan Boyle 8dd329f57f
Go basic program gen (#4667) 2020-05-21 10:23:33 -07:00
Mikhail Shilkov adfa8116fb
Introduce k8s compatibility mode to C# codegen (#4544)
Introduce k8s compatibility mode to C# codegen
2020-05-19 11:41:06 +02:00
Mikhail Shilkov f66100ce28
Initial support for C# program gen (#4611)
Initial support for C# program gen
2020-05-19 10:18:38 +02:00
Pat Gavlin 088751a4a8
[codegen/hcl2] Refactor package schema loading. (#4661)
- Move the implementation of loadPackageSchema into a method on
  PackageCache
- Protect the cache with synchronization primitives to enable
  concurrency in downstream consumers
- Use jsoniter to deserialize schemas
2020-05-18 17:35:11 -07:00
Praneet Loke 30b12cff49
[codegen/docs] Various Go-related fixes (#4646)
* Remove code that was hiding Go as a language option for k8s overlay resources. Mark input args type for Functions as optional in Go.

* Show a special note in the Go function's snippet when the function name does not match other languages.

* Make sure the draft PR stays assigned to the original author. Add some more comments.

* Remove logic to use the Go ModuleToPackage map to then lookup the relevant C# namespace. Make getLanguageModuleName a method of modContext since passing in a package is not needed anymore.
2020-05-15 17:33:56 -07:00
Mikhail Shilkov 5b410ec440
Resolve referenced packages for every TF program (#4636) 2020-05-15 19:18:07 +02:00
Sean Holung f5ed6190ba
Link Python and Go constructors (#4593) 2020-05-15 09:51:24 -07:00
Pat Gavlin e9dd0e5e69
[codegen/schema] Path unescape type tokens in refs (#4641)
Some type tokens contain characters that are not valid in a single
URL path element (`/` in particular). These type tokens may be
path-escaped, and should be unescaped before they are interpreted.
2020-05-14 13:35:57 -07:00
Evan Boyle 0d257bb32d
go gen_program shell + test + sample (#4630) 2020-05-14 08:43:12 -07:00
Pat Gavlin 8f0a002a26
Generate deprecation comments in Go. (#4631)
This is consistent with the convention for marking members as
deprecated: https://github.com/golang/go/wiki/Deprecated.
2020-05-13 17:12:59 -07:00
Pat Gavlin 99852bc18e
[codegen/nodejs] SDK generator fixes. (#4618)
- Add support for constant values in unions (e.g. `"foo" | "bar"`)
- Generate `Input<T | U>` instead of `Input<T> | Input<U>`
- Emit deprecation messages for resources
- Handle nil state inputs
- Allow packages to provide a README
- Remove sync invoke support

These changes are part of
https://github.com/pulumi/pulumi-terraform-bridge/issues/179, and
restore functional parity with the current `tfgen` generator.
2020-05-13 10:55:37 -07:00
Praneet Loke 54f5a0ac36
[codegen/docs] Use the C# namespaces override map for links. (#4616) 2020-05-13 09:32:40 -07:00
Pat Gavlin 647b6627a2
[codegen/hcl2] Fix descent in RewriteConversions. (#4614)
Descend into anonymous function expressions, the operands to conditional
expressions, and the value in for expressions.
2020-05-13 08:25:26 -07:00
Praneet Loke fcac4af8ae
[codegen/docs] Generate a table with links to the language-specific module pages (#4597)
* Generate language package details in the index pages.

* Add a new DocLanguageHelper interface method to get to a module per-language. 

* Add a new workflow file for automatically creating draft docs PRs for previewing resource docs for AWS and Kubernetes as a result of changes in the resource docs generator.
2020-05-12 15:37:37 -07:00
Pat Gavlin 33258326e0
[codegen/hcl2] Add a conversion insertion pass. (#4594)
Add a rewriter that reifies implicit conversions into a call to the
`__convert` intrinsic. Code generators can recognize this intrinsic and
use it to generate appropriate conversion code.

Part of this work involves redesigning the type annotations system.
Annotations are now only applicable to opaque and object types. Instead
of inspecting annotations directly, code generators should use
`hcl2.GetSchemaForType` to extract the `schema.Type` for a `model.Type`.
2020-05-11 11:17:36 -07:00
Pat Gavlin 255620ea1e
[codegen/nodejs] Await invokes in async contexts. (#4598)
If we are generating code into an async context (e.g. an async main),
await calls to invoke rather than leaving them as promises. This results
in more idiomatic code withing such contexts.
2020-05-11 10:21:56 -07:00
Praneet Loke aa313aecf8
[codegen/docs] Add a new template for examples section (#4591)
* Add a new template for examples section. Extract the examples section into a structured format for custom template processing.

* Update the description IFF we were able to extract examples sections from it.

* Update doc comments and add missing file header for the newly added file.

* Make the example description readable. Add a check for empty example sections.

* Add a chooser right below the Example Usage header. Remove javascript as a language.

* Allow an empty new-line between short-codes boundaries.
2020-05-08 16:25:28 -07:00
Praneet Loke 5613867b3b
[codegen/docs] Add apiextensions as a k8s overlay resource (#4583)
* Add apiextensions as a k8s overlay. Add comment.
2020-05-08 11:13:21 -07:00