pulumi/pkg/cmd
Will Jones 34eac65c20
Only use gRPC to communicate with the Java host (#18138)
Language hosts are an important part of the Pulumi ecosystem,
encapsulating language-specific concerns such as program execution,
plugin hosting, and code generation, and exposing these as a gRPC
service.

Presently, we abuse the fact that the Java language host (along with all
other Pulumi-maintained language hosts) is written in Go to invoke some
of its functionality _directly_---that is, as linked in-memory function
calls---by having `pulumi/pulumi` depend on `pulumi/pulumi-java` in its
`go.mod`. This is undesirable for several reasons -- it creates
unnecessary coupling (indeed, a very annoying cyclic dependency),
requires special-casing in various parts of the CLI, and is hard to
test. In this change, therefore, we switch out these in-memory calls for
"proper" gRPC ones. Specifically:

* `pulumi convert` and `pulumi import` will now call `GenerateProject`
and `GenerateProgram` (Programgen) over a gRPC wire.
* `pulumi package gen-sdk` will now call `GeneratePackage` (SDKgen) over
a gRPC wire.
* `pulumi-java` is removed as a dependency from `go.mod`(s).
`pulumi-java`'s version is now explicitly tracked in the
`scripts/get-language-providers.sh` script (which also becomes simpler
now we have no `go.mod`-dependency-hosts any more).

Aside from the fact that calls are now being made over a network
connection, behaviour should be identical:

* The gRPC implementations of `GenerateProgram` and `GenerateProject`
(found in `pkg/cmd/pulumi-language-java/main.go` in `pulumi-java`) call
the currently used in-memory function as-is, with no surrounding code
except for deserialization of inputs and binding of PCL.
* The gRPC implementation of `GeneratePackage` performs a single
operation aside from deserialization and binding -- name deduplication.
This is the same function as that performed by the `pulumi-java-gen`
binary that is currently used to generate Java SDKs (until now,
`gen-sdk` has not been used _at all_---in-memory or otherwise---due to
this and other issues; see
https://github.com/pulumi/pulumi-java/issues/1508). As a result, this
should now be a suitable replacement for `pulumi-java-gen` and the
correct implementation for `gen-sdk`.

With this, we can remove the cyclic dependency, get rid of
`pulumi-java-gen` and clean up several bits of bespoke code. Rock on,
Java!

> [!NOTE]
> Aside from Java conformance tests giving us confidence, `pulumi
package gen-sdk` has been manually tested with `pulumi-azure-native`,
which is referenced in
https://github.com/pulumi/pulumi-java/issues/1508.

Fixes https://github.com/pulumi/pulumi-java/issues/1508
2025-01-03 16:48:13 +00:00
..
pulumi Only use gRPC to communicate with the Java host (#18138) 2025-01-03 16:48:13 +00:00