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

feat: add detection for Cloud Run #1177

Merged
merged 2 commits into from May 21, 2021
Merged

feat: add detection for Cloud Run #1177

merged 2 commits into from May 21, 2021

Conversation

JustinBeckwith
Copy link
Contributor

@JustinBeckwith JustinBeckwith commented May 19, 2021

Fixes #1155. This adds detection for Cloud Run via the K_CONFIGURATION env var. The order of checks is important in that it:

  • First makes sure there's a GCE Metadata server available
  • Makes sure we're not on k8s
  • Then finally checks for the env var

This should help get rid of false positives via Knative on k8s or non-gcp environments.

@JustinBeckwith JustinBeckwith requested a review from a team as a code owner May 19, 2021 23:37
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 19, 2021
@JustinBeckwith JustinBeckwith merged commit 4512363 into master May 21, 2021
@JustinBeckwith JustinBeckwith deleted the detectrun branch May 21, 2021 16:40
Comment on lines +73 to +75
function isCloudRun() {
return !!process.env.K_CONFIGURATION;
}

Choose a reason for hiding this comment

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

I guess it's too late now but we should be querying metadata endpoint first and use this env variable only in case metadata endpoint doesn't return the environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCPEnv to detect more GCP services
3 participants