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.
* 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.
Future proof this test by depending on `@pulumi/pulumi` 2.0. `@pulumi/pulumi` 1.x depends on the native `grpc` package. In the future, when we run on future versions of Node.js, prebuilt native binaries of `grpc` might not be available which could result in this test failing.
In `@pulumi/pulumi` 2.0, we have moved to using `@grpc/grpc-js`, a pure JavaScript implementation, which doesn’t have this problem.
There are two expressions in HCL2 that are used to iterate over
collections:
- Splat expressions, e.g. `foo.*.bar`, and
- For expressions, e.g. `[for v in foo: v.bar]`
In both of these cases, the parts of the expression that are not the
collection being iterated behave like callbacks, and must be treated as
such by the apply rewriter.
Token detection was broken for conditional and for expressions that
represent template control sequences. The code originally attempted to
determine whether or not a conditional or for expression was a control
sequence by inspecting the expression's parent. Unfortunately, that
approach is unable to distinguish between expressions that are control
sequences and those that are merely template parts. These changes
instead inspect the first token of the expression for a template control
token (i.e. `%{`): if such a token is found, the expression is detected
as a template control sequence.
Fixes: #4585
This was happening by default in the test framework and then again
in the go language runtime
Also we were replacing a module and then running go mod tidy - this
is unnecessary - go mod download is sufficient here to ensure we
have the correct dependency we need. The tidy may have been removing
the replacements added
* Adjust the args type names for k8s overlay resources.
* Revert to using input type link for kubernetes non-overlay resources.
* Use the correct module name to lookup the C# namespace for resources that belong to a module.
* Helm's arg types don't use the version number.
Specifically, handle index and relative traversal expressions, and clean
up the code a little bit.
This should also help us pick up more `pulumi.interpolate` calls in TS.
This avoids the "NotSupportedException : Multiple executions of TestAsync must run serially" from calls to `Deployment.TestAsync` in the mocks test, which can happen if a stack test runs before the mock test (.NET unit tests are run in random order).
With the addition of Python examples, doc comments may now contain
triple quotes. These must be escaped in order to avoid malformed source
files.
Fixes#4568.
These changes port the downstream codegen testing actions from
https://github.com/pulumi/pulumi-terraform-bridge to this repository.
`github.com/pulumi/pulumi/pkg/v2` is replaced with the PR HEAD.
These tests are only triggered on changes to `pkg/codegen` and
the workflow definition itself.
- Determine variable types for ranged resources by typechecking an
equivalent expression
- Detect top-level await in NodeJS and generate an async main
- Fix `pulumi.all` generation for NodeJS
- Fix a bug in the lowering of relative traversals in Python
* Restore the API type links for C#.
* Also restore them in function.tmpl.
* Add package details to the Functions template as well. Add a global template function to detect if the APIDocLinks has links for a language. Don't generate C# API doc links for k8s.
Despite having the `[assembly: CollectionBehavior(DisableTestParallelization = true)]` attribute, it appears `dotnet test` is still running tests in parallel. To address, use a configuration file to disable parallelization.
This code was accidentally removed in a prior PR.
These changes also remove an assert; the situation the assertion guards
against is valid and occurs when dealing with traversals inside of
splat expressions.
Unlike most languages with interpolated strings, Python's formatted
string literals do not allow the nesting of quotes. For example,
this expression is not legal Python:
f"Foo {"bar"} baz"
If an interpolation requires quotes, those quotes nust differ from the
quotes used by the enclosing literal. We can fix the previous example
by rewriting it with single quotes:
f"Foo {'bar'} baz"
However, this presents a problem if there are more than two levels of
nesting, as Python only has two kinds of quotes (four if the outermost
string uses """ or '''): in this case, the expression becomes
unspellable, and must be assigned to a local that is then used in place
of the original expression. So this:
f"Foo {bar[f'index {baz["qux"]}']} zed"
becomes this:
index = "qux"
f"Foo {bar[f'index {baz[index]}']}"
To put it bluntly, Python code generation reqiures register allocation,
but for quotes. These changes implement exactly that.
These changes also include a fix for traversals that access values that
are dictionaries rather than objects, and must use indexers rather than
attributes.
Mapping happens at package scope, not type scope. This is what causes
some of the surprising mixes of camel and snake casing in our packages.
In order to accommodate this, build the case mapping tables up front,
and refer to them when performing case mapping.
The tokens that make up the "key" portion of an index traversal
(e.g. `"foo"` in `a["foo"]`) are structured like those that make up a
block label: an open quote token, a string literal token, and a close
quote token. The token mapper did not account for that fact, and instead
recorded the key token as the open quote. These changes correct that
error, and adjust the code in `literalText` to allow for
properly-escaped and quoted strings where necessary.
If a single process is going to bind and generate multiple programs, it
is useful to be able to cache package schemas in order to avoid the
(large) overhead of deserializing schemas multiple times.
Use strings.Builder instead of raw slices. We could go further here and
collapse to a single, ~right-sized bulder at the cost of complexity in
the `stateAcronym -> stateLowerOrNumber` transition.
Also, eliminate the pyName function, as it is redundant.
* Enable container runtime tests for cron jobs
* Use VERSION var from Makefile
Co-authored-by: Paul Stack <public@paulstack.co.uk>
Co-authored-by: Paul Stack <public@paulstack.co.uk>
Adds support for RegisterResource to accept map-typed implementations if Input as well as the existing struct-typed implementations. Currently these must be fully untyped - but both map[string]pulumi.Input and map[string]interface{} are allowed. In the future, it's plausible that a mode where the data itself is a map, but the ElementType implementation returns a struct could be supported, with the struct used to provide type information over the untyped map.