GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Eventarc Quickstart Brushup (#3846) · jrgito/java-docs-samples@990334c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • eventarc
    • README.md
    • audit-storage
      • Dockerfile
      • README.md
      • anthos.md
      • pom.xml
      • src
        • main
          • java/com/example/cloudrun
            • Application.java
            • EventController.java
            • eventpojos
              • PubSubBody.java
          • resources
            • application.properties
        • test/java/com/example/cloudrun
          • EventControllerTests.java
    • pubsub
      • Dockerfile
      • README.md
      • anthos.md
      • pom.xml
      • src
        • main
          • java/com/example/cloudrun
            • Application.java
            • EventController.java
            • eventpojos
              • PubSubBody.java
          • resources
            • application.properties
        • test/java/com/example/cloudrun
          • EventControllerTests.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎eventarc/README.md‎

Copy file name to clipboard
+105Lines changed: 105 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Cloud Eventarc Java Samples
2+
3+
[![Open in Cloud Shell][shell_img]][shell_link]
4+
5+
[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
6+
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=blog/README.md
7+
8+
This directory contains samples for Cloud Eventarc.
9+
10+
## Samples
11+
12+
| Sample | Description | Deploy |
13+
| ------------------------------- | ------------------------ | ------------- |
14+
|[Eventarc - Pub/Sub](events-pubsub/) | Events for Cloud Run with Pub/Sub | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30">][run_button_events_pubsub] |
15+
|[Anthos Events - Pub/Sub](events-pubsub/anthos.md) | Events for Cloud Run on Anthos with Pub/Sub | - |
16+
|[Eventarc - Storage](events-audit-storage/) | Events for Cloud Run with GCS | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30">][run_button_events_gcs] |
17+
|[Anthos Events - Storage](events-audit-storage/anthos.md) | Events for Cloud Run on Anthos with GCS | - |
18+
19+
## Setup
20+
21+
1. [Set up for Cloud Run development](https://cloud.google.com/run/docs/setup)
22+
23+
1. Clone this repository:
24+
25+
```
26+
git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
27+
```
28+
29+
1. In the samples's `pom.xml`, update the image field for the `jib-maven-plugin`
30+
with your Google Cloud Project Id:
31+
32+
```XML
33+
<plugin>
34+
<groupId>com.google.cloud.tools</groupId>
35+
<artifactId>jib-maven-plugin</artifactId>
36+
<version>2.0.0</version>
37+
<configuration>
38+
<to>
39+
<image>gcr.io/PROJECT_ID/SAMPLE_NAME</image>
40+
</to>
41+
</configuration>
42+
</plugin>
43+
```
44+
45+
## How to run a sample locally
46+
47+
1. [Build the sample container using Jib](https://github.com/GoogleContainerTools/jib):
48+
49+
```Bash
50+
mvn compile jib:dockerBuild
51+
```
52+
53+
1. [Run containers locally](https://cloud.google.com/run/docs/testing/local) by
54+
replacing `PROJECT_ID` and `SAMPLE_NAME` with your values.
55+
56+
With the built container:
57+
58+
```Bash
59+
PORT=8080 && docker run --rm -p 9090:${PORT} -e PORT=${PORT} gcr.io/PROJECT_ID/SAMPLE_NAME
60+
```
61+
62+
Injecting your service account key for access to GCP services:
63+
64+
```Bash
65+
PORT=8080 && docker run \
66+
-p 9090:${PORT} \
67+
-e PORT=${PORT} \
68+
-e K_SERVICE=dev \
69+
-e K_CONFIGURATION=dev \
70+
-e K_REVISION=dev-00001 \
71+
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/[FILE_NAME].json \
72+
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/[FILE_NAME].json:ro \
73+
gcr.io/PROJECT_ID/SAMPLE_NAME
74+
```
75+
76+
* Use the --volume (-v) flag to inject the credential file into the container
77+
(assumes you have already set your `GOOGLE_APPLICATION_CREDENTIALS`
78+
environment variable on your machine)
79+
80+
* Use the --environment (-e) flag to set the `GOOGLE_APPLICATION_CREDENTIALS`
81+
variable inside the container
82+
83+
1. Open http://localhost:9090 in your browser.
84+
85+
Learn more about [testing your container image locally.][testing]
86+
87+
## Deploying
88+
89+
1. [Build the sample container using Jib](https://github.com/GoogleContainerTools/jib):
90+
91+
```
92+
mvn compile jib:build
93+
```
94+
95+
**Note**: Using the image tag `gcr.io/PROJECT_ID/SAMPLE_NAME` automatically
96+
pushes the image to [Google Container Registry](https://cloud.google.com/container-registry/).
97+
98+
1. Deploy to Cloud Run by replacing `PROJECT_ID` and `SAMPLE_NAME` with your values:
99+
100+
```bash
101+
gcloud run deploy --image gcr.io/PROJECT_ID/SAMPLE_NAME
102+
```
103+
104+
[run_button_events_gcs]: https://deploy.cloud.run/?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&dir=eventarc/audit-storage
105+
[run_button_events_pubsub]: https://deploy.cloud.run/?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&dir=eventarc/pubsub
Collapse file

‎run/events-storage/Dockerfile‎ ‎eventarc/audit-storage/Dockerfile‎run/events-storage/Dockerfile renamed to eventarc/audit-storage/Dockerfile

Copy file name to clipboardExpand all lines: eventarc/audit-storage/Dockerfile
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START run_events_gcs_dockerfile]
15+
# [START eventarc_gcs_dockerfile]
1616

1717
# Use the official maven/Java 8 image to create a build artifact.
1818
# https://hub.docker.com/_/maven
@@ -33,9 +33,9 @@ RUN mvn package -DskipTests
3333
FROM adoptopenjdk/openjdk11:alpine-slim
3434

3535
# Copy the jar to the production image from the builder stage.
36-
COPY --from=builder /app/target/events-storage-*.jar /events-storage.jar
36+
COPY --from=builder /app/target/audit-storage-*.jar /audit-storage.jar
3737

3838
# Run the web service on container startup.
39-
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/events-storage.jar"]
39+
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/audit-storage.jar"]
4040

41-
# [END run_events_gcs_dockerfile]
41+
# [END eventarc_gcs_dockerfile]
Collapse file

‎run/events-storage/README.md‎ ‎eventarc/audit-storage/README.md‎run/events-storage/README.md renamed to eventarc/audit-storage/README.md

Copy file name to clipboardExpand all lines: eventarc/audit-storage/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Events for Cloud Run - Cloud Storage tutorial
1+
# Cloud Eventarc - Cloud Storage via Audit Logs tutorial
22

33
This sample shows how to create a service that processes GCS events.
44

Collapse file

‎run/events-storage/anthos.md‎ ‎eventarc/audit-storage/anthos.md‎run/events-storage/anthos.md renamed to eventarc/audit-storage/anthos.md

Copy file name to clipboard
  • Display the source diff
  • Display the rich diff
File renamed without changes.
Collapse file

‎run/events-storage/pom.xml‎ ‎eventarc/audit-storage/pom.xml‎run/events-storage/pom.xml renamed to eventarc/audit-storage/pom.xml

Copy file name to clipboardExpand all lines: eventarc/audit-storage/pom.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1515
<modelVersion>4.0.0</modelVersion>
1616
<groupId>com.example.cloudrun</groupId>
17-
<artifactId>events-storage</artifactId>
17+
<artifactId>audit-storage</artifactId>
1818
<version>0.0.1-SNAPSHOT</version>
1919
<!-- The parent pom defines common style checks and testing strategies for our samples.
2020
Removing or replacing it should not affect the execution of the samples in anyway. -->
@@ -85,7 +85,7 @@ limitations under the License.
8585
</execution>
8686
</executions>
8787
</plugin>
88-
<!-- [START run_events_gcs_jib] -->
88+
<!-- [START eventarc_gcs_jib] -->
8989
<plugin>
9090
<groupId>com.google.cloud.tools</groupId>
9191
<artifactId>jib-maven-plugin</artifactId>
@@ -96,7 +96,7 @@ limitations under the License.
9696
</to>
9797
</configuration>
9898
</plugin>
99-
<!-- [END run_events_gcs_jib] -->
99+
<!-- [END eventarc_gcs_jib] -->
100100
</plugins>
101101
</build>
102102
</project>
Collapse file

‎…va/com/example/cloudrun/Application.java‎ ‎…va/com/example/cloudrun/Application.java‎run/events-storage/src/main/java/com/example/cloudrun/Application.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/Application.java run/events-storage/src/main/java/com/example/cloudrun/Application.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/Application.java

Copy file name to clipboardExpand all lines: eventarc/audit-storage/src/main/java/com/example/cloudrun/Application.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.example.cloudrun;
1818

19-
// [START run_events_gcs_server]
19+
// [START eventarc_gcs_server]
2020
import org.springframework.boot.SpringApplication;
2121
import org.springframework.boot.autoconfigure.SpringBootApplication;
2222

@@ -26,4 +26,4 @@ public static void main(String[] args) {
2626
SpringApplication.run(Application.class, args);
2727
}
2828
}
29-
// [END run_events_gcs_server]
29+
// [END eventarc_gcs_server]
Collapse file

‎…om/example/cloudrun/EventController.java‎ ‎…om/example/cloudrun/EventController.java‎run/events-storage/src/main/java/com/example/cloudrun/EventController.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/EventController.java run/events-storage/src/main/java/com/example/cloudrun/EventController.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/EventController.java

Copy file name to clipboardExpand all lines: eventarc/audit-storage/src/main/java/com/example/cloudrun/EventController.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.example.cloudrun;
1818

19-
// [START run_events_gcs_handler]
19+
// [START eventarc_gcs_handler]
2020
import com.example.cloudrun.eventpojos.PubSubBody;
2121
import java.util.Arrays;
2222
import java.util.List;
@@ -58,4 +58,4 @@ public ResponseEntity<String> receiveMessage(
5858
return new ResponseEntity<String>(msg, HttpStatus.OK);
5959
}
6060
}
61-
// [END run_events_gcs_handler]
61+
// [END eventarc_gcs_handler]
Collapse file

‎…mple/cloudrun/eventpojos/PubSubBody.java‎ ‎…mple/cloudrun/eventpojos/PubSubBody.java‎run/events-pubsub/src/main/java/com/example/cloudrun/eventpojos/PubSubBody.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/eventpojos/PubSubBody.java run/events-pubsub/src/main/java/com/example/cloudrun/eventpojos/PubSubBody.java renamed to eventarc/audit-storage/src/main/java/com/example/cloudrun/eventpojos/PubSubBody.java

Copy file name to clipboard
File renamed without changes.
Collapse file

‎…rc/main/resources/application.properties‎ ‎…rc/main/resources/application.properties‎run/events-pubsub/src/main/resources/application.properties renamed to eventarc/audit-storage/src/main/resources/application.properties run/events-pubsub/src/main/resources/application.properties renamed to eventarc/audit-storage/src/main/resources/application.properties

Copy file name to clipboard
File renamed without changes.
Collapse file

‎…ample/cloudrun/EventControllerTests.java‎ ‎…ample/cloudrun/EventControllerTests.java‎run/events-storage/src/test/java/com/example/cloudrun/EventControllerTests.java renamed to eventarc/audit-storage/src/test/java/com/example/cloudrun/EventControllerTests.java run/events-storage/src/test/java/com/example/cloudrun/EventControllerTests.java renamed to eventarc/audit-storage/src/test/java/com/example/cloudrun/EventControllerTests.java

Copy file name to clipboard
File renamed without changes.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.