Commit Graph

12 Commits

Author SHA1 Message Date
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 d89bc9d705 Update docs of WriteSource to not specify a starting root directory
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2023-03-16 11:51:45 +01:00
Zaid Ajaj 0d25812a62 Program.WriteSource takes only the file system 2023-03-16 11:51:45 +01:00
Zaid Ajaj d3a764d666 Use Afero file system abstraction to write out PCL files 2023-03-16 11:51:45 +01:00
Zaid Ajaj 0ced47ec32 lint 2023-03-16 11:51:45 +01:00
Zaid Ajaj 6d01a77106 PCL program.SourceFiles(...) implementation and usage in pulumi convert 2023-03-16 11:51:45 +01:00
Zaid Ajaj 26e58eb9a8 nodejs program-gen implementation for components and support for nested component declarations 2023-03-14 16:17:14 +01:00
Zaid Ajaj ba639d555a PCL components and dotnet program-gen implementation 2023-03-08 14:21:34 +01:00
Fraser Waters 8d85edda47 Make convert's pcl output yaml agnostic
We're going to use convert for more data sources than just YAML (e.g.
hcl, arm, etc). So we don't want the PCL output option to be YAML
specific given it should be usable for any input source.
2022-11-08 17:04:51 +00: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 98e48f4cc4
codegen: preserve externally visible names of a resources and outputs ()
* codegen: preserve externally visible names of a resources and outputs

* refactor: rename unique name to logical name
2022-04-25 15:07:25 -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