Commit Graph

442 Commits

Author SHA1 Message Date
Justin Van Patten 5e6b7ef070
Bump .NET version after 3.66.2 release ()
See https://github.com/pulumi/pulumi-dotnet/releases/tag/v3.66.2
2024-08-21 16:19:35 +00:00
Justin Van Patten 9f48d0f66b
[programgen/nodejs] Unskip some tests ()
The issue no longer repros so we can unskip these compile tests.

Fixes 
2024-08-16 13:44:42 +00:00
Justin Van Patten d747770234
[programgen] Unskip some Python and .NET tests ()
The Python and .NET issues are no longer present, so we no longer need
to skip these.

Fixes 
2024-08-16 08:14:13 +00:00
Justin Van Patten 856e71a3f7
Bump dotnet SDK version after release () 2024-08-09 21:06:37 +00:00
Zaid Ajaj 5fedf392e6
[sdk-gen] Support parameterized .NET provider SDKs ()
This PR extends sdk-gen for .NET to support parameterized providers.
When a schema has a parameterization, we emit a new function
`PackageParameterization()` in the `Utilities` class and call this
function for generated resources, invokes and methods.

It requires https://github.com/pulumi/pulumi-dotnet/pull/311 to be
merged first and a new version of Pulumi nuget package to be released,
then we can bump the version we use here.

EDIT: Now using Pulumi nuget package v3.66.0 
2024-08-09 13:16:20 +00:00
Julien 8afaf8dc47
Bump PulumiDotnetSDKVersion after dotnet release () 2024-08-08 20:42:57 +00:00
Julien ca60d337e2
Generate TypedDict input types by default ()
With https://github.com/pulumi/pulumi/pull/15957 we introduced the
schema setting `Languages.Python.InputTypes` to optionally generate
TypedDict based input types side-by-side with Args classes. This setting
defaulted to `classes`, meaning that only Args classes are generated. To
enable the TypedDict types, SDK authors had to explicitly opt in by
setting it to `classes-and-dicts`.

We now flip this setting to generating TypedDict input types
side-by-side with the Args classes, unless explicitly disabled by
setting it to `classes`.

Fixes https://github.com/pulumi/pulumi/issues/16375
2024-07-23 11:26:54 +00:00
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
Florian Stadler 74e8928cff
Add ability to constrain supported languages of resource and function overlays ()
The existing overlays (e.g. Chart v3 in Kubernetes, or CallbackFunction
in AWS) are not available in every language Pulumi supports. This often
confuses users because the generated docs include all languages Pulumi
supports (e.g. see
https://github.com/pulumi/pulumi-kubernetes/issues/2181).

To solve that problem, this change adds a new optional parameter to the
schema that allows configuring the languages an overlay (resource or
function) supports.
To support this in docsgen the existing Language Chooser
(`LangChooserLanguages`) of resources is made configurable and extended
to functions.

Note: This doesn't support resource methods right now. They'll need
extra handling because and overlay resource method might not support all
of the languages its resource supports. I'll tackle this in a follow up
PR.

Here's a screenshot of how this will look like for the Helm v3 chart for
example:
<img width="1046" alt="Screenshot 2024-07-01 at 16 11 23"
src="https://github.com/pulumi/pulumi/assets/2453580/b1a1365a-6dee-4099-829a-2859639a4c8c">

The PR contains the following commits. I'd recommend to look at the
first three ones and then check the regenerated golden files in the last
one:
- **Add schema parameter to constrain supported languages for overlays**
- **Update developer docs and changelog**
- **Refactor LanguageChooser and always pass supported languages**
- **Regenerate testdata**

relates to 
2024-07-09 14:54:50 +00:00
Justin Van Patten b29807f2b4
[sdkgen/dotnet] Bump Pulumi version reference ()
Bump the default version range for the referenced `Pulumi` package to a
version that supports `Config.GetDouble` (3.55+;
380536dd85).

Fixes 
2024-06-27 05:16:14 +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
Thomas Gummerer 1d47a7d6e3
upgrade dotnet dependency to latest ()
Upgrade to the latest dotnet release.
2024-06-11 06:30:13 +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
Thomas Gummerer 76edb80dc1
update dotnet version in tests to latest ()
Update to the latest dotnet version. Pulumi.Awsx started depending on
that, so using an earlier version makes the tests fail.

This happened a few times now, so we should really fix this in a way
that doesn't require us to hardcode this version. But I want to get the
merge queue unblocked, and this is probably the quickest way to do that.
2024-05-15 06:07:24 +00:00
Fraser Waters 15331285ff
Update version of dotnet we run tests against ()
Fixes https://github.com/pulumi/pulumi/issues/16047.
2024-04-24 21:52:39 +00:00
Thomas Gummerer 4dbacf37af
update dotnet SDK version in codegen tests ()
Since we released a new SDK we should also update the version here.
Otherwise tests might end up failing as soon as a provider we're using
in the tests depends on the new dotnet SDK version.

Saw https://github.com/pulumi/pulumi/pull/15955 and realized we ran into
issues with this last time.
2024-04-17 08:15:06 +00:00
Zaid Ajaj 4a012def4b
[sdk-gen, dotnet/go] Fixes SDK-generation when referencing shared types in config variables ()
# Description


Fixes  
- In .NET, non-primitive types such as objects used in config variables
will be generated anyways under the `Types` namespace as plain-shaped
objects inside of the `Config` class. This is because the types from
`Outputs` or `Inputs` cannot be used directly from config. Also no
longer marking objects used from config variables as "outputs" (doesn't
make any sense)

- In Go, disable adding imports into the `config.go` based on used
shared types because these are not used/referenced in the config module
anywhere anyways.

## 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. -->
- [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-28 17:14:47 +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
Thomas Gummerer 4f82720084
codegen testing: use latest pulumi dotnet version ()
We're currently failing tests because of a nuget error. It looks like
Pulumi.Awsx has started depending on the 3.60 dotnet SDK version, but
we're still using 3.59 here. It looks like this ends up in test as nuget
complains about "error NU1605: Warning As Error: Detected package
downgrade: Pulumi from 3.60.0 to 3.59.0. Reference the package directly
from the project to select a different version."

Not sure if this is the actual fix, not knowing much about dotnet, but
it looks like it might be the problem.

Right now the merge queue fails consistently because of this error.
2024-03-21 11:31:06 +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 6b554338b3
Ensure package generation for Go SDKs doesn't panic when encountering overly nested arrays or maps of primitive types ()
# Description

Fixes  where sdk-gen should no longer panic when encountering
overly nested arrays or maps of primitive types. The generated code
still fails to compile but validation can be added later to cover cases
where we are missing primitives in the core SDK to handle overly nested
type definitions.

## 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-14 14:21:15 +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
Anton Tayanovskyy d62c398bfb
Move codegen testdata ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

It appears that Go copies testdata into every GOMODCACHE of a project
that depends on pulumi/pkg; the schemas in codegen testdata add 300MB of
weight to the GOMODCACHE needed for download. What if we moved the
testdata out from under the tree.

The move looks like this:

```
from=pkg/codegen/testing/test/testdata
to=tests/testdata/codegen/
git mv "$from" "$to"
(cd pkg/codegen/testing/test && ln -s ../../../../tests/testdata/codegen ./testdata)
git add "$from"
```

The previous location is symlinked to the new location.

Evidence of `GOMODCACHE` pressure reduction:
https://gist.github.com/t0yv0/05dd8be5880171045aed01e123ae2b09

## 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. -->
- [ ] 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-06 20:36:50 +00:00
Julien P 9a357aff7c
Unskip tests skipped in , , ()
# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes  
Ref 
Ref 

## 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. -->
2024-03-05 09:12:53 +00:00
Eron Wright 8c7a9e5d3f
Support for non-overlay components in codegen for pulumi-kubernetes provider ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

This PR enhances the codegen for dotnet to allow the pulumi-kubernetes
provider to have non-overlay components. Previously all components were
overlays and didn't require codegen.

The specific change is to not apply the `KubernetesResource` base class
when the resource is a component. It is inappropriate to use
`KubernetesResource` in this case because it extends `CustomResource`
not `ComponentResource`.

The sdkgen test suite for `kubernetes20` mode was updated with a new
example resource:
- a non-overlay component resource
([code](https://github.com/pulumi/pulumi/pull/15490/files#diff-31beec99a7baef687bd1024481d8c6e1d13b1c7f4494b417cc044fe71ad0f8cd))

The fix is manifested
[here](https://github.com/pulumi/pulumi/pull/15490/files#diff-79ca901e45591fc7db0c022cf914e99eccc0e35b2d3b1e8ee2ce45ad82faaf29R16).
## 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. -->
- [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-04 19:37:54 +00:00
Sean Holung 23313d6b0a
Fix deprecation note formatting ()
fixes: https://github.com/pulumi/registry/issues/3983

This PR fixes up some issues with our deprecation message formatting.
The deprecation messages attached to enums were not being formatted at
all, due to a missing css class. Secondly, I also noticed there was a
whitespace missing in the deprecation message when it renders in the
browser, due to the leading `-` in `{{- .... -}}`, so I addressed that
here as well.

### enum deprecation

before:
![Screen Shot 2024-02-22 at 10 20 34
AM](https://github.com/pulumi/pulumi/assets/16751381/89cf20b7-ad05-4085-9a42-fd73f964e250)



after:
![Screen Shot 2024-02-22 at 9 54 43
AM](https://github.com/pulumi/pulumi/assets/16751381/a95a8302-e40f-43aa-96a2-44f14b505571)

### fix whitespace after "Deprecated:"

before:
![Screen Shot 2024-02-22 at 10 20 53
AM](https://github.com/pulumi/pulumi/assets/16751381/53f088fa-5f46-45e4-b217-536b0affa0cf)

after:
![Screen Shot 2024-02-22 at 9 54 29
AM](https://github.com/pulumi/pulumi/assets/16751381/fbc687a7-43aa-4b80-9f3b-cd3d9f3255a0)
2024-03-02 06:02:03 +00:00
Eron Wright 1c4393b30f
[dotnet] codegen fix for resources without constant input properties ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

This PR fixes a bug in the dotnet codegen where the wrong "args" class
name would be used, in the case that the resource has no constant
inputs. This is an edge case because most resources do have at least one
such input.

For example, a new resource definition in p/k produced this output:
```csharp
namespace Pulumi.Kubernetes.Yaml.V2
{
        public ConfigGroup(string name, Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs? args = null, CustomResourceOptions? options = null)
            : base("kubernetes:yaml/v2:ConfigGroup", name, args ?? new ConfigGroupArgs(), MakeResourceOptions(options, ""), remote: true)
        {
        }
}
```
Which doesn't compile because `ConfigGroupArgs` is in a separate
namespace.

Should be:
```csharp
        public ConfigGroup(string name, Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs? args = null, CustomResourceOptions? options = null)
            : base("kubernetes:yaml/v2:ConfigGroup", name, args ?? new Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs(), MakeResourceOptions(options, ""), remote: true)
        {
        }
```

[Here's
](https://github.com/pulumi/pulumi/pull/15488/files#diff-18b12fabab20d68398aced2890b1ca3073cc32081bb62a022b77a5090c209e3bR45)where
the fix manifests itself in the new test case.

## Testing

A new SDK test case was added to cover the whole `kubernetes20`
compatibility mode, based on a simplified schema from the
pulumi-kubernetes provider.

The schema contains a representative set of resources:
1. `kubernetes:core/v1:ConfigMap` - a non-overlay resource representing
a Kubernetes kind.
2. `kubernetes:core/v1:ConfigMapList` - a Kubernetes list kind
3. `kubernetes:helm.sh/v3:Release` - a non-overlay, non-Kubernetes
resource
4. `kubernetes:yaml:ConfigGroup` - an overlay component resource

An important detail is whether a resource has any input properties that
have a constant value, such as we see with `kind` and `apiVersion`. The
`Release` resource intentionally has no such constant inputs.

## 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. -->
- [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-02 06:01:31 +00:00
Zaid Ajaj 3b9f5c09b7
[program-gen] Fix stack overflow when binding invoke that resolves to promise ()
# Description


Fixes  because using `ContainsPromises` doesn't account for
recursive object references where as `ContainsEventuals` does.

## 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-02-20 15:49:08 +00:00
Zaid Ajaj c5ae74a74e
[program-gen] Emit Output-returning JSON serialization methods without rewriting applies ()
### Description

A while ago we started implementing [specialized JSON serialization
methods](https://github.com/pulumi/pulumi/issues/12519) for Pulumi
programs which can accept nested outputs without having to rewrite and
combine applies.
 - `Output.SerializeJson` in .NET
 - `pulumi.jsonStringify` in nodejs
 - `pulumi.Output.json_dumps` in Python

This PR extends program-gen for TypeScript, C# and Python to start
emitting these JSON serialization functions (when necessary). The PR
special-cases the `toJSON` PCL function when rewriting applies so that
nested outputs aren't rewritted.

Example PCL program and generated results:

> Also check out the downstream codegen tests to see improved generated
examples

```
resource vpc "aws:ec2:Vpc" {
	cidrBlock = "10.100.0.0/16"
	instanceTenancy = "default"
}

resource policy "aws:iam/policy:Policy" {
	description = "test"
	policy = toJSON({
		"Version" = "2012-10-17"
		"Interpolated" = "arn:${vpc.arn}:value"
		"Value" = vpc.id
	})
}
```


### Generated TypeScript Before
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const vpc = new aws.ec2.Vpc("vpc", {
    cidrBlock: "10.100.0.0/16",
    instanceTenancy: "default",
});
const policy = new aws.iam.Policy("policy", {
    description: "test",
    policy: pulumi.all([vpc.arn, vpc.id]).apply(([arn, id]) => JSON.stringify({
        Version: "2012-10-17",
        Interpolated: `arn:${arn}:value`,
        Value: id,
    })),
});
```

### Generated TypeScript After
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const vpc = new aws.ec2.Vpc("vpc", {
    cidrBlock: "10.100.0.0/16",
    instanceTenancy: "default",
});
const policy = new aws.iam.Policy("policy", {
    description: "test",
    policy: pulumi.jsonStringify({
        Version: "2012-10-17",
        Interpolated: pulumi.interpolate`arn:${vpc.arn}:value`,
        Value: vpc.id,
    }),
});
```
### Generated Python Before
```python
import pulumi
import json
import pulumi_aws as aws

vpc = aws.ec2.Vpc("vpc",
    cidr_block="10.100.0.0/16",
    instance_tenancy="default")
policy = aws.iam.Policy("policy",
    description="test",
    policy=pulumi.Output.all(vpc.arn, vpc.id).apply(lambda arn, id: json.dumps({
        "Version": "2012-10-17",
        "Interpolated": f"arn:{arn}:value",
        "Value": id,
    })))
```

### Generated Python After
```python
import pulumi
import json
import pulumi_aws as aws

vpc = aws.ec2.Vpc("vpc",
    cidr_block="10.100.0.0/16",
    instance_tenancy="default")
policy = aws.iam.Policy("policy",
    description="test",
    policy=pulumi.Output.json_dumps({
        "Version": "2012-10-17",
        "Interpolated": vpc.arn.apply(lambda arn: f"arn:{arn}:value"),
        "Value": vpc.id,
    }))
```

### Generated C# Before
```csharp
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var vpc = new Aws.Ec2.Vpc("vpc", new()
    {
        CidrBlock = "10.100.0.0/16",
        InstanceTenancy = "default",
    });

    var policy = new Aws.Iam.Policy("policy", new()
    {
        Description = "test",
        PolicyDocument = Output.Tuple(vpc.Arn, vpc.Id).Apply(values =>
        {
            var arn = values.Item1;
            var id = values.Item2;
            return JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "2012-10-17",
                ["Interpolated"] = $"arn:{arn}:value",
                ["Value"] = id,
            });
        }),
    });

});
```

### Generated C# After
```csharp
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var vpc = new Aws.Ec2.Vpc("vpc", new()
    {
        CidrBlock = "10.100.0.0/16",
        InstanceTenancy = "default",
    });

    var policy = new Aws.Iam.Policy("policy", new()
    {
        Description = "test",
        PolicyDocument = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Interpolated"] = vpc.Arn.Apply(arn => $"arn:{arn}:value"),
            ["Value"] = vpc.Id,
        })),
    });

});
```

## 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-02-20 15:48:46 +00:00
Fraser Waters 11eff25a20
Add test for legacy style names ()
Long term I want to introduce a new snake_case based naming system to
schemas. There's an internal design doc about this at
https://docs.google.com/document/d/1ns07htpLjw0dJPn5p7TBPVULvwwYc1Pl7l1c1jdGXoY/edit.

As part of that we get the nice feature that _nearly_ all current names
are either valid and the same in both system (e.g. "foo"), or they look
different in the current system (e.g. "fooBar"). But there are a handful
of odd cases where we have providers using names that look like they
should be new style snake case names (e.g. kubernetes has a load of
"x_kubernetes_" properties).

To provide a way to ensure k8s can stay on the current name generation
(even though it gives pretty odd results) this change adds a test with a
schema demonstrating a load of snake_case names. When we do add the new
naming system this test _should not diff_, excepting possibly setting an
option if the new naming system is opt-out rather than opt-in.
2024-02-15 13:44:44 +00:00
Sean Holung bf251932ef
Fix enum rendering issue ()
Fixes: https://github.com/pulumi/registry/issues/3724
Fixes: https://github.com/pulumi/registry/issues/2966

This PR is to resolve the enum rendering issue. The enums were not being
rendered on the page at all due to a misconfigured language choosable
(i.e. `<pulumi-choosable>`) that wraps the enum section. I found out
this had to do with the lang property being set as `nodejs` when instead
the choosable expects `javascript` or `typescript` as the valid values.
I then followed the pattern of what we seem to be doing for the other
pulumi-choosables which have this issue, which is to have an if
statement that sets it to `javascript,typescript` if `nodejs` is given.

This is how the rendering looks now. I have not adjusted any layouts of
the template or anything along those lines, only fixed the choosable. I
am wondering if this is actually what was intended for these, as we have
a display name in the left column that is ~useless IMO and the right
column has the value. I am assuming this was done to match the
formatting of the other nested types that are displayed since these
enums are treated as such. Though I don't think it is optimal for what
we are trying to present given that we do not have descriptions for any
of the individual enum values and what they represent.

Should we consider doing something like having a separate enum section
that is more purpose built for the data we can display where we just
have the enum type in the left column, followed by the valid enum values
in the right column. For example:

| Instance Type | a1.2xlarge, a1.4xlarge , a1.large.... |


Should we consider moving to something like this or continue following
the current pattern we have? Thoughts welcome!

Also, we can consider shipping this as it is as it is still an
improvement over what we have now and file a follow up issue to
re-assess the way this is presented.

This is the current render that this PR fix will produce:

<img width="795" alt="Screen Shot 2024-02-09 at 8 35 21 AM"
src="https://github.com/pulumi/pulumi/assets/16751381/352462b7-720c-4495-bdfe-f62cfdd946c0">
2024-02-12 21:25:36 +00:00
Zaid Ajaj ed79536f65
[program-gen] Emit missing trivia for resources and local variables ()
# Description

For C#, Python and TypeScript: emit missing comments for local variable
declaration
For Go: emit missing comments for local variables and resources


## 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. -->
- [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-02-11 17:02:12 +00:00
Fraser Waters c227b1dafa
Use camelCase for schema names ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

A few of the test schema's were using snake_case names. Codegen doesn't
actually deal well with that so was giving some odd snapshot results,
this just fixes up the tests to use camelCase instead to get more
standard codegen results out.
2024-02-05 10:42:32 +00:00
Justin Van Patten cc631241b3
[sdkgen/python] Require Python >=3.8 ()
Python 3.7 is unsupported and has been end-of-life since 6/27/2023. See
https://devguide.python.org/versions/

The core `pulumi` Python SDK package is being updated to indicate that
Python 3.8 or greater is required (see ).

This change updates the default minimum required Python version for
generated provider SDKs to Python 3.8 or greater as well.

Fixes 
2024-02-04 19:07:53 +00:00
Zaid Ajaj 151558f7f2
Enable python conformance tests ()
### Description

Enabling python conformance tests. 

Uses a virtual environment for the generated projects and activates it
when installing dependencies.

~Right now fails at runtime due to missing engine address but the rest
works(TM)~

## 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-01-30 15:02:59 +00:00
Zaid Ajaj 03c2ba99b1
[sdk-gen/go] Remove pulumix references from generated enums in non-generic SDKs ()
### Description

This PR fixes build issues for Go SDKs where enums import the `pulumix`
package without using it or sometimes using it with generated input
interfaces for the enums for non-generic sdks. The problem was using the
function `goPackageInfo` which reads the package info from the language
section of the schema but not initializing `Generics` field to `none`
when it is empty.

## 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-01-27 18:57:16 +00:00
Justin Van Patten 87b611b1f4
[sdkgen/python] Use `importlib.metadata` instead of `pkg_resources` ()
This addresses two issues:

1. `pkg_resource` is deprecated in favor of `importlib.resources` and
`importlib.metadata`
(https://setuptools.pypa.io/en/latest/pkg_resources.html)

2. Generated provider SDKs don't indicate that they have a dependency on
`setuptools` (which includes `pkg_resources`), which can cause problems
when installing the package in environments that don't have `setuptools`
installed. That's not often common in Pulumi projects, as the virtual
environment created by the CLI will include `setuptools`, however, if
creating the virtual environment manually with `python -m venv`,
`setuptools` is no longer included in the created virtual environment as
of Python 3.12.

Fixes 

Based on , thanks @edgarrmondragon!

---------

Co-authored-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-01-27 02:13:37 +00:00
Zaid Ajaj 27fbba6900
[program-gen/ts] Fixes generated expression for filebase64 function to use fs.readFileSync directly ()
### Description

Fixes  by correcting the generated expression for the `filebase64`
function

## 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-01-25 18:14:38 +00:00
Fraser Waters 966fd75011
Check PCL outputs can have arbitrary labels ()
Prompted by https://github.com/pulumi/pulumi-yaml/pull/546

At some point we added `__logicalName` to outputs to match
resources/config. But outputs don't actually need lexical and logical
names, they only have logical names. In the cases where `__logicalName`
was set the lexical name was totally ignored.

We can simply just use the block label (block labels can be arbitrary
strings) and eventually deprecate the `__logicalName` option on
`output`.
2024-01-18 22:07:02 +00:00
Fraser Waters 7302311c2c
Renable tests disabled due to appdash () 2024-01-17 09:09:53 +00:00
Zaid Ajaj 91bcce199a
Revert "[sdk-gen/go] Fix compiling plain element type with plain maps" ()
Reverts pulumi/pulumi#14704 

Fixes  because the PR above changed how object types are
referenced when they are plain. It seems that we only support _shallow_
plain types (only container of nested objects can be plain, not the
object itself) which is why we confused the previous diffs to be
correct.

This reverts the PR previous to fix the breaking change at hand but will
reopen  and make sure the fix for it is to generate `ObjectType`
_and_ `ObjectTypeArgs` regardless of whether the location where the
object type is referenced in the schema.
2024-01-05 15:22:41 +00:00
Julien P 0b4edd8902
Fix python cross module imports ()
# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

For python we were generating bad imports for 1) members of the same
module, and 2) for members imported from another module.

When importing from a different module, we want to always reference
members using a fully qualified name (`mymod.childmod.member.Member`) to
avoid any naming clashes in case multiple modules have members of the
same name. For these we need to import their top level python module
(`from ${relPath} import mymod`).

When importing members from the same module, we want to use relative
imports (`from .some_member import SomeMember`).

Fixes https://github.com/pulumi/pulumi/issues/12980

## 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
  - [ ] 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-01-05 09:05:41 +00:00
Justin Van Patten ea7be023f5
Temporarily revert validation of urn/id output properties ()
Partial temporary revert of 8b26393163
(keeping a test that can be kept).

The validation is currently preventing the use of `id` as an output
property for packaged components (i.e. MLCs), which wasn't originally
considered when adding this validation. We do want to be able to support
`id` properties for components, so when we do subsequently add back the
validation, we'll do so in a way that doesn't prevent that.

Part of 
2024-01-03 03:21:23 +00:00
Fraser Waters c902c35148
Delete unused go testdata ()
This test isn't run for Go codegen so these snapshots aren't being
updated or checked against.
2024-01-02 17:20:07 +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 ab17473110
[program-gen/csharp,python] Allow object keys to be template expressions ()
# Description

I've noticed while working with PCL generated from Kubernetes manifests
that when an object property key is quoted for example `{ "key" = value
}` instead of `{ key = value }` then program-gen for csharp and python
_panic_ because they assume the object keys to be strictly a literal
value expression and this type assertion fails:
```go
lit := item.Key.(*model.LiteralValueExpression)
```
This PR fixes this panic and allows program-gen to handle cases where
the object keys are `TemplateExpression` assuming that it has one part
which is a literal value expression (handling cases like `{ "key" =
value }`)

## 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-23 11:26:01 +00:00