Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional at Launch #38

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ codeowners:
owner: "@paketo-buildpacks/java-buildpacks"

package:
repository: gcr.io/paketo-buildpacks/google-stackdriver
repository: gcr.io/paketo-buildpacks/google-cloud
register: true
registry_token: ${{ secrets.JAVA_GITHUB_TOKEN }}

Expand All @@ -17,20 +17,20 @@ docker_credentials:
password: ${{ secrets.JAVA_GCLOUD_SERVICE_ACCOUNT_KEY }}

dependencies:
- id: google-stackdriver-debugger-java
- id: google-cloud-debugger-java
uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main
with:
glob: compute-java_debian-wheezy_cdbg_java_agent_gce\.tar
owner: GoogleCloudPlatform
repository: cloud-debug-java
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
- id: google-stackdriver-debugger-nodejs
- id: google-cloud-debugger-nodejs
uses: docker://ghcr.io/paketo-buildpacks/actions/npm-dependency:main
with:
package: "@google-cloud/debug-agent"
- id: google-stackdriver-profiler-java
- id: google-cloud-profiler-java
uses: docker://ghcr.io/paketo-buildpacks/actions/google-stackdriver-profiler-dependency:main
- id: google-stackdriver-profiler-nodejs
- id: google-cloud-profiler-nodejs
uses: docker://ghcr.io/paketo-buildpacks/actions/npm-dependency:main
with:
package: "@google-cloud/profiler"
6 changes: 3 additions & 3 deletions .github/workflows/create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
--config "${HOME}"/package.toml
fi
env:
PACKAGE: gcr.io/paketo-buildpacks/google-stackdriver
PACKAGE: gcr.io/paketo-buildpacks/google-cloud
PUBLISH: "true"
VERSION: ${{ steps.version.outputs.version }}
- name: Update release with digest
Expand All @@ -164,7 +164,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.JAVA_GITHUB_TOKEN }}
- uses: docker://ghcr.io/buildpacks/actions/registry:main
with:
address: gcr.io/paketo-buildpacks/google-stackdriver@${{ steps.package.outputs.digest }}
id: paketo-buildpacks/google-stackdriver
address: gcr.io/paketo-buildpacks/google-cloud@${{ steps.package.outputs.digest }}
id: paketo-buildpacks/google-cloud
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
version: ${{ steps.version.outputs.version }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update google-stackdriver-debugger-java
name: Update google-cloud-debugger-java
"on":
schedule:
- cron: 0 5 * * 1-5
Expand Down Expand Up @@ -75,21 +75,21 @@ jobs:
echo "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${VERSION}"
env:
ID: google-stackdriver-debugger-java
ID: google-cloud-debugger-java
SHA256: ${{ steps.dependency.outputs.sha256 }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+'
- uses: peter-evans/create-pull-request@v3
with:
body: Bumps `google-stackdriver-debugger-java` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-stackdriver-debugger-java
body: Bumps `google-cloud-debugger-java` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-cloud-debugger-java
commit-message: |-
Bump google-stackdriver-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bump google-cloud-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}

Bumps google-stackdriver-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
Bumps google-cloud-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: semver:minor, type:dependency-upgrade
signoff: true
title: Bump google-stackdriver-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
title: Bump google-cloud-debugger-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update google-stackdriver-debugger-nodejs
name: Update google-cloud-debugger-nodejs
"on":
schedule:
- cron: 0 5 * * 1-5
Expand Down Expand Up @@ -72,21 +72,21 @@ jobs:
echo "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${VERSION}"
env:
ID: google-stackdriver-debugger-nodejs
ID: google-cloud-debugger-nodejs
SHA256: ${{ steps.dependency.outputs.sha256 }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+'
- uses: peter-evans/create-pull-request@v3
with:
body: Bumps `google-stackdriver-debugger-nodejs` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-stackdriver-debugger-nodejs
body: Bumps `google-cloud-debugger-nodejs` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-cloud-debugger-nodejs
commit-message: |-
Bump google-stackdriver-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bump google-cloud-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}

Bumps google-stackdriver-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
Bumps google-cloud-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: semver:minor, type:dependency-upgrade
signoff: true
title: Bump google-stackdriver-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
title: Bump google-cloud-debugger-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update google-stackdriver-profiler-java
name: Update google-cloud-profiler-java
"on":
schedule:
- cron: 0 5 * * 1-5
Expand Down Expand Up @@ -70,21 +70,21 @@ jobs:
echo "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${VERSION}"
env:
ID: google-stackdriver-profiler-java
ID: google-cloud-profiler-java
SHA256: ${{ steps.dependency.outputs.sha256 }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+'
- uses: peter-evans/create-pull-request@v3
with:
body: Bumps `google-stackdriver-profiler-java` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-stackdriver-profiler-java
body: Bumps `google-cloud-profiler-java` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-cloud-profiler-java
commit-message: |-
Bump google-stackdriver-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bump google-cloud-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}

Bumps google-stackdriver-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
Bumps google-cloud-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: semver:minor, type:dependency-upgrade
signoff: true
title: Bump google-stackdriver-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
title: Bump google-cloud-profiler-java from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update google-stackdriver-profiler-nodejs
name: Update google-cloud-profiler-nodejs
"on":
schedule:
- cron: 0 5 * * 1-5
Expand Down Expand Up @@ -72,21 +72,21 @@ jobs:
echo "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${VERSION}"
env:
ID: google-stackdriver-profiler-nodejs
ID: google-cloud-profiler-nodejs
SHA256: ${{ steps.dependency.outputs.sha256 }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+'
- uses: peter-evans/create-pull-request@v3
with:
body: Bumps `google-stackdriver-profiler-nodejs` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-stackdriver-profiler-nodejs
body: Bumps `google-cloud-profiler-nodejs` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/google-cloud-profiler-nodejs
commit-message: |-
Bump google-stackdriver-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bump google-cloud-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}

Bumps google-stackdriver-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
Bumps google-cloud-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: semver:minor, type:dependency-upgrade
signoff: true
title: Bump google-stackdriver-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
title: Bump google-cloud-profiler-nodejs from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
google-stackdriver
google-cloud

Copyright (c) 2020-Present CloudFoundry.org Foundation, Inc. All Rights Reserved.

Expand Down
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
# `gcr.io/paketo-buildpacks/google-stackdriver`
The Paketo Google Stackdriver Buildpack is a Cloud Native Buildpack that contributes Stackdriver agents and configures them to connect to the service.
# `paketo-buildpacks/google-cloud`
The Paketo Google Cloud Buildpack is a Cloud Native Buildpack that contributes Google Cloud agents and configures them to connect to their services.

## Behavior
This buildpack will participate if any of the following conditions are met

* A binding exists with `type` of `StackdriverDebugger`
* A binding exists with `type` of `StackdriverProfiler`
* If `$BP_GOOGLE_CLOUD_DEBUGGER_ENABLED` is set to `true` and the application is Java
* At build time, contributes an agent to a layer
* At launch time, if credentials are available, configures the application to use the agent
* If `$BP_GOOGLE_CLOUD_DEBUGGER_ENABLED` is set to `true` and the application is NodeJS
* At build time, contributes an agent to a layer
* At launch time, if credentials are available, configures `$NODE_MODULES` with the agent path. If the main module does not already require `@google-cloud/debug-agent`, prepends the main module with `require('@google-cloud/debug-agent').start({...});`.

The buildpack will do the following for Java applications:
* If `$BP_GOOGLE_CLOUD_PROFILER_ENABLED` is set to `true` and the application is Java
* At build time, contributes an agent to a layer
* At launch time, if credentials are available, configures the application to use the agent
* If `$BP_GOOGLE_CLOUD_PROFILER_ENABLED` is set to `true` and the application is NodeJS
* At build time, contributes an agent to a layer
* At launch time, if credentials are available, configures `$NODE_MODULES` with the agent path. If the main module does not already require `@google-cloud/profiler`, prepends the main module with `require('@google-cloud/profiler').start({...});`.

* If `StackdriverDebugger` binding exists contributes a Java debugger agent to a layer and configures `$JAVA_TOOL_OPTIONS` to use it
* If `StackdriverProfiler` binding exists contributes a Java profiler agent to a layer and configures `$JAVA_TOOL_OPTIONS` to use it
* Sets `$GOOGLE_APPLICATION_CREDENTIALS` to the path of the `ApplicationCredentials` secret
### Credential Availability
If the applications runs within Google Cloud and the [Google Metadata Service][m] is accessible, those credentials will be used. If the application runs within any other environment, credentials must be provided with a service binding as described below.

The buildpack will do the following for NodeJS applications:

* If `StackdriverDebugger` binding exists
* Contributes a NodeJS debugger agent to a layer and configures `$NODE_MODULES` to use it
* If main module does not already require `@google-cloud/debug-agent` module, prepends the main module with `require('@google-cloud/debug-agent').start();`
* If `StackdriverProfiler` binding exists
* Contributes a NodeJS profiler agent to a layer and configures `$NODE_MODULES` to use it
* If main module does not already require `@google-cloud/profiler` module, prepends the main module with `require('@google-cloud/profiler').start();`
* Sets `$GOOGLE_APPLICATION_CREDENTIALS` to the path of the `ApplicationCredentials` secret
[m]: https://cloud.google.com/compute/docs/storing-retrieving-metadata

## Configuration
| Environment Variable | Description
| -------------------- | -----------
| `$BPL_GOOGLE_STACKDRIVER_MODULE` | Configure the name of the application. Defaults to `default-module`.
| `$BPL_GOOGLE_STACKDRIVER_VERSION` | Configure the project id for the application. Defaults to `<EMPTY>`.
| `$BPL_GOOGLE_STACKDRIVER_VERSION` | Configure the version of the application. Defaults to `<EMPTY>`.
| `$BP_GOOGLE_CLOUD_DEBUGGER_ENABLED` | Whether to add Google Cloud Debugger during build
| `$BP_GOOGLE_CLOUD_PROFILER_ENABLED` | Whether to add Google Cloud Profiler during build
| `$BPL_GOOGLE_CLOUD_MODULE` | Configure the name of the application (required)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we make BPL_GOOGLE_CLOUD_MODULE and BPL_GOOGLE_CLOUD_VERSION required?

| `$BPL_GOOGLE_CLOUD_PROJECT_ID` | Configure the project id for the application (required if running outside of Google Cloud)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I made the opposite comment earlier but you mentioned that the project ID is now included in the service account key and therefore is not actually required in all situations. If we wanted to be clever (maybe too clever) we could pull the project ID out of the key name or project_id fields https://cloud.google.com/iam/docs/creating-managing-service-account-keys.

| `$BPL_GOOGLE_CLOUD_VERSION` | Configure the version of the application (required)

## Bindings
The buildpack optionally accepts the following bindings:

### Type: `GoogleCloud`
|Key | Value | Description
|-------------------------|------------------|------------
|`ApplicationCredentials` | `<JSON Payload>` | Google Cloud Application Credentials in JSON form
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`ApplicationCredentials` | `<JSON Payload>` | Google Cloud Application Credentials in JSON form
|`ApplicationCredentials` | `<JSON Payload>` | Google Cloud [Service Account Key][s] (JSON)
[s]: https://cloud.google.com/iam/docs/creating-managing-service-account-keys

I think using the more specific terminology and a link will help folks understand the workflow more quickly.


### Type: `dependency-mapping`
|Key | Value | Description
|----------------------|---------|------------
Expand Down
Loading