Commit Graph

127 Commits

Author SHA1 Message Date
Fraser Waters 3460c9963f
Enable l1-output-number conformance test for Go ()
This required fixing `__convert` in Go programgen to handle expressions
that needed to result in input-y values. This also fixed the
"single-or-none" codegen test.
2024-07-22 17:12:28 +00:00
Fraser Waters d587d23b84
Fix literal values in generated Go stack outputs ()
Splitting off just the codegen changes from
https://github.com/pulumi/pulumi/pull/16698 to see if they pass CI.
2024-07-21 09:13:43 +00:00
Alex Qiu e6d20d26f7
Add support for `DeletedWith` to `pulumi convert` ()
This commit extends PCL so that it knows about the `DeletedWith`
resource option. With this, we can give `pulumi convert` the ability to
preserve `DeletedWith` resource options when converting programs.

Part of https://github.com/pulumi/pulumi-yaml/pull/437
2024-07-19 14:17:45 +00:00
Julien P 05574aaaa4
Generate TypedDicts for python inputs ()
Epic: Improved Typing https://github.com/pulumi/pulumi/issues/12689

This PR adds the flag `Languages.Python.InputTypes` to the schema, which
can take the values `classes` or `classes-and-dicts`. In the first
iteration of the feature, this defaults to `classes`, which leaves code
generation as is and does not change input types.. If the flag is set to
`classes-and-dicts`, `TypedDict` based types are generated next to the
current `<Type>Args` classes. In the future this could be extended to
support `dicts` to generate only `TypedDict` types.

The generated types are conditional on the used type checker to work
around perf issues in MyPy and PyCharm, see
https://github.com/pulumi/pulumi/issues/12689#issuecomment-2117240276

```python
if not MYPY:
    class DeploymentArgsDict(TypedDict):
        api_version: NotRequired[Input[str]]
        kind: NotRequired[Input[str]]
        metadata: NotRequired[Input['ObjectMetaArgsDict']]
        ...
elif False:
    DeploymentArgsDict: TypeAlias = Mapping[str, Any]
```

Removing the workaround is tracked in
https://github.com/pulumi/pulumi/issues/16408

---------

Co-authored-by: Anthony King <anthony@datapane.com>
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2024-06-18 15:24:42 +00:00
Zaid Ajaj 3207e19983
[go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs ()
# Description

Partially addressing
https://github.com/pulumi/pulumi-azure-native/issues/3308

Implementing a new go language option called `importPathPattern` which
can be used to override how the base import path and modules are
concatenated to create imports in generated Go programs. By convention
this used to be `{baseImportPath}/{module}` which has worked for all of
our providers. However, azure-native v2 has introduced a new import
scheme where the convention above causes incorrect import paths to be
generated.

This is where `importPathPattern` comes into play and allows for a
different convention. In the case the of azure-native v2, the pattern
_must_ be `github.com/pulumi/pulumi-azure-native-sdk/{module}/v2`.

This PR implements `importPathPattern` and tests it using a squashed
down azure-native v2 schema containing only contents from the
`eventgrid` module. This schema sets the option like this:
```json
"importPathPattern": "github.com/pulumi/pulumi-azure-native-sdk/{module}/v2"
```
This schema also modifies `packageImportAliases` from the current
azure-native v2 schema to exclude /v2 before the module path (see the
file below). This change is needed in the actual azure-native v2
provider cc @danielrbradley and it is the second part of fully fixing
https://github.com/pulumi/pulumi-azure-native/issues/3308

> We cannot just use `{baseImportPath}/{module}` because the base import
path for azure-native v2 has a suffix v2 (it's required)

Also implemented a small feature in ProgramTest to allow overriding the
used plugin host for the specific program test, this is because I wanted
to test the program against the simplified azure-native v2 schema
without changing how other test load the previous azure-native v1.x
schemas (I tested that without this, binding programs fails)



## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-05-30 19:51:12 +00:00
Zaid Ajaj 3d1641b100
[program-gen/tests] Replace discriminated unions test program with a program from a synthetic schema of basic unions ()
# Description

This PR replaces the test program `discriminated-unions` with a new
program `basic-unions` that uses a synthetic schema that has basic union
definitions.

The former program was failing compilation with Go because of a
**faulty** azure-native SDK (tests using v1.56.0). It didn't generate
the extra types for union objects (those with suffix `Args`). Those
missing extra types are added in newer versions of azure-native SDK but
the shape of the same resource doesn't have unions anymore so we can't
just upgrade the version of the azure-native sdk we are testing with.

I decided not to depend on a specific azure-native SDK and instead use a
synthetic schema with the sole purpose of showing that we can emit
correct code for fields assigned to object which are bound to different
union cases. The downside here is that we can't compile the example for
any language since it is a synthetic schema with no generated SDK
(conformance tests in Go would make this possible but we are far away
from that 😢)

Closes  since the original issue was due to faulty SDK, not
program-gen.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-03-28 10:49:27 +00:00
Zaid Ajaj c7c91f023f
[program-gen/csharp] Fixes generated code for a list of resources used in resource option DependsOn ()
# Description

Fixes  by special casing how we handle `dependsOn` and generating
`DependsOn = { ... }` instead of `DependsOn = new[] { ... }`

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->

---------

Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
2024-03-25 15:34:54 +00:00
Zaid Ajaj 7627d8097e
[program-gen/go,dotnet] Fixes emited code for object expressions assigned to properties of type Any ()
# Description

Fixes  by specifically handling object expressions that are
annotated as `Any` and emitting the correct code.

- In case of Go, expression `X` is emitted as `pulumi.Any(X)` where the
type name here is `map[string]interface{}`.
- In case of C#, we generate `Dictionary<string, object?>` expressions
(similar to what we do inside `toJSON` calls)
- Updates the test aws-native schema from 0.13.0 to 0.99.0

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-03-24 00:06:57 +00:00
Zaid Ajaj 3bdc65c6e5
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases ()
# Description

This PR improves enum type resolution from strings. When we try to
resolve `Union[string, Enum]` for a string expression, we choose
`string` because it is the more general type since not every string is
assignable to `Enum`. However, here we spacial case strings that are
actually part of that `Enum`.

The result is that `pcl.LowerConversion` will choose `Enum` from
`Union[string, Enum]` when the value of the input string is compatible
with the enum. This greatly improves program-gen for all of typescript,
python, csharp and go which now will emit the fully qualified enum cases
instead of emitting strings.

Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is
supposed to be a duplicate of
https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is
not the case (the former is about unions of objects, the latter is
unions of enums and strings)

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-03-15 17:49:12 +00:00
Zaid Ajaj 8b3f94b89c
[program-gen] Fix panic when generating programs for MLC packages using external types ()
# Description

For an MLC package such as `aws-static-website`, it has some types which
are referenced from the `aws` package. Program-gen assumes packages are
inferred from resources and invokes, not types which caused panics in Go
(), dotnet and python
(https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2)

This PR fixes those panics. In Go the panic was due to using package
name instead of the package reference from the imported type. In dotnet
and python was due to assuming no external type references. Now we
generate nice code for all these languages.

That said, there is still an issue of resolving imports for the packages
of these external types. It works in Go, TypeScript doesn't need it but
dotnet and python do. That is why the latter are added in `SkipCompile`
in the test program.


Fixes 
Fixes
https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/3
Fixes
https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-03-10 17:23:15 +00:00
Fraser Waters 7302311c2c
Renable tests disabled due to appdash () 2024-01-17 09:09:53 +00:00
Zaid Ajaj b96f19b2fa
[program-gen/pcl] Fixes type-annotating nested resource properties when these have quoted keys ()
# Description

When binding resource properties and annotating these with types from
their schemas, we seem to skip this annotation process when resource
properties and their nested objects use _quoted_ keys `{ "key" = <value>
}` rather than using _literal_ keys `{ key = <value> }`.

This results in issues such as
https://github.com/pulumi/kube2pulumi/issues/60 where a csharp property
name override was not correctly applied because
1) kube2pulumi generated properties for resources that are quoted (this
should be fine)
2) binding the resource properties skipped annotating the nested object
with its corresponding schema type
3) program-gen in dotnet didn't have access to the schema type of the
nested object to correctly apply the property override

This PR fixes this issue by extending PCL resource binding to also check
for properties which have quoted keys.

Fixes https://github.com/pulumi/kube2pulumi/issues/60 and potentially
other issues that arise from converters generating PCL with quoted keys.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-27 12:42:52 +00:00
Zaid Ajaj 1a8abbf8c8
[program-gen/go] Fix required config variables of type bool and number ()
# Description

While covering more parts of go codegen, I've seen that config variables
are broken 😓 specifically when requiring config variables using
`RequireFloat` it should be `RequireFloat64` and `RequireBoolean` should
be `RequireBool`.
Moreover, it seems that `RequireObject` doesn't work at all since the
function signature doesn't match the way it was generated (see )

C# has a similar issue with optional untyped objects as config
variables. For now have skipped compilation for those.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-20 13:16:37 +00:00
Justin Van Patten b0c276ece0
Update esc to v0.6.1 ()
First step in addressing https://github.com/pulumi/pulumi/issues/14873

Note: I suspect I'll need to temporarily disable some codegen tests to
get this merged, and then once we release v3.98.0 and the next version
of esc, we can re-enable.
2023-12-19 08:05:16 +00:00
Zaid Ajaj b52ab81cc4
[typescrypt/program-gen] Fix generated readFile function so that it includes the encoding ()
# Description

Small fix for generated `readFile` function so that it includes the
encoding and returns a string

Fixes 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-11-23 00:26:41 +00:00
Zaid Ajaj ac6adb98bf
[go/program-gen] Fix using inline invoke expressions inside resources, objects and arrays ()
# Description

This PR fixes an issue in Go program where if users are writing invoke
expressions inline inside other expressions, then that invoke is
extracted into a temporary variable and then later referenced the same
way it was used. This is because non-output-versioned invokes cannot be
used directly since they return a tuple (InvokeResult, err) so we need
to check for the error before proceeding.

Fixes 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-11-03 14:22:43 +00:00
Thomas Gummerer 0d6fff3995
codegen/go: output correct array type ()
Currently for an array of objects, codegen for Go outputs a
`pulumi.AnyArray` type. However that does not exist. Make sure it always
outputs the correct `pulumi.Array` type.

While there give Maps the same treatment, as `pulumi.AnyMap` also
doesn't exist.

Fixes #https://github.com/pulumi/pulumi/issues/8072

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-10-20 16:12:25 +00:00
Zaid Ajaj daaaaea339
[python/program-gen] Fix panic in python program-gen when rewriting index expressions ()
# Description

Fixes  so that the program generation no longer panics

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-10-06 22:26:04 +00:00
Zaid Ajaj 72a333e882
[programgen/csharp] Fixes compiling an empty list of expressions from object properties ()
Fixes  

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-09-28 12:43:35 +00:00
Ian Wahbe 429106e42d
Unskip azure-native-pp generation for go ()
The generated go code still fails to compile. It's missing lots of type
names (worse then before) and still uses `pulumi.AnyArray` (which
doesn't exist). I don't see non-deterministic panics anymore

Fixes 
2023-08-22 20:12:44 +00:00
Fraser Waters 99b736b55b Add localDependencies option to GenerateProject
This isn't currently actually used anywhere. I've just threaded it
through to all the program gen functions where it will be needed.

Matrix testing will be using and testing this.
2023-08-08 12:28:19 +01:00
Zaid Ajaj 810460099e Fixes parseProxyApply to handle nested outputs within index expressions 2023-08-07 21:08:54 +02:00
Zaid Ajaj d66a037ba3 Fixes list initializer for plain lists in resource properties 2023-08-07 18:43:37 +02:00
Zaid Ajaj fe0b729889 Fixes code generation of ForExpressions 2023-07-28 20:30:00 +02:00
bors[bot] d96533d46a
Merge
13590: [dotnet/program-gen] Fix typing for optional and complex config variables in main program r=Zaid-Ajaj a=Zaid-Ajaj

# Description

This PR adds support in dotnet program-gen for  optional and complex config variables. For Object-typed config variables, it will generate a class with the shape of the type, then later on during `config.GetObject<T>` it will use a reference to that type `T`

Similarly to complex types in component config variables, this does not implemented _nested_ objects yet but handles the most common cases. 

Fixes 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
2023-07-27 14:36:14 +00:00
Zaid Ajaj c6d1117036 Fix typing for optional and complex config variables in main program 2023-07-26 13:37:53 +02:00
Abhinav Gupta bb18a194f0
test(codgen): Reproduce
Adds a minimal reproduction of the duplicate import issues
reported in .
2023-07-25 12:49:36 -07:00
Zaid Ajaj 62af6b0b1a Fix interpolated strings used as keys of maps 2023-07-18 08:47:37 +02:00
Zaid Ajaj 86dd665b93 Improve static typing of config variables in main program 2023-07-15 00:15:28 +02:00
Zaid Ajaj ed02926277 Allow generating code for unknown invokes in non-strict mode 2023-07-10 15:05:18 +02:00
bors[bot] 656cf29179
Merge
13251: [convert] Prefer output-versioned invokes in generated programs for nodejs and python r=Zaid-Ajaj a=Zaid-Ajaj

### Description

This PR implements a new PCL bind option called `PreferOutputVersionedInvokes` which as the name suggests gives higher priority to using output-versioned invokes in generated programs if they exist* but only for python and nodejs. Previously we have enabled this for all languages but it breaks go and dotnet programs so here it is only applied to python and typescript. 

Binding component programs carry over this option if the main program has it too. 

This work is a continuation of 

<details>
   <summary>PCL program example</summary>

```
vpc = invoke("aws:ec2:getVpc", {
	default = true
})
subnets = invoke("aws:ec2:getSubnetIds", {
	vpcId = vpc.id
})

resource webSecurityGroup "aws:ec2:SecurityGroup" {
	vpcId = vpc.id
	egress = [{
		protocol = "-1"
		fromPort = 0
		toPort = 0
		cidrBlocks = ["0.0.0.0/0"]
	}]
	ingress = [{
		protocol = "tcp"
		fromPort = 80
		toPort = 80
		cidrBlocks = ["0.0.0.0/0"]
	}]
}
```

</details>

<details>
   <summary>Generated TypeScript Before</summary>

```typescript
const vpc = aws.ec2.getVpc({
    "default": true,
});
const subnets = vpc.then(vpc => aws.ec2.getSubnetIds({
    vpcId: vpc.id,
}));
const webSecurityGroup = new aws.ec2.SecurityGroup("webSecurityGroup", {
    vpcId: vpc.then(vpc => vpc.id),
    egress: [{
        protocol: "-1",
        fromPort: 0,
        toPort: 0,
        cidrBlocks: ["0.0.0.0/0"],
    }],
    ingress: [{
        protocol: "tcp",
        fromPort: 80,
        toPort: 80,
        cidrBlocks: ["0.0.0.0/0"],
    }],
});
```

</details>

<details>
   <summary>Generated TypeScript After</summary>

```typescript
const vpc = aws.ec2.getVpcOutput({
    "default": true,
});
const subnets = aws.ec2.getSubnetIdsOutput({
    vpcId: vpc.id,
});
const webSecurityGroup = new aws.ec2.SecurityGroup("webSecurityGroup", {
    vpcId: vpc.id,
    egress: [{
        protocol: "-1",
        fromPort: 0,
        toPort: 0,
        cidrBlocks: ["0.0.0.0/0"],
    }],
    ingress: [{
        protocol: "tcp",
        fromPort: 80,
        toPort: 80,
        cidrBlocks: ["0.0.0.0/0"],
    }],
});
```

</details>

> * The existence of output-versioned invokes depends on whether they have any arguments. The idea is to change that later such that every function invoke emits an output-versioned invoke regardless of whether it has input args or not. 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
2023-06-26 11:30:24 +00:00
bors[bot] 9af5007b17
Merge
13212: [program-gen/go] Fix aliasing package names using dashes when schema doesn't include package info r=Zaid-Ajaj a=Zaid-Ajaj

### Description

Fixes  such that if a package doesn't have a specific go package override (like the one mentioned in the bug report) and needs an alias (because of using hypthens) then we apply aliasing for it. 

The PR adds a small synthetic schema called `using-dashes` that doesn't have any special go package info overrides and generates test programs from it. 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
2023-06-23 09:52:45 +00:00
Zaid Ajaj 7ab7ad5a58 Prefer output-versioned invokes in generated programs for nodejs and python 2023-06-23 02:42:18 +02:00
Abhinav Gupta da184df24a
fix(codegen/go): Use raw string literals for multiline-strings
We already have logic in place to generate mutliline strings with
backticks if they meet certain conditions in genTemplateExpression.
However, the logic came into effect only if the string was complex
enough to warrant use of `Sprintf`
because the function short circuits to just printing a string literal
if the string doesn't need a `Sprintf`.

This changes genStringLiteral to be responsible for the decision
of whether the string warrants backticks or not,
retaining the prior conditions on whether the string would benefit
from being split across multiple lines.

Resolves 
2023-06-22 10:55:45 -07:00
Zaid Ajaj 3bc0e6fe38 Fix aliasing package names using dashes when schema doesn't include go package info override 2023-06-20 18:11:47 +02:00
Zaid Ajaj 7e5e452909 Extend SkipResourceTypechecking to allow generating unknown resources 2023-06-14 19:02:56 +02:00
Justin Van Patten 31d106980e [programgen/dotnet,go] Implement singleOrNone intrinsic
This change adds support for the `singleOrNone` intrinsic to Go and C# programgen.
2023-06-11 16:23:33 -07:00
Zaid Ajaj 8912eae4c6 Fixes python panic when emiting code for index expressions that aren't typechecked 2023-06-09 01:44:09 +02:00
bors[bot] 54d3b786a1
Merge
13116: [pcl/go] Fix panic in go program-gen when encountering splat expressions r=Zaid-Ajaj a=Zaid-Ajaj

# Description

This PR adds a test program to show compiling splat expressions in the different languages and fixing a panic in go program-gen. I created a simple schema for this specific test which is why compiling the example is skipped in all languages. 

The problem was that rewriting splat expressions happened after rewriting conversions so I switched the order of them.  

Fixes  

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
2023-06-07 13:25:59 +00:00
Zaid Ajaj 2ce1fdb091 Fix panic in go program-gen when encountering splat expressions 2023-06-07 13:22:41 +02:00
Zaid Ajaj da875885bf Allow output variables to have the same identifier as other program nodes 2023-06-07 02:37:40 +02:00
Zaid Ajaj 82eed5a8bf Only await task-returning invokes in dotnet program-gen 2023-06-03 09:23:38 +02:00
Zaid Ajaj 935ab8a847 correctly skip all languages except for typescript 2023-06-03 02:02:42 +02:00
Zaid Ajaj c6b88ecb2e Skip compiling the example on nodejs 2023-06-03 00:51:53 +02:00
Zaid Ajaj cd8911c628 Skip should use nodejs instead of typescript 2023-06-03 00:48:27 +02:00
Zaid Ajaj a28faade82 Only await promise-returning invokes in typescript program-gen 2023-06-02 18:33:18 +02:00
Zaid Ajaj af09d174cd Do not error out when generaing not yet implemented ForExpressions 2023-06-02 16:59:46 +02:00
Zaid Ajaj 65ad123780 Implement singleOrNone intrinsic for typescript and python 2023-05-25 22:12:13 +02:00
Zaid Ajaj a18152a1a2 Skip compling dynamic-entries TypeScript example 2023-05-16 21:33:14 +02:00
Zaid Ajaj d37b26874f Allow iterating dynamic entries in TypeScript 2023-05-16 20:11:57 +02:00