Commit Graph

18 Commits

Author SHA1 Message Date
Zaid Ajaj fe5e65f0f4 Allow binding unsupported range and collection types in non-strict mode for pulumi convert 2023-07-12 19:13:57 +02:00
Zaid Ajaj ed02926277 Allow generating code for unknown invokes in non-strict mode 2023-07-10 15:05:18 +02:00
Fraser Waters 571fadae3f Use slice.Prealloc instead of make([]T, 0, ...)
Fixes https://github.com/pulumi/pulumi/issues/12738

https://github.com/pulumi/pulumi/pull/11834 turned on the prealloc
linter and changed a load of slice uses from just `var x T[]` to `x :=
make([]T, 0, preallocSize)`. This was good for performance but it turns
out there are a number of places in the codebase that treat a `nil`
slice as semnatically different to an empty slice.

Trying to test that, or even reason that through for every callsite is
untractable, so this PR replaces all expressions of the form `make([]T,
0, size)` with a call to `slice.Prealloc[T](size)`. When size is 0 that
returns a nil array, rather than an empty array.
2023-06-29 11:27:50 +01:00
Zaid Ajaj 7e5e452909 Extend SkipResourceTypechecking to allow generating unknown resources 2023-06-14 19:02:56 +02:00
Abhinav Gupta e395deef6b
all: Assert => Assertf
Migrates all remaining usages of
`contract.Assert*` and `contract.Require*` to the f variants,
which require adding meaningful error messages.

There were a couple cases where a `testing.T` or `testing.B`
was already available.
For those, this uses t.FailNow or require.NoError.

Refs 
2023-03-03 14:37:43 -08:00
Ian Wahbe 8e99749c1a Interpret schema.Asset as pcl.AssetOrArchive 2022-12-08 16:00:17 +01:00
Ian Wahbe 6d4b3d619b Simplify `findFunctionSchema`
Update test output

Expose a token lookup method in PCL, and then use it instead of
`schema.PackageReference.Functions().Get`.
2022-12-07 15:05:28 +01:00
aq17 927e9d4a69 Improve error msg for invalid enum values on convert 2022-12-01 15:29:22 -08:00
Ian Wahbe d770162254 Remove traverse errors on dynamic types
Preserve traverser src range

Improve testing diags

Re-enable resource type checking

Warn instead of skipping missing resources

Improve explination for the new test

Get test to generate output

Reenable forceing resource type checking

CL

Fix TestBindProgram

Cleanup PR
2022-11-16 14:41:30 -08:00
aq17 525849bf17 Support options.version on pulumi convert 2022-09-23 09:41:17 -07:00
Alex Qiu b1557bc5ec
Fix StackReference code gen () 2022-08-19 10:27:05 -07:00
Aaron Friel c2e196bf3f
[codegen] Simplify program generation for explicit providers () 2022-07-19 09:26:40 -07:00
Aaron Friel 5e7e39a941
[codegen] simplify opaque types to string newtype () 2022-06-13 11:13:03 -07:00
Pat Gavlin 36cbf572f4
[schema] Add support for on-demand binding. ()
These changes extend the public API of `pkg/codegen/schema` to support
on-demand binding of package members. On-demand binding is appropriate for
scenarios that do not require the entire package, especially those such as
program code generation or the YAML LSP server that require only specific
types/functions/etc.

The extensions to the public API consist of two new types and several new
methods. The most notable of these are `PackageReference` and
`Loader.LoadPackageReference`. The former provides the on-demand binding
interface, while the latter creates instances of the former (n.b. it was
my intent to make a breaking change to the signature of `Loader.LoadPackage`
s.t. it returns a `PackageReference`, but the circular dependency between
this Go module and those for YAML and Java prevented that change).

These changes _dramatically_ reduce the memory required to interace with
Pulumi Packages, and only require memory proportional to the number of
accessed package members. We may be able to improve on this in the future
by removing type/resource/function interning, which would allow those
values to be garbage collected at a granaular level rather than at a
package level. That is a more radical change, though, as it requires new
equality semantics for each of the affected types (some of which are
currently used as map keys).
2022-05-23 15:44:35 -07:00
Aaron Friel 1da317dcc9
[codegen] Improve handling of resources with outputs that are resources. () 2022-05-20 10:29:05 -07:00
Ian Wahbe 183fa89163
Add an EnumType to the PCL model ()
* Add an EnumType to the PCL model

Languages implementation:
- [X] C#
- [X] Python
- [X] TypeScript
- [X] Go

* Fix assert

* Take namespace settings into account

* Implement enums for Go

* Update tests and add documentation.

* Add a test + handle output&unsafe

* Get outputs compiling for Go

* Line up types for Go

* Add nodejs

* Add Python

* Change expression form

* Fix nil check (`==` -> `!=`)

* Standardize nodejs & python checks

This should fix the Node OOM error.

* Rename enum-py to typed-enum-pp

* Don't reference schema types in `hcl2/model`

* Fix nits
2022-04-18 11:03:42 +02:00
Ian Wahbe 7da81c1d7f
PCL: Use resource aliases when resolving a type ()
* PCL: Use resource aliases when resolving a type

* Add a test

* Fix lint

* Fetch schemas in the makefile

Because we have exposed the `TestProgramCodegen` function to the public,
we can no longer pin specific schema version from that function. In
general, we should avoid mutating global state in tests. This becomes
especially important when the tests are used by other packages.

Using the makefile to setup global state both simplifies how we fetch
schemas and ensures that the fetches are intentional.

* Fix path

* remove unused imports

* Add comments
2022-03-18 11:48:39 -07:00
Pat Gavlin f21eda521f
[codegen] Rename the PCL package. ()
It's just confusing that PCL lives in a package named `hcl2`.
2021-09-29 20:11:56 -07:00