Skip to content

Commit 4b84438

Browse files
authored
New region tags (GoogleCloudPlatform#4181)
1 parent 4aec98e commit 4b84438

File tree

21 files changed

+65
-2
lines changed

21 files changed

+65
-2
lines changed

run/authentication/src/main/java/com/example/cloudrun/Authentication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.example.cloudrun;
1818

19+
// [START cloudrun_service_to_service_auth]
1920
// [START run_service_to_service_auth]
2021
// [START functions_bearer_token]
2122
import com.google.api.client.http.GenericUrl;
@@ -54,3 +55,4 @@ public static HttpResponse makeGetRequest(String serviceUrl) throws IOException
5455
}
5556
// [END functions_bearer_token]
5657
// [END run_service_to_service_auth]
58+
// [END cloudrun_service_to_service_auth]

run/hello-broken/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ limitations under the License.
3131
<maven.compiler.source>11</maven.compiler.source>
3232
</properties>
3333
<dependencies>
34+
<!-- [START cloudrun_broken_service_dep] -->
3435
<!-- [START run_broken_service_dep] -->
3536
<dependency>
3637
<groupId>com.sparkjava</groupId>
@@ -53,6 +54,7 @@ limitations under the License.
5354
<version>1.7.30</version>
5455
</dependency>
5556
<!-- [END run_broken_service_dep] -->
57+
<!-- [END cloudrun_broken_service_dep] -->
5658
<dependency>
5759
<groupId>junit</groupId>
5860
<artifactId>junit</artifactId>
@@ -66,9 +68,11 @@ limitations under the License.
6668
<scope>test</scope>
6769
</dependency>
6870
</dependencies>
71+
<!-- [START cloudrun_broken_service_build] -->
6972
<!-- [START run_broken_service_build] -->
7073
<build>
7174
<plugins>
75+
<!-- [START cloudrun_broken_service_jib] -->
7276
<!-- [START run_broken_service_jib] -->
7377
<plugin>
7478
<groupId>com.google.cloud.tools</groupId>
@@ -81,7 +85,9 @@ limitations under the License.
8185
</configuration>
8286
</plugin>
8387
<!-- [END run_broken_service_jib] -->
88+
<!-- [END cloudrun_broken_service_jib] -->
8489
</plugins>
8590
</build>
8691
<!-- [END run_broken_service_build] -->
92+
<!-- [END cloudrun_broken_service_build] -->
8793
</project>

run/hello-broken/src/main/java/com/example/cloudrun/App.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.example.cloudrun;
1818

19+
// [START cloudrun_broken_service]
1920
// [START run_broken_service]
2021
import static spark.Spark.get;
2122
import static spark.Spark.port;
@@ -35,6 +36,7 @@ public static void main(String[] args) {
3536
"/",
3637
(req, res) -> {
3738
logger.info("Hello: received request.");
39+
// [START cloudrun_broken_service_problem]
3840
// [START run_broken_service_problem]
3941
String name = System.getenv("NAME");
4042
if (name == null) {
@@ -46,25 +48,30 @@ public static void main(String[] args) {
4648
return "Internal Server Error";
4749
}
4850
// [END run_broken_service_problem]
51+
// [END cloudrun_broken_service_problem]
4952
res.status(200);
5053
return String.format("Hello %s!", name);
5154
});
5255
// [END run_broken_service]
56+
// [END cloudrun_broken_service]
5357
get(
5458
"/improved",
5559
(req, res) -> {
5660
logger.info("Hello: received request.");
61+
// [START cloudrun_broken_service_upgrade]
5762
// [START run_broken_service_upgrade]
5863
String name = System.getenv().getOrDefault("NAME", "World");
5964
if (System.getenv("NAME") == null) {
6065
logger.warn(String.format("NAME not set, default to %s", name));
6166
}
6267
// [END run_broken_service_upgrade]
68+
// [END cloudrun_broken_service_upgrade]
6369
res.status(200);
6470
return String.format("Hello %s!", name);
6571
});
66-
72+
// [START cloudrun_broken_service]
6773
// [START run_broken_service]
6874
}
6975
}
7076
// [END run_broken_service]
77+
// [END cloudrun_broken_service]

run/helloworld/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_helloworld_dockerfile]
1516
# [START run_helloworld_dockerfile]
1617

1718
# Use the official maven/Java 8 image to create a build artifact.
@@ -39,3 +40,4 @@ COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar
3940
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/helloworld.jar"]
4041

4142
# [END run_helloworld_dockerfile]
43+
# [END cloudrun_helloworld_dockerfile]

run/helloworld/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ limitations under the License.
6868
</execution>
6969
</executions>
7070
</plugin>
71+
<!-- [START cloudrun_helloworld_jib] -->
7172
<!-- [START run_helloworld_jib] -->
7273
<plugin>
7374
<groupId>com.google.cloud.tools</groupId>
@@ -80,6 +81,7 @@ limitations under the License.
8081
</configuration>
8182
</plugin>
8283
<!-- [END run_helloworld_jib] -->
84+
<!-- [END cloudrun_helloworld_jib] -->
8385
</plugins>
8486
</build>
8587
</project>

run/helloworld/src/main/java/com/example/helloworld/HelloworldApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
// [START cloudrun_helloworld_service]
1718
// [START run_helloworld_service]
1819

1920
package com.example.helloworld;
@@ -43,3 +44,4 @@ public static void main(String[] args) {
4344
}
4445
}
4546
// [END run_helloworld_service]
47+
// [END cloudrun_helloworld_service]

run/helloworld/src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
# [START cloudrun_helloworld_properties]
1415
# [START run_helloworld_properties]
1516
server.port=${PORT:8080}
1617
# [END run_helloworld_properties]
18+
# [END cloudrun_helloworld_properties]

run/image-processing/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_imageproc_dockerfile]
1516
# [START run_imageproc_dockerfile]
1617
# Use AdoptOpenJDK for base image.
1718
# It's important to use OpenJDK 8u191 or above that has container support enabled.
@@ -23,3 +24,4 @@ FROM adoptopenjdk/openjdk11:alpine-slim
2324
# https://cloud.google.com/run/docs/tutorials/system-packages#dockerfile
2425
RUN apk add --no-cache imagemagick
2526
# [END run_imageproc_dockerfile]
27+
# [END cloudrun_imageproc_dockerfile]

run/image-processing/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ limitations under the License.
7272
<artifactId>spring-boot-starter-test</artifactId>
7373
<scope>test</scope>
7474
</dependency>
75+
<!-- [START cloudrun_imageproc_dep] -->
7576
<!-- [START run_imageproc_dep] -->
7677
<dependency>
7778
<groupId>com.google.code.gson</groupId>
@@ -98,13 +99,15 @@ limitations under the License.
9899
<version>2.8.0</version>
99100
</dependency>
100101
<!-- [END run_imageproc_dep] -->
102+
<!-- [END cloudrun_imageproc_dep] -->
101103
</dependencies>
102104
<build>
103105
<plugins>
104106
<plugin>
105107
<groupId>org.springframework.boot</groupId>
106108
<artifactId>spring-boot-maven-plugin</artifactId>
107109
</plugin>
110+
<!-- [START cloudrun_imageproc_jib] -->
108111
<!-- [START run_imageproc_jib] -->
109112
<plugin>
110113
<groupId>com.google.cloud.tools</groupId>
@@ -120,6 +123,7 @@ limitations under the License.
120123
</configuration>
121124
</plugin>
122125
<!-- [END run_imageproc_jib] -->
126+
<!-- [END cloudrun_imageproc_jib] -->
123127
</plugins>
124128
</build>
125129
</project>

run/image-processing/src/main/java/com/example/cloudrun/ImageMagick.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
1717
package com.example.cloudrun;
1818

19+
// [START cloudrun_imageproc_handler_setup]
1920
// [START run_imageproc_handler_setup]
2021
import com.google.cloud.storage.Blob;
2122
import com.google.cloud.storage.BlobId;
@@ -44,7 +45,9 @@ public class ImageMagick {
4445
private static final String BLURRED_BUCKET_NAME = System.getenv("BLURRED_BUCKET_NAME");
4546
private static Storage storage = StorageOptions.getDefaultInstance().getService();
4647
// [END run_imageproc_handler_setup]
48+
// [END cloudrun_imageproc_handler_setup]
4749

50+
// [START cloudrun_imageproc_handler_analyze]
4851
// [START run_imageproc_handler_analyze]
4952
// Blurs uploaded images that are flagged as Adult or Violence.
5053
public static void blurOffensiveImages(JsonObject data) {
@@ -87,7 +90,9 @@ public static void blurOffensiveImages(JsonObject data) {
8790
}
8891
}
8992
// [END run_imageproc_handler_analyze]
93+
// [END cloudrun_imageproc_handler_analyze]
9094

95+
// [START cloudrun_imageproc_handler_blur]
9196
// [START run_imageproc_handler_blur]
9297
// Blurs the file described by blobInfo using ImageMagick,
9398
// and uploads it to the blurred bucket.
@@ -134,3 +139,4 @@ public static void blur(BlobInfo blobInfo) throws IOException {
134139
}
135140
}
136141
// [END run_imageproc_handler_blur]
142+
// [END cloudrun_imageproc_handler_blur]

0 commit comments

Comments
 (0)