pulumi / pulumi-java

Java support for Pulumi
Apache License 2.0
69 stars 21 forks source link

PULUMI_CONFIG env variable is not used with PulumiTest #1333

Open imavroukakis opened 5 months ago

imavroukakis commented 5 months ago

What happened?

Trying to use a configuration JSON during testing via the environment variable at runtime - as is the case with the implementation in other languages.

Example

Given '{"project:the_environment": "devtest"}' stored in PULUMI_CONFIG

final var config = ctx.config();
final var environment = config.get("the_environment")

fails when testing via PulumiTest

Output of pulumi about

CLI
Version      3.108.1
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME        VERSION
aws         6.18.2
aws-native  0.95.0
java        unknown

Host
OS       darwin
Version  14.4
Arch     x86_64

Additional context

Instead of initialising an empty config in PulumiTestInternal

if (this.config == null) {
                this.config = new DeploymentImpl.Config(ImmutableMap.of(), ImmutableSet.of());
}

it should be possible and safe to do

if (this.config == null) {
                this.config = Config.parse();
}

instead.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

justinvp commented 5 months ago

@imavroukakis, thanks for opening the issue. Would you be interested in contributing a fix?

imavroukakis commented 5 months ago

@justinvp happy to!

imavroukakis commented 5 months ago

apologies for taking so long, will have a pull request soon !

imavroukakis commented 3 months ago

hey @justinvp , I have made the change but I cannot for the life of me figure out how unit tests are run for the java repo, any doco I could perhaps reference?

joaotab commented 1 month ago

hey @imavroukakis I'm not a contributor to this project but I was also looking for this to work since right now it seems we can't run Unit Tests in Java that require any sort of Pulumi config.

Anything I can help you with? Looks like Make is used as a build tool and there are some go command line examples in the Makefile for running tests.

imavroukakis commented 3 weeks ago

Hey @joaotab I want to actually run the Java side of the tests but they seem to blow up in unrelated places. The aim here is to a) make sure the existing tests are not broken b) if they break , fix them c) add tests for the new functionality