diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index e3ee41906ed..f05bbfa6404 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -2,4 +2,6 @@ - Update pulumi/pulumi to v3.132.0 -### Bug Fixes +- Feature flag parameterized provider support + +### Bug Fixes \ No newline at end of file diff --git a/pulumi b/pulumi index 487b4a8494e..e34b753f070 160000 --- a/pulumi +++ b/pulumi @@ -1 +1 @@ -Subproject commit 487b4a8494ef556063aaf8335e6bad6317bb1072 +Subproject commit e34b753f070b2862263f80882ceb88ce69a14272 diff --git a/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java b/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java index 05224613263..0ee8aad34b2 100644 --- a/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java +++ b/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java @@ -253,6 +253,11 @@ private CompletableFuture monitorSupportsFeature(String feature) { CompletableFuture monitorSupportsResourceReferences() { return monitorSupportsFeature("resourceReferences"); } + + @InternalUse + CompletableFuture monitorSupportsParameterization() { + return monitorSupportsFeature("parameterization"); + } } @ParametersAreNonnullByDefault @@ -846,21 +851,27 @@ public CompletableFuture registerPackage( String packageVersion, String base64Parameter ) { - var request = RegisterPackageRequest.newBuilder() - .setName(baseProviderName) - .setVersion(baseProviderVersion) - .setDownloadUrl(baseProviderDownloadUrl) - .setParameterization( - Parameterization.newBuilder() - .setName(packageName) - .setVersion(packageVersion) - .setValue(ByteString.copyFrom(Base64.getDecoder().decode(base64Parameter))) - .build() - ) - .build(); - - return this.state.monitor.registerPackageAsync(request) - .thenApply(response -> response.getRef()); + return this.featureSupport.monitorSupportsParameterization().thenCompose(supportsParameterization -> { + if (!supportsParameterization) { + throw new UnsupportedOperationException("The Pulumi CLI does not support parameterization. Please update the Pulumi CLI."); + } + + var request = RegisterPackageRequest.newBuilder() + .setName(baseProviderName) + .setVersion(baseProviderVersion) + .setDownloadUrl(baseProviderDownloadUrl) + .setParameterization( + Parameterization.newBuilder() + .setName(packageName) + .setVersion(packageVersion) + .setValue(ByteString.copyFrom(Base64.getDecoder().decode(base64Parameter))) + .build() + ) + .build(); + + return this.state.monitor.registerPackageAsync(request) + .thenApply(response -> response.getRef()); + }); } private static final class Prepare { diff --git a/tests/examples/aws-native-java-s3-folder/.gitignore b/tests/examples/aws-native-java-s3-folder/.gitignore new file mode 100644 index 00000000000..1b6985c0094 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/tests/examples/aws-native-java-s3-folder/Pulumi.yaml b/tests/examples/aws-native-java-s3-folder/Pulumi.yaml new file mode 100644 index 00000000000..48dc8bc50d8 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/Pulumi.yaml @@ -0,0 +1,3 @@ +name: aws-java-s3-folder +runtime: java +description: A static website hosted on AWS S3 \ No newline at end of file diff --git a/tests/examples/aws-native-java-s3-folder/README.md b/tests/examples/aws-native-java-s3-folder/README.md new file mode 100644 index 00000000000..c56bbda7e28 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/README.md @@ -0,0 +1,116 @@ +[![Deploy this example with Pulumi](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-native-java-s3-folder/README.md#gh-light-mode-only) +[![Deploy this example with Pulumi](https://get.pulumi.com/new/button-light.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-native-java-s3-folder/README.md#gh-dark-mode-only) + +# Host a Static Website on Amazon S3 with the AWS Native Provider + +A static website that uses [S3's website support](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html). +For a detailed walkthrough of this example, see the tutorial [Static Website on AWS S3](https://www.pulumi.com/docs/tutorials/aws/s3-website/). + +Note: Some resources are not yet supported by the Native AWS provider, so we are using both the Native +and Classic provider in this example. The resources will be updated to use native resources as they are +available in AWS's Cloud Control API. + +## Deploying and running the program + +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + +1. Set the AWS region: + + Either using an environment variable + ```bash + $ export AWS_REGION=us-west-2 + ``` + + Or with the stack config + ```bash + $ pulumi config set aws:region us-west-2 + $ pulumi config set aws-native:region us-west-2 + ``` + +1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. + + ```bash + $ pulumi up + Previewing update (dev) + + View Live: https://app.pulumi.com/***/aws-java-s3-folder/dev/previews/e251093a-d128-4ed3-a230-4e98888aed84 + + Type Name Plan Info + + pulumi:pulumi:Stack aws-java-s3-folder-dev create 6 messages + + ├─ aws-native:s3:Bucket s3-website-bucket create + + ├─ aws:s3:BucketPolicy bucketPolicy create + + ├─ aws:s3:BucketObject index.html create + + └─ aws:s3:BucketObject favicon.ico create + + Diagnostics: + pulumi:pulumi:Stack (aws-java-s3-folder-dev): + > Task :app:compileJava UP-TO-DATE + > Task :app:processResources NO-SOURCE + > Task :app:classes UP-TO-DATE + > Task :app:run + BUILD SUCCESSFUL in 3s + 2 actionable tasks: 1 executed, 1 up-to-date + + + Updating (dev) + + View Live: https://app.pulumi.com/***/aws-java-s3-folder/dev/updates/1 + + Type Name Status Info + + pulumi:pulumi:Stack aws-java-s3-folder-dev created 6 messages + + ├─ aws-native:s3:Bucket s3-website-bucket created + + ├─ aws:s3:BucketPolicy bucketPolicy created + + ├─ aws:s3:BucketObject index.html created + + └─ aws:s3:BucketObject favicon.ico created + + Diagnostics: + pulumi:pulumi:Stack (aws-java-s3-folder-dev): + > Task :app:compileJava UP-TO-DATE + > Task :app:processResources NO-SOURCE + > Task :app:classes UP-TO-DATE + > Task :app:run + BUILD SUCCESSFUL in 1m 5s + 2 actionable tasks: 1 executed, 1 up-to-date + + Outputs: + bucketName: "s3-website-bucket-***" + urn : "***" + websiteUrl: "http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com" + + Resources: + + 5 created + + Duration: 1m6s + ``` + +1. To see the resources that were created, run `pulumi stack output`: + + ```bash + $ pulumi stack output + Current stack outputs (3): + OUTPUT VALUE + bucketName s3-website-bucket-*** + urn urn:pulumi:dev::aws-java-s3-folder::pulumi:pulumi:Stack::aws-java-s3-folder-dev + websiteUrl http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com + ``` + +1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: + + ```bash + $ aws s3 ls $(pulumi stack output bucketName) + 2022-02-17 14:11:54 13731 favicon.ico + 2022-02-17 14:11:54 198 index.html + ``` + +1. Open the site URL in a browser to see both the rendered HTML and the favicon: + + ```bash + $ pulumi stack output websiteUrl + http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com + ``` + + ![Hello S3 example](https://user-images.githubusercontent.com/274700/116912066-9384e300-abfc-11eb-8130-dbcff512a9de.png) + +1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. diff --git a/tests/examples/aws-native-java-s3-folder/pom.xml b/tests/examples/aws-native-java-s3-folder/pom.xml new file mode 100644 index 00000000000..1dd26793316 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + com.pulumi + aws-native-java-s3-folder + 1.0-SNAPSHOT + + + UTF-8 + 17 + 17 + 17 + s3site.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.2,6.99] + + + com.pulumi + aws-native + (,1.0] + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + ${mainClass} + ${mainArgs} + + + + + diff --git a/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java b/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java new file mode 100644 index 00000000000..ee3625f257f --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java @@ -0,0 +1,76 @@ +// from https://github.com/pulumi/examples/blob/8cc8b1a4384c8b33f70ba65c701e19daecfa6399/aws-ts-s3-folder/index.ts +package s3site; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.asset.FileAsset; +import com.pulumi.aws.s3.BucketObject; +import com.pulumi.aws.s3.BucketObjectArgs; +import com.pulumi.aws.s3.BucketPolicy; +import com.pulumi.aws.s3.BucketPolicyArgs; +import com.pulumi.awsnative.s3.Bucket; +import com.pulumi.awsnative.s3.BucketArgs; +import com.pulumi.awsnative.s3.inputs.BucketWebsiteConfigurationArgs; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.BiConsumer; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + private static void stack(Context ctx) { + final var siteBucket = new Bucket("s3-website-bucket", + BucketArgs.builder().websiteConfiguration(BucketWebsiteConfigurationArgs.builder() + .indexDocument("index.html") + .build()).build()); + + final String siteDir = "www/"; + forEachFileInTree(siteDir, (path, contentType) -> { + new BucketObject(path.toString().replace(siteDir, ""), + BucketObjectArgs.builder().bucket(siteBucket.getId()) + .source(new FileAsset(path.toAbsolutePath().toString())) + .contentType(contentType).build() + ); + }); + + final var bucketPolicy = new BucketPolicy("bucketPolicy", + BucketPolicyArgs.builder().bucket(siteBucket.getId()) + .policy(siteBucket.arn() + .applyValue(bucketArn -> """ + { + "Version":"2012-10-17", + "Statement":[{ + "Effect":"Allow", + "Principal":"*", + "Action":["s3:GetObject"], + "Resource":["%s/*"] + }] + } + """.formatted(bucketArn)) + ).build()); + + ctx.export("bucketName", siteBucket.bucketName()); + ctx.export("websiteUrl", siteBucket.websiteUrl()); + } + + private static void forEachFileInTree(String siteDir, BiConsumer consumer) { + try (var paths = Files.walk(Paths.get(siteDir)).filter(Files::isRegularFile)) { + paths.forEach(path -> { + final String contentType; + try { + contentType = Files.probeContentType(path); + } catch (IOException e) { + throw new RuntimeException(String.format("Failed to probeContentType for path: '%s'", path), e); + } + consumer.accept(path, contentType); + }); + } catch (IOException e) { + throw new RuntimeException(String.format("Failed to walk a path: '%s'", siteDir), e); + } + } +} diff --git a/tests/examples/aws-native-java-s3-folder/www/favicon.ico b/tests/examples/aws-native-java-s3-folder/www/favicon.ico new file mode 100644 index 00000000000..ad4baeb6fd3 Binary files /dev/null and b/tests/examples/aws-native-java-s3-folder/www/favicon.ico differ diff --git a/tests/examples/aws-native-java-s3-folder/www/index.html b/tests/examples/aws-native-java-s3-folder/www/index.html new file mode 100644 index 00000000000..db1c4d3f525 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/www/index.html @@ -0,0 +1,7 @@ + + + Hello, Pulumi! + +

Hello, S3!

+

Made with ❤️ with Pulumi

+ diff --git a/tests/examples/java_examples_test.go b/tests/examples/java_examples_test.go index cc29bed86ad..df1cb907aaf 100644 --- a/tests/examples/java_examples_test.go +++ b/tests/examples/java_examples_test.go @@ -30,34 +30,41 @@ const previewOnly = true func TestExamples(t *testing.T) { t.Run("random", func(t *testing.T) { - test := getJavaBase(t, "random", integration.ProgramTestOptions{ - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - o := stackInfo.Outputs - assert.Greater(t, o["randomInteger"].(float64), -0.1) - assert.Len(t, o["randomString"].(string), 10) - assert.Len(t, o["randomUuid"].(string), 36) - assert.Len(t, o["randomIdHex"].(string), 20) - - for _, s := range o["shuffled"].([]interface{}) { - s := s.(string) - assert.Contains(t, []string{"A", "B", "C"}, s) - } - - hasCipherText := false - for k := range o["randomPassword"].(map[string]interface{}) { - if k == "ciphertext" { - hasCipherText = true + test := makeJavaProgramTestOptions( + t, + "tests/examples/random", + []string{"random"}, + integration.ProgramTestOptions{ + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + o := stackInfo.Outputs + assert.Greater(t, o["randomInteger"].(float64), -0.1) + assert.Len(t, o["randomString"].(string), 10) + assert.Len(t, o["randomUuid"].(string), 36) + assert.Len(t, o["randomIdHex"].(string), 20) + + for _, s := range o["shuffled"].([]interface{}) { + s := s.(string) + assert.Contains(t, []string{"A", "B", "C"}, s) } - } - assert.True(t, hasCipherText) + + hasCipherText := false + for k := range o["randomPassword"].(map[string]interface{}) { + if k == "ciphertext" { + hasCipherText = true + } + } + assert.True(t, hasCipherText) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-static-website", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-static-website", + test := makeJavaProgramTestOptions( + t, + "examples/azure-java-static-website", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -70,13 +77,15 @@ func TestExamples(t *testing.T) { assert.True(t, strings.HasPrefix(cdnEndpoint, "https")) assert.True(t, strings.HasPrefix(staticEndpoint, "https")) }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("aws-java-webserver", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-java-webserver", + test := makeJavaProgramTestOptions(t, + "examples/aws-java-webserver", []string{"aws"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -89,38 +98,44 @@ func TestExamples(t *testing.T) { assert.True(t, strings.Contains(publicIp, ".")) assert.True(t, strings.Contains(publicHostName, ".")) }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-appservice-sql", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-appservice-sql", + test := makeJavaProgramTestOptions(t, + "examples/azure-java-appservice-sql", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ "azure-native:location": "westus", "azure-java-appservice-sql:sqlPassword": "not-a-real-password", }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("aws-java-eks-minimal", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-java-eks-minimal", + test := makeJavaProgramTestOptions(t, + "examples/aws-java-eks-minimal", []string{"eks", "aws", "kubernetes"}, integration.ProgramTestOptions{ Config: map[string]string{ "aws:region": "us-west-1", }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("gcp-java-gke-hello-world", func(t *testing.T) { - test := getJavaBaseNew(t, - "gcp-java-gke-hello-world", + test := makeJavaProgramTestOptions(t, + "examples/gcp-java-gke-hello-world", []string{"gcp"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -128,70 +143,88 @@ func TestExamples(t *testing.T) { "gcp:project": "pulumi-ci-gcp-provider", "gcp:zone": "us-west1-a", }, - }) + }, + ) integration.ProgramTest(t, &test) }) t.Run("kubernetes", func(t *testing.T) { t.SkipNow() - test := getJavaBase(t, "kubernetes", integration.ProgramTestOptions{ - Config: map[string]string{}, - }) + test := makeJavaProgramTestOptions( + t, + "tests/examples/kubernetes", + []string{"kubernetes"}, + integration.ProgramTestOptions{ + Config: map[string]string{}, + }, + ) + integration.ProgramTest(t, &test) }) t.Run("minimal", func(t *testing.T) { - test := getJavaBase(t, "minimal", integration.ProgramTestOptions{ - PrepareProject: func(info *engine.Projinfo) error { - cmd := exec.Command(filepath.Join(info.Root, "mvnw"), - "--no-transfer-progress", "package") - cmd.Dir = info.Root - var buf bytes.Buffer - cmd.Stdout = &buf - cmd.Stderr = &buf - err := cmd.Run() - - if err != nil { - t.Logf("mvwn --no-transfer-progress package: %v", err) - t.Log(buf.String()) - } + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimal", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + PrepareProject: func(info *engine.Projinfo) error { + cmd := exec.Command(filepath.Join(info.Root, "mvnw"), + "--no-transfer-progress", "package") + cmd.Dir = info.Root + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err := cmd.Run() + if err != nil { + t.Logf("mvwn --no-transfer-progress package: %v", err) + t.Log(buf.String()) + } - return err - }, - Config: map[string]string{ - "name": "Pulumi", - }, - Secrets: map[string]string{ - "secret": "this is my secret message", - }, - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - // Simple runtime validation that just ensures the checkpoint was written and read. - assert.NotNil(t, stackInfo.Deployment) + return err + }, + Config: map[string]string{ + "name": "Pulumi", + }, + Secrets: map[string]string{ + "secret": "this is my secret message", + }, + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + // Simple runtime validation that just ensures the checkpoint was written and read. + assert.NotNil(t, stackInfo.Deployment) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("minimalsbt", func(t *testing.T) { - test := getJavaBase(t, "minimalsbt", integration.ProgramTestOptions{ - Config: map[string]string{ - "name": "Pulumi", - }, - Secrets: map[string]string{ - "secret": "this is my secret message", - }, - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - // Simple runtime validation that just ensures the checkpoint was written and read. - assert.NotNil(t, stackInfo.Deployment) + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimalsbt", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "name": "Pulumi", + }, + Secrets: map[string]string{ + "secret": "this is my secret message", + }, + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + // Simple runtime validation that just ensures the checkpoint was written and read. + assert.NotNil(t, stackInfo.Deployment) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("aws-native-java-s3-folder", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-native-java-s3-folder", + test := makeJavaProgramTestOptions(t, + "tests/examples/aws-native-java-s3-folder", []string{"aws", "aws-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -203,13 +236,15 @@ func TestExamples(t *testing.T) { // provider bug. We need to recheck // after upgrading to latest. SkipRefresh: true, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-function-graal-spring", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-function-graal-spring", + test := makeJavaProgramTestOptions(t, + "examples/azure-java-function-graal-spring", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -238,41 +273,66 @@ func TestExamples(t *testing.T) { } return err }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("minimal-jbang", func(t *testing.T) { - test := getJavaBase(t, "minimal-jbang", integration.ProgramTestOptions{ - Config: map[string]string{ - "minimal:name": "minimal-name", - "minimal:secret": "minimal-secret", + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimal-jbang", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "minimal:name": "minimal-name", + "minimal:secret": "minimal-secret", + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("testing-unit-java", func(t *testing.T) { - test := getJavaBase(t, "testing-unit-java", integration.ProgramTestOptions{ - Config: map[string]string{ - "aws:region": "us-east-2", + test := makeJavaProgramTestOptions( + t, + "tests/examples/testing-unit-java", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "aws:region": "us-east-2", + }, }, - }) + ) + integration.ProgramTest(t, &test) }) } -func getJavaBaseNew( +// Constructs a set of integration.ProgramTestOptions for running a Java example test. The supplied directory will be +// resolved relative to the repository root, and is typically one of the following: +// +// - tests/examples/ if the example being tested is vendored into this repository. +// - examples/ if the example being tested is in the Pulumi examples repository, which is cloned into this one +// as part of running this test suite. +func makeJavaProgramTestOptions( t *testing.T, dir string, providers []string, - testSpecificOptions integration.ProgramTestOptions, + overrides integration.ProgramTestOptions, ) integration.ProgramTestOptions { repoRoot, err := filepath.Abs(filepath.Join("..", "..")) if err != nil { panic(err) } + prepareProject := func(info *engine.Projinfo) error { + if len(providers) == 0 { + return nil + } + deps, err := jtests.ParsePinVersionsFromEnv(t, providers) if err != nil { return err @@ -280,17 +340,17 @@ func getJavaBaseNew( _, err = jtests.Pin(info.Root, deps) return err } - opts := integration.ProgramTestOptions{ - Dir: filepath.Join(repoRoot, "examples", dir), - } - opts = opts.With(getBaseOptions()). - With(testSpecificOptions). + + opts := integration.ProgramTestOptions{Dir: filepath.Join(repoRoot, dir)}. + With(getBaseOptions()). + With(overrides). With(integration.ProgramTestOptions{ PrepareProject: combinePrepareProject( prepareProject, - testSpecificOptions.PrepareProject, + overrides.PrepareProject, ), }) + if previewOnly { opts = opts.With(integration.ProgramTestOptions{ SkipRefresh: true, @@ -300,6 +360,7 @@ func getJavaBaseNew( }) opts.ExtraRuntimeValidation = nil } + return opts } @@ -317,26 +378,6 @@ func combinePrepareProject(f1, f2 func(info *engine.Projinfo) error) func(info * } } -func getJavaBase(t *testing.T, dir string, testSpecificOptions integration.ProgramTestOptions) integration.ProgramTestOptions { - opts := integration.ProgramTestOptions{ - Dir: filepath.Join(getCwd(t), dir), - PrepareProject: func(*engine.Projinfo) error { - return nil // needed because defaultPrepareProject does not know about java - }, - } - opts = opts.With(getBaseOptions()).With(testSpecificOptions) - if previewOnly { - opts = opts.With(integration.ProgramTestOptions{ - SkipRefresh: true, - SkipEmptyPreviewUpdate: true, - SkipExportImport: true, - SkipUpdate: true, - }) - opts.ExtraRuntimeValidation = nil - } - return opts -} - // Copied from: https://github.com/pulumi/examples/blob/4fb1f146409ace4af1945f84ee9c90c643430e9d/misc/test/examples_test.go func assertHTTPResult(t *testing.T, output interface{}, headers map[string]string, check func(string) bool) bool { @@ -348,7 +389,8 @@ func assertHTTPResultWithRetry(t *testing.T, output interface{}, headers map[str } func assertHTTPResultShapeWithRetry(t *testing.T, output interface{}, headers map[string]string, maxWait time.Duration, - ready func(string) bool, check func(string) bool) bool { + ready func(string) bool, check func(string) bool, +) bool { hostname, ok := output.(string) if !assert.True(t, ok, fmt.Sprintf("expected `%s` output", output)) { return false @@ -416,4 +458,4 @@ func assertHTTPResultShapeWithRetry(t *testing.T, output interface{}, headers ma } return false -} +} \ No newline at end of file diff --git a/tests/integration/java_integration_test.go b/tests/integration/java_integration_test.go index c231a5077a9..4f72c509843 100644 --- a/tests/integration/java_integration_test.go +++ b/tests/integration/java_integration_test.go @@ -25,7 +25,7 @@ func TestIntegrations(t *testing.T) { DebugLogLevel: 0, // Stack references will change on refresh due to steps changing outputs and self stack // references. - SkipRefresh: true, + SkipRefresh: true, Env: []string{ "PULUMI_EXCESSIVE_DEBUG_OUTPUT=false", }, diff --git a/tests/integration/util.go b/tests/integration/util.go index 589f02e0a86..3405d70ff4b 100644 --- a/tests/integration/util.go +++ b/tests/integration/util.go @@ -3,10 +3,11 @@ package integration import ( - "github.com/pulumi/pulumi/pkg/v3/engine" - "github.com/pulumi/pulumi/pkg/v3/testing/integration" "os" "testing" + + "github.com/pulumi/pulumi/pkg/v3/engine" + "github.com/pulumi/pulumi/pkg/v3/testing/integration" ) func getCwd(t *testing.T) string { diff --git a/tests/internal/pin.go b/tests/internal/pin.go index 9af9e8eab38..f49db35db6d 100644 --- a/tests/internal/pin.go +++ b/tests/internal/pin.go @@ -173,7 +173,7 @@ func editFile(path string, edit func([]byte) []byte) (FileEdit, error) { if err != nil { return nil, err } - err = ioutil.WriteFile(path, edit(bytes), 0600) + err = ioutil.WriteFile(path, edit(bytes), 0o600) return revertFile{path, bytes}, err } @@ -183,5 +183,5 @@ type revertFile struct { } func (rf revertFile) Revert() error { - return ioutil.WriteFile(rf.path, rf.bytes, 0600) + return ioutil.WriteFile(rf.path, rf.bytes, 0o600) }