From e493d3cb73af55e439b9c6c4d46934edadf89c30 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Fri, 4 Oct 2024 19:09:52 +0000 Subject: [PATCH 01/19] feat: add properties to customize universe-domain and endpoint in Storage --- .../GcpBigQueryAutoConfiguration.java | 2 +- .../storage/GcpStorageAutoConfiguration.java | 29 ++++++- .../storage/GcpStorageProperties.java | 27 +++++++ .../GcpStorageAutoConfigurationTests.java | 81 ++++++++++++++++--- 4 files changed, 121 insertions(+), 18 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryAutoConfiguration.java index 2bab6fb587..7b2ce44422 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryAutoConfiguration.java @@ -160,7 +160,7 @@ public BigQueryTemplate bigQueryTemplate( bigQuery, bigQueryWriteClient, bqInitSettings, bigQueryThreadPoolTaskScheduler); } - private String resolveToHost(String endpoint) throws URISyntaxException { + private String resolveToHost(String endpoint) { int portIndex = endpoint.indexOf(":"); if (portIndex != -1) { return "https://" + endpoint.substring(0, portIndex) + "/"; diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index 7bd6f36fda..ba2ee12280 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -52,6 +52,10 @@ public class GcpStorageAutoConfiguration { // NOSONAR squid:S1610 must be a clas private final CredentialsProvider credentialsProvider; + private final String universeDomain; + + private final String endpoint; + public GcpStorageAutoConfiguration( GcpProjectIdProvider coreProjectIdProvider, CredentialsProvider credentialsProvider, @@ -67,16 +71,33 @@ public GcpStorageAutoConfiguration( gcpStorageProperties.getCredentials().hasKey() ? new DefaultCredentialsProvider(gcpStorageProperties) : credentialsProvider; + + this.universeDomain = gcpStorageProperties.getUniverseDomain(); + this.endpoint = gcpStorageProperties.getEndpoint(); } @Bean @ConditionalOnMissingBean public Storage storage() throws IOException { - return StorageOptions.newBuilder() + StorageOptions.Builder storageOptionsBuilder = StorageOptions.newBuilder() .setHeaderProvider(new UserAgentHeaderProvider(GcpStorageAutoConfiguration.class)) .setProjectId(this.gcpProjectIdProvider.getProjectId()) - .setCredentials(this.credentialsProvider.getCredentials()) - .build() - .getService(); + .setCredentials(this.credentialsProvider.getCredentials()); + + if (this.universeDomain != null){ + storageOptionsBuilder.setUniverseDomain(this.universeDomain); + } + if (this.endpoint != null){ + storageOptionsBuilder.setHost(resolveToHost(this.endpoint)); + } + return storageOptionsBuilder.build().getService(); + } + + private String resolveToHost(String endpoint) { + int portIndex = endpoint.indexOf(":"); + if (portIndex != -1) { + return "https://" + endpoint.substring(0, portIndex) + "/"; + } + return "https://" + endpoint + "/"; } } diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index 2b86449c62..aea362a4c9 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -37,6 +37,11 @@ public Credentials getCredentials() { } private String projectId; + + private String universeDomain; + + private String endpoint; + public String getProjectId() { return projectId; @@ -45,4 +50,26 @@ public String getProjectId() { public void setProjectId(String projectId) { this.projectId = projectId; } + + public String getUniverseDomain() { + return universeDomain; + } + + public void setUniverseDomain(String universeDomain) { + this.universeDomain = universeDomain; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } } + + + + + + diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java index fa36ccec9c..868d502502 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java @@ -49,7 +49,8 @@ class GcpStorageAutoConfigurationTests { @Test void testValidObject() throws Exception { - this.contextRunner.run( + this.contextRunner + .withUserConfiguration(TestStorageConfiguration.class).run( context -> { Resource resource = context.getBean("mockResource", Resource.class); assertThat(resource.contentLength()).isEqualTo(4096); @@ -58,7 +59,8 @@ void testValidObject() throws Exception { @Test void testAutoCreateFilesTrueByDefault() throws IOException { - this.contextRunner.run( + this.contextRunner + .withUserConfiguration(TestStorageConfiguration.class).run( context -> { Resource resource = context.getBean("mockResource", Resource.class); assertThat(((GoogleStorageResource) resource).isAutoCreateFiles()).isTrue(); @@ -66,9 +68,10 @@ void testAutoCreateFilesTrueByDefault() throws IOException { } @Test - void testAutoCreateFilesRespectsProperty() throws IOException { + void testAutoCreateFilesRespectsProperty() { this.contextRunner + .withUserConfiguration(TestStorageConfiguration.class) .withPropertyValues("spring.cloud.gcp.storage.auto-create-files=false") .run( context -> { @@ -77,9 +80,71 @@ void testAutoCreateFilesRespectsProperty() throws IOException { }); } + @Test + void testUniverseDomain() { + this.contextRunner + .withPropertyValues("spring.cloud.gcp.storage.universe-domain=example.com") + .run( + context -> { + Storage storage = context.getBean("storage", Storage.class); + assertThat(storage.getOptions().getUniverseDomain()).isEqualTo("example.com"); + assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.example.com/"); + }); + } + + @Test + void testEndpoint() { + this.contextRunner + .withPropertyValues("spring.cloud.gcp.storage.endpoint=storage.example.com") + .run( + context -> { + Storage storage = context.getBean("storage", Storage.class); + assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.example.com/"); + }); + } + + @Test + void testUniverseDomainAndEndpointSet() { + this.contextRunner + .withPropertyValues("spring.cloud.gcp.storage.universe-domain=example.com", + "spring.cloud.gcp.storage.endpoint=storage.example.com") + .run( + context -> { + Storage storage = context.getBean("storage", Storage.class); + assertThat(storage.getOptions().getUniverseDomain()).isEqualTo("example.com"); + assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.example.com/"); + }); + } + + @Test + void testNoUniverseDomainAndEndpointSet_useDefaults() { + this.contextRunner + .run( + context -> { + Storage storage = context.getBean("storage", Storage.class); + assertThat(storage.getOptions().getUniverseDomain()).isNull(); + assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.googleapis.com/"); + }); + } + + @Configuration static class TestConfiguration { + @Bean + public static CredentialsProvider googleCredentials() { + return () -> mock(Credentials.class); + } + + @Bean + public static GcpProjectIdProvider gcpProjectIdProvider() { + return () -> "default-project"; + } + } + + @Configuration + static class TestStorageConfiguration { + @Value("gs://test-spring/images/spring.png") private Resource remoteResource; @@ -98,15 +163,5 @@ public static Storage mockStorage() throws Exception { when(storage.get(validBlob)).thenReturn(mockedBlob); return storage; } - - @Bean - public static CredentialsProvider googleCredentials() { - return () -> mock(Credentials.class); - } - - @Bean - public static GcpProjectIdProvider gcpProjectIdProvider() { - return () -> "default-project"; - } } } From 061be96c16ed3a7ea20022fdb29de9ef2fd46ce6 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Fri, 4 Oct 2024 19:12:12 +0000 Subject: [PATCH 02/19] fix format --- .../autoconfigure/storage/GcpStorageProperties.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index aea362a4c9..283b44d698 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -50,7 +50,7 @@ public String getProjectId() { public void setProjectId(String projectId) { this.projectId = projectId; } - + public String getUniverseDomain() { return universeDomain; } @@ -67,9 +67,3 @@ public void setEndpoint(String endpoint) { this.endpoint = endpoint; } } - - - - - - From 33872a64098cb450e99ca6a71976df73d1a3071d Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Fri, 4 Oct 2024 19:39:12 +0000 Subject: [PATCH 03/19] expose host instead of endpoint --- docs/src/main/asciidoc/storage.adoc | 2 + .../storage/GcpStorageAutoConfiguration.java | 27 ++++------ .../storage/GcpStorageProperties.java | 20 ++++--- .../GcpStorageAutoConfigurationTests.java | 54 +++++++++---------- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/docs/src/main/asciidoc/storage.adoc b/docs/src/main/asciidoc/storage.adoc index 7dd2cf9bb8..4af7d3c509 100644 --- a/docs/src/main/asciidoc/storage.adoc +++ b/docs/src/main/asciidoc/storage.adoc @@ -119,6 +119,8 @@ The Spring Boot Starter for Google Cloud Storage provides the following configur Base64-encoded contents of OAuth2 account private key for authenticating with the Google Cloud Storage API, if different from the ones in the <> | No | | `spring.cloud.gcp.storage.credentials.scopes` | https://developers.google.com/identity/protocols/googlescopes[OAuth2 scope] for Spring Framework on Google Cloud Storage credentials | No | https://www.googleapis.com/auth/devstorage.read_write +| `spring.cloud.gcp.bigquery.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain} | No | Relies on client library’s default universe domain which is googleapis.com +| `spring.cloud.gcp.bigquery.host` | Host of the Storage service which is formatted as https://${service}.${universeDomain}. | No | Relies on client library’s default host which is `https://storage.googleapis.com` |=== diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index ba2ee12280..a77ca8459e 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -54,7 +54,7 @@ public class GcpStorageAutoConfiguration { // NOSONAR squid:S1610 must be a clas private final String universeDomain; - private final String endpoint; + private final String host; public GcpStorageAutoConfiguration( GcpProjectIdProvider coreProjectIdProvider, @@ -73,31 +73,24 @@ public GcpStorageAutoConfiguration( : credentialsProvider; this.universeDomain = gcpStorageProperties.getUniverseDomain(); - this.endpoint = gcpStorageProperties.getEndpoint(); + this.host = gcpStorageProperties.getHost(); } @Bean @ConditionalOnMissingBean public Storage storage() throws IOException { - StorageOptions.Builder storageOptionsBuilder = StorageOptions.newBuilder() - .setHeaderProvider(new UserAgentHeaderProvider(GcpStorageAutoConfiguration.class)) - .setProjectId(this.gcpProjectIdProvider.getProjectId()) - .setCredentials(this.credentialsProvider.getCredentials()); + StorageOptions.Builder storageOptionsBuilder = + StorageOptions.newBuilder() + .setHeaderProvider(new UserAgentHeaderProvider(GcpStorageAutoConfiguration.class)) + .setProjectId(this.gcpProjectIdProvider.getProjectId()) + .setCredentials(this.credentialsProvider.getCredentials()); - if (this.universeDomain != null){ + if (this.universeDomain != null) { storageOptionsBuilder.setUniverseDomain(this.universeDomain); } - if (this.endpoint != null){ - storageOptionsBuilder.setHost(resolveToHost(this.endpoint)); + if (this.host != null) { + storageOptionsBuilder.setHost(this.host); } return storageOptionsBuilder.build().getService(); } - - private String resolveToHost(String endpoint) { - int portIndex = endpoint.indexOf(":"); - if (portIndex != -1) { - return "https://" + endpoint.substring(0, portIndex) + "/"; - } - return "https://" + endpoint + "/"; - } } diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index 283b44d698..f1b3c1cecb 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -37,11 +37,15 @@ public Credentials getCredentials() { } private String projectId; - + + /** + * Universe domain of the client which is part of the host that is formatted as + * `https://${service}.${universeDomain}. + */ private String universeDomain; - - private String endpoint; - + + /** Host of the Storage client that is formatted as `https://${service}.${universeDomain}. */ + private String host; public String getProjectId() { return projectId; @@ -59,11 +63,11 @@ public void setUniverseDomain(String universeDomain) { this.universeDomain = universeDomain; } - public String getEndpoint() { - return endpoint; + public String getHost() { + return host; } - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; + public void setHost(String host) { + this.host = host; } } diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java index 868d502502..50d0821ec6 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java @@ -48,28 +48,29 @@ class GcpStorageAutoConfigurationTests { .withUserConfiguration(TestConfiguration.class); @Test - void testValidObject() throws Exception { + void testValidObject() { this.contextRunner - .withUserConfiguration(TestStorageConfiguration.class).run( - context -> { - Resource resource = context.getBean("mockResource", Resource.class); - assertThat(resource.contentLength()).isEqualTo(4096); - }); + .withUserConfiguration(TestStorageConfiguration.class) + .run( + context -> { + Resource resource = context.getBean("mockResource", Resource.class); + assertThat(resource.contentLength()).isEqualTo(4096); + }); } @Test - void testAutoCreateFilesTrueByDefault() throws IOException { + void testAutoCreateFilesTrueByDefault() { this.contextRunner - .withUserConfiguration(TestStorageConfiguration.class).run( - context -> { - Resource resource = context.getBean("mockResource", Resource.class); - assertThat(((GoogleStorageResource) resource).isAutoCreateFiles()).isTrue(); - }); + .withUserConfiguration(TestStorageConfiguration.class) + .run( + context -> { + Resource resource = context.getBean("mockResource", Resource.class); + assertThat(((GoogleStorageResource) resource).isAutoCreateFiles()).isTrue(); + }); } @Test void testAutoCreateFilesRespectsProperty() { - this.contextRunner .withUserConfiguration(TestStorageConfiguration.class) .withPropertyValues("spring.cloud.gcp.storage.auto-create-files=false") @@ -93,9 +94,9 @@ void testUniverseDomain() { } @Test - void testEndpoint() { + void testHost() { this.contextRunner - .withPropertyValues("spring.cloud.gcp.storage.endpoint=storage.example.com") + .withPropertyValues("spring.cloud.gcp.storage.host=https://storage.example.com/") .run( context -> { Storage storage = context.getBean("storage", Storage.class); @@ -104,10 +105,11 @@ void testEndpoint() { } @Test - void testUniverseDomainAndEndpointSet() { + void testUniverseDomainAndHostSet() { this.contextRunner - .withPropertyValues("spring.cloud.gcp.storage.universe-domain=example.com", - "spring.cloud.gcp.storage.endpoint=storage.example.com") + .withPropertyValues( + "spring.cloud.gcp.storage.universe-domain=example.com", + "spring.cloud.gcp.storage.host=https://storage.example.com/") .run( context -> { Storage storage = context.getBean("storage", Storage.class); @@ -117,17 +119,15 @@ void testUniverseDomainAndEndpointSet() { } @Test - void testNoUniverseDomainAndEndpointSet_useDefaults() { - this.contextRunner - .run( - context -> { - Storage storage = context.getBean("storage", Storage.class); - assertThat(storage.getOptions().getUniverseDomain()).isNull(); - assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.googleapis.com/"); - }); + void testNoUniverseDomainOrHostSet_useDefaults() { + this.contextRunner.run( + context -> { + Storage storage = context.getBean("storage", Storage.class); + assertThat(storage.getOptions().getUniverseDomain()).isNull(); + assertThat(storage.getOptions().getHost()).isEqualTo("https://storage.googleapis.com/"); + }); } - @Configuration static class TestConfiguration { From 476dde2d44989d32704ff8128ba23ea512cd2bfd Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Fri, 4 Oct 2024 20:00:28 +0000 Subject: [PATCH 04/19] fix docs --- docs/src/main/asciidoc/storage.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/storage.adoc b/docs/src/main/asciidoc/storage.adoc index 4af7d3c509..217e73b2f4 100644 --- a/docs/src/main/asciidoc/storage.adoc +++ b/docs/src/main/asciidoc/storage.adoc @@ -119,8 +119,8 @@ The Spring Boot Starter for Google Cloud Storage provides the following configur Base64-encoded contents of OAuth2 account private key for authenticating with the Google Cloud Storage API, if different from the ones in the <> | No | | `spring.cloud.gcp.storage.credentials.scopes` | https://developers.google.com/identity/protocols/googlescopes[OAuth2 scope] for Spring Framework on Google Cloud Storage credentials | No | https://www.googleapis.com/auth/devstorage.read_write -| `spring.cloud.gcp.bigquery.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain} | No | Relies on client library’s default universe domain which is googleapis.com -| `spring.cloud.gcp.bigquery.host` | Host of the Storage service which is formatted as https://${service}.${universeDomain}. | No | Relies on client library’s default host which is `https://storage.googleapis.com` +| `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain} | No | Relies on client library’s default universe domain which is googleapis.com +| `spring.cloud.gcp.storage.host` | Host of the Storage service which expects https://${service}.${universeDomain} as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` |=== From e5b3503d4630aa48b102bf776fbd951b0d1329c6 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 8 Oct 2024 21:48:12 +0000 Subject: [PATCH 05/19] add check for validating host; include consistent documentation --- .../bigquery/GcpBigQueryProperties.java | 9 +++- .../autoconfigure/kms/.idea/workspace.xml | 44 +++++++++++++++++++ .../autoconfigure/kms/GcpKmsProperties.java | 6 +++ .../storage/GcpStorageAutoConfiguration.java | 13 +++++- .../storage/GcpStorageProperties.java | 2 +- .../GcpStorageAutoConfigurationTests.java | 18 ++++++++ 6 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java index f555c4ae2c..ed317a7eae 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java @@ -45,10 +45,17 @@ public class GcpBigQueryProperties implements CredentialsSupplier { /** The size of thread pool of ThreadPoolTaskScheduler used by GcpBigQueryAutoConfiguration */ private int threadPoolSize; + /** + * Universe domain of the Bigquery and BigQueryWriteClient which is part of the endpoint that is + * formatted as `{service}.{universeDomain}:${port}`. + */ private String universeDomain; /** - * Endpoint (formatted as `{service}.{universeDomain}:${port}`) + * Endpoint of the Bigquery and BigQueryWriteClient. Formatted as + * `{service}.{universeDomain}:${port}`. Note that endpoint will be reformatted in {@link + * GcpBigQueryAutoConfiguration} to follow the `https://${service}.${universeDomain}/` pattern + * before being applied to the Bigquery client. */ private String endpoint; diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml new file mode 100644 index 0000000000..c08bd36559 --- /dev/null +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1723142811474 + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java index df7d90c459..be4217131e 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java @@ -31,8 +31,14 @@ public class GcpKmsProperties implements CredentialsSupplier { /** Overrides the GCP Project ID specified in the Core module. */ private String projectId; + + /** + * Universe domain of the client which is part of the endpoint that is formatted as + * `${service}.${universeDomain}:${port}` + */ private String universeDomain; + /** Enspoint of the KMS client which is formatted as`${service}.${universeDomain}:${port}` */ private String endpoint; @Override diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index a77ca8459e..463312cf5c 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -26,6 +26,7 @@ import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; import java.io.IOException; + import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -89,8 +90,18 @@ public Storage storage() throws IOException { storageOptionsBuilder.setUniverseDomain(this.universeDomain); } if (this.host != null) { - storageOptionsBuilder.setHost(this.host); + storageOptionsBuilder.setHost(verifyAndFetchHost(this.host)); } return storageOptionsBuilder.build().getService(); } + + private String verifyAndFetchHost(String host) { + if (!host.startsWith("https://")) { + throw new IllegalArgumentException( + "Invalid host format: " + + host + + ". Please verify that the specified host follows the 'https://${service}.${universeDomain}' format"); + } + return host; + } } diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index f1b3c1cecb..59ab708f3b 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -44,7 +44,7 @@ public Credentials getCredentials() { */ private String universeDomain; - /** Host of the Storage client that is formatted as `https://${service}.${universeDomain}. */ + /** Host of the Storage client that is formatted as `https://${service}.${universeDomain}/. */ private String host; public String getProjectId() { diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java index 50d0821ec6..e7b9fd0ebe 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java @@ -17,6 +17,7 @@ package com.google.cloud.spring.autoconfigure.storage; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -29,6 +30,8 @@ import com.google.cloud.storage.Storage; import java.io.IOException; import org.junit.jupiter.api.Test; +import org.springframework.beans.BeanInstantiationException; +import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -128,6 +131,21 @@ void testNoUniverseDomainOrHostSet_useDefaults() { }); } + @Test + void testInvalidHost_throwsException() { + this.contextRunner + .withPropertyValues("spring.cloud.gcp.storage.host=storage.example.com") + .run( + context -> { + Exception exception = + assertThrows(Exception.class, () -> context.getBean("storage", Storage.class)); + assertThat(exception).hasRootCauseInstanceOf(IllegalArgumentException.class); + assertThat(exception) + .hasRootCauseMessage( + "Invalid host format: storage.example.com. Please verify that the specified host follows the 'https://${service}.${universeDomain}' format"); + }); + } + @Configuration static class TestConfiguration { From fa194d754e86925d6e48432ad239092cd22f8619 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 8 Oct 2024 21:55:25 +0000 Subject: [PATCH 06/19] formatting --- .../autoconfigure/storage/GcpStorageAutoConfiguration.java | 1 - .../autoconfigure/storage/GcpStorageAutoConfigurationTests.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index 463312cf5c..e0a02c8281 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -26,7 +26,6 @@ import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; import java.io.IOException; - import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java index e7b9fd0ebe..c0ab5b92c0 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java @@ -30,8 +30,6 @@ import com.google.cloud.storage.Storage; import java.io.IOException; import org.junit.jupiter.api.Test; -import org.springframework.beans.BeanInstantiationException; -import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; From ff8441831765ce4c0854e1d2dea7f5c6866ea053 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 8 Oct 2024 22:00:12 +0000 Subject: [PATCH 07/19] undo .idea edit --- .../autoconfigure/kms/.idea/workspace.xml | 44 -------- spring-cloud-gcp-kms/.idea/.gitignore | 3 + spring-cloud-gcp-kms/.idea/compiler.xml | 104 ++++++++++++++++++ spring-cloud-gcp-kms/.idea/encodings.xml | 7 ++ .../.idea/google-java-format.xml | 6 + .../.idea/jarRepositories.xml | 20 ++++ spring-cloud-gcp-kms/.idea/misc.xml | 12 ++ spring-cloud-gcp-kms/.idea/vcs.xml | 40 +++++++ 8 files changed, 192 insertions(+), 44 deletions(-) delete mode 100644 spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml create mode 100644 spring-cloud-gcp-kms/.idea/.gitignore create mode 100644 spring-cloud-gcp-kms/.idea/compiler.xml create mode 100644 spring-cloud-gcp-kms/.idea/encodings.xml create mode 100644 spring-cloud-gcp-kms/.idea/google-java-format.xml create mode 100644 spring-cloud-gcp-kms/.idea/jarRepositories.xml create mode 100644 spring-cloud-gcp-kms/.idea/misc.xml create mode 100644 spring-cloud-gcp-kms/.idea/vcs.xml diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml deleted file mode 100644 index c08bd36559..0000000000 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/.idea/workspace.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - 1723142811474 - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/.gitignore b/spring-cloud-gcp-kms/.idea/.gitignore new file mode 100644 index 0000000000..26d33521af --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/spring-cloud-gcp-kms/.idea/compiler.xml b/spring-cloud-gcp-kms/.idea/compiler.xml new file mode 100644 index 0000000000..ffa0c175a9 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/compiler.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/encodings.xml b/spring-cloud-gcp-kms/.idea/encodings.xml new file mode 100644 index 0000000000..aa00ffab78 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/google-java-format.xml b/spring-cloud-gcp-kms/.idea/google-java-format.xml new file mode 100644 index 0000000000..2aa056da34 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/jarRepositories.xml b/spring-cloud-gcp-kms/.idea/jarRepositories.xml new file mode 100644 index 0000000000..712ab9d985 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/misc.xml b/spring-cloud-gcp-kms/.idea/misc.xml new file mode 100644 index 0000000000..eb288dda26 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/vcs.xml b/spring-cloud-gcp-kms/.idea/vcs.xml new file mode 100644 index 0000000000..e206420597 --- /dev/null +++ b/spring-cloud-gcp-kms/.idea/vcs.xml @@ -0,0 +1,40 @@ + + + + + + + + + \ No newline at end of file From 45d09846479f2e8c9b015cfc56c20348c149be13 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 8 Oct 2024 22:02:39 +0000 Subject: [PATCH 08/19] cleanup --- spring-cloud-gcp-kms/.idea/.gitignore | 3 - spring-cloud-gcp-kms/.idea/compiler.xml | 104 ------------------ spring-cloud-gcp-kms/.idea/encodings.xml | 7 -- .../.idea/google-java-format.xml | 6 - .../.idea/jarRepositories.xml | 20 ---- spring-cloud-gcp-kms/.idea/misc.xml | 12 -- spring-cloud-gcp-kms/.idea/vcs.xml | 40 ------- 7 files changed, 192 deletions(-) delete mode 100644 spring-cloud-gcp-kms/.idea/.gitignore delete mode 100644 spring-cloud-gcp-kms/.idea/compiler.xml delete mode 100644 spring-cloud-gcp-kms/.idea/encodings.xml delete mode 100644 spring-cloud-gcp-kms/.idea/google-java-format.xml delete mode 100644 spring-cloud-gcp-kms/.idea/jarRepositories.xml delete mode 100644 spring-cloud-gcp-kms/.idea/misc.xml delete mode 100644 spring-cloud-gcp-kms/.idea/vcs.xml diff --git a/spring-cloud-gcp-kms/.idea/.gitignore b/spring-cloud-gcp-kms/.idea/.gitignore deleted file mode 100644 index 26d33521af..0000000000 --- a/spring-cloud-gcp-kms/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/spring-cloud-gcp-kms/.idea/compiler.xml b/spring-cloud-gcp-kms/.idea/compiler.xml deleted file mode 100644 index ffa0c175a9..0000000000 --- a/spring-cloud-gcp-kms/.idea/compiler.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/encodings.xml b/spring-cloud-gcp-kms/.idea/encodings.xml deleted file mode 100644 index aa00ffab78..0000000000 --- a/spring-cloud-gcp-kms/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/google-java-format.xml b/spring-cloud-gcp-kms/.idea/google-java-format.xml deleted file mode 100644 index 2aa056da34..0000000000 --- a/spring-cloud-gcp-kms/.idea/google-java-format.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/jarRepositories.xml b/spring-cloud-gcp-kms/.idea/jarRepositories.xml deleted file mode 100644 index 712ab9d985..0000000000 --- a/spring-cloud-gcp-kms/.idea/jarRepositories.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/misc.xml b/spring-cloud-gcp-kms/.idea/misc.xml deleted file mode 100644 index eb288dda26..0000000000 --- a/spring-cloud-gcp-kms/.idea/misc.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/spring-cloud-gcp-kms/.idea/vcs.xml b/spring-cloud-gcp-kms/.idea/vcs.xml deleted file mode 100644 index e206420597..0000000000 --- a/spring-cloud-gcp-kms/.idea/vcs.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - \ No newline at end of file From 37bf0d81ca2ca2dbd066adf40d7597de015736fa Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 9 Oct 2024 02:25:21 +0000 Subject: [PATCH 09/19] make rethrow MalformedURLException --- .../storage/GcpStorageAutoConfiguration.java | 9 +++++++-- .../storage/GcpStorageAutoConfigurationTests.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index e0a02c8281..a998b20294 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -26,6 +26,8 @@ import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -95,12 +97,15 @@ public Storage storage() throws IOException { } private String verifyAndFetchHost(String host) { - if (!host.startsWith("https://")) { + URL url; + try { + url = new URL(host); + } catch (MalformedURLException e) { throw new IllegalArgumentException( "Invalid host format: " + host + ". Please verify that the specified host follows the 'https://${service}.${universeDomain}' format"); } - return host; + return url.getProtocol() + "://" + url.getHost() + "/"; } } diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java index c0ab5b92c0..3904f61373 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfigurationTests.java @@ -110,7 +110,7 @@ void testUniverseDomainAndHostSet() { this.contextRunner .withPropertyValues( "spring.cloud.gcp.storage.universe-domain=example.com", - "spring.cloud.gcp.storage.host=https://storage.example.com/") + "spring.cloud.gcp.storage.host=https://storage.example.com") .run( context -> { Storage storage = context.getBean("storage", Storage.class); From 993824815f3ff722cf177b07b0efad595a895c9d Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:20:38 -0400 Subject: [PATCH 10/19] update javadoc Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../spring/autoconfigure/bigquery/GcpBigQueryProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java index ed317a7eae..ca7597a590 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java @@ -46,7 +46,7 @@ public class GcpBigQueryProperties implements CredentialsSupplier { private int threadPoolSize; /** - * Universe domain of the Bigquery and BigQueryWriteClient which is part of the endpoint that is + * Universe domain of the BigQuery and BigQueryWriteClient which is part of the endpoint that is * formatted as `{service}.{universeDomain}:${port}`. */ private String universeDomain; From 5635a012d9f2104ac771fcef06c353b32edff9ae Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:20:59 -0400 Subject: [PATCH 11/19] update documentation syntax Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- docs/src/main/asciidoc/storage.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/storage.adoc b/docs/src/main/asciidoc/storage.adoc index 217e73b2f4..0f9e4c3511 100644 --- a/docs/src/main/asciidoc/storage.adoc +++ b/docs/src/main/asciidoc/storage.adoc @@ -119,7 +119,7 @@ The Spring Boot Starter for Google Cloud Storage provides the following configur Base64-encoded contents of OAuth2 account private key for authenticating with the Google Cloud Storage API, if different from the ones in the <> | No | | `spring.cloud.gcp.storage.credentials.scopes` | https://developers.google.com/identity/protocols/googlescopes[OAuth2 scope] for Spring Framework on Google Cloud Storage credentials | No | https://www.googleapis.com/auth/devstorage.read_write -| `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain} | No | Relies on client library’s default universe domain which is googleapis.com +| `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as `https://${service}.${universeDomain}` | No | Relies on client library’s default universe domain which is `googleapis.com` | `spring.cloud.gcp.storage.host` | Host of the Storage service which expects https://${service}.${universeDomain} as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` |=== From 4af01b707b61ea436339d009fd6aef4451bb9728 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:21:11 -0400 Subject: [PATCH 12/19] update documentation syntax Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- docs/src/main/asciidoc/storage.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/storage.adoc b/docs/src/main/asciidoc/storage.adoc index 0f9e4c3511..361834a3d3 100644 --- a/docs/src/main/asciidoc/storage.adoc +++ b/docs/src/main/asciidoc/storage.adoc @@ -120,7 +120,7 @@ Base64-encoded contents of OAuth2 account private key for authenticating with th | `spring.cloud.gcp.storage.credentials.scopes` | https://developers.google.com/identity/protocols/googlescopes[OAuth2 scope] for Spring Framework on Google Cloud Storage credentials | No | https://www.googleapis.com/auth/devstorage.read_write | `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as `https://${service}.${universeDomain}` | No | Relies on client library’s default universe domain which is `googleapis.com` -| `spring.cloud.gcp.storage.host` | Host of the Storage service which expects https://${service}.${universeDomain} as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` +| `spring.cloud.gcp.storage.host` | Host of the Storage service which expects `https://${service}.${universeDomain}` as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` |=== From 29cd19ac53d83f0f1fcee74c0aafdbe244252c36 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:21:34 -0400 Subject: [PATCH 13/19] update from Bigquery to BigQuery Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../spring/autoconfigure/bigquery/GcpBigQueryProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java index ca7597a590..c6428440f0 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java @@ -52,7 +52,7 @@ public class GcpBigQueryProperties implements CredentialsSupplier { private String universeDomain; /** - * Endpoint of the Bigquery and BigQueryWriteClient. Formatted as + * Endpoint of the BigQuery and BigQueryWriteClient. Formatted as * `{service}.{universeDomain}:${port}`. Note that endpoint will be reformatted in {@link * GcpBigQueryAutoConfiguration} to follow the `https://${service}.${universeDomain}/` pattern * before being applied to the Bigquery client. From 7e3de7ed2bf785ec6b002b12771aebe49feb8a24 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:21:47 -0400 Subject: [PATCH 14/19] Update from Bigquery to BigQuery Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../spring/autoconfigure/bigquery/GcpBigQueryProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java index c6428440f0..4d515006e2 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/bigquery/GcpBigQueryProperties.java @@ -55,7 +55,7 @@ public class GcpBigQueryProperties implements CredentialsSupplier { * Endpoint of the BigQuery and BigQueryWriteClient. Formatted as * `{service}.{universeDomain}:${port}`. Note that endpoint will be reformatted in {@link * GcpBigQueryAutoConfiguration} to follow the `https://${service}.${universeDomain}/` pattern - * before being applied to the Bigquery client. + * before being applied to the BigQuery client. */ private String endpoint; From de28054d1e8bfe0af8f53e0b52539f569b462920 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:22:04 -0400 Subject: [PATCH 15/19] fix typo in javadoc Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java index be4217131e..796d44240f 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/kms/GcpKmsProperties.java @@ -38,7 +38,7 @@ public class GcpKmsProperties implements CredentialsSupplier { */ private String universeDomain; - /** Enspoint of the KMS client which is formatted as`${service}.${universeDomain}:${port}` */ + /** Endpoint of the KMS client which is formatted as`${service}.${universeDomain}:${port}` */ private String endpoint; @Override From 02ca643247eb9b56c4deb066f6063c446f528ee6 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:22:20 -0400 Subject: [PATCH 16/19] update javadoc Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../spring/autoconfigure/storage/GcpStorageProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index 59ab708f3b..7680b2b796 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -40,7 +40,7 @@ public Credentials getCredentials() { /** * Universe domain of the client which is part of the host that is formatted as - * `https://${service}.${universeDomain}. + * `https://${service}.${universeDomain}`. */ private String universeDomain; From 92e143e408fa572c541636f1bc7150c9cafc5c66 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:22:30 -0400 Subject: [PATCH 17/19] update javadoc Co-authored-by: Burke Davison <40617934+burkedavison@users.noreply.github.com> --- .../spring/autoconfigure/storage/GcpStorageProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java index 7680b2b796..ecc2abf101 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageProperties.java @@ -44,7 +44,7 @@ public Credentials getCredentials() { */ private String universeDomain; - /** Host of the Storage client that is formatted as `https://${service}.${universeDomain}/. */ + /** Host of the Storage client that is formatted as `https://${service}.${universeDomain}/`. */ private String host; public String getProjectId() { From a7beae4e1dd07ca2f7a5f7e6585090af9276d3fd Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 9 Oct 2024 20:43:04 +0000 Subject: [PATCH 18/19] fix typo in documentation --- docs/src/main/asciidoc/storage.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/storage.adoc b/docs/src/main/asciidoc/storage.adoc index 217e73b2f4..ed5a1c1c17 100644 --- a/docs/src/main/asciidoc/storage.adoc +++ b/docs/src/main/asciidoc/storage.adoc @@ -119,8 +119,8 @@ The Spring Boot Starter for Google Cloud Storage provides the following configur Base64-encoded contents of OAuth2 account private key for authenticating with the Google Cloud Storage API, if different from the ones in the <> | No | | `spring.cloud.gcp.storage.credentials.scopes` | https://developers.google.com/identity/protocols/googlescopes[OAuth2 scope] for Spring Framework on Google Cloud Storage credentials | No | https://www.googleapis.com/auth/devstorage.read_write -| `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain} | No | Relies on client library’s default universe domain which is googleapis.com -| `spring.cloud.gcp.storage.host` | Host of the Storage service which expects https://${service}.${universeDomain} as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` +| `spring.cloud.gcp.storage.universe-domain` | Universe domain of the Storage service. The universe domain is a part of the host that is formatted as https://${service}.${universeDomain}/ | No | Relies on client library’s default universe domain which is googleapis.com +| `spring.cloud.gcp.storage.host` | Host of the Storage service which expects https://${service}.${universeDomain}/ as the format. | No | Relies on client library’s default host which is `https://storage.googleapis.com` |=== From 1d76e4ffe6b73d517d6de8f7aa4f962461001107 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 9 Oct 2024 21:11:39 +0000 Subject: [PATCH 19/19] fix checkstyle --- .../autoconfigure/storage/GcpStorageAutoConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java index e1315c5fb5..2ad85f3dac 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/storage/GcpStorageAutoConfiguration.java @@ -100,7 +100,7 @@ public Storage storage() throws IOException { * Verifies and returns host in the `https://${service}.${universeDomain}/` format, following * convention in com.google.cloud.ServiceOptions#getResolvedApiaryHost(). * - * @param host + * @param host host provided through `spring.cloud.gcp.storage.host` property * @return host formatted as `https://${service}.${universeDomain}/` */ private String verifyAndFetchHost(String host) {