Skip to content

Commit

Permalink
Merge branch 'main' into retry_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 authored Jul 18, 2024
2 parents 88ffd50 + a880fb8 commit ead286e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions internal/detect/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
)

const (
projectIDSentinel = "*detect-project-id*"
// ProjectIDSentinel is the value that users should pass for the project ID
// to enable detection.
ProjectIDSentinel = "*detect-project-id*"
envProjectID = "GOOGLE_CLOUD_PROJECT"
)

Expand All @@ -41,8 +43,8 @@ var (
// 1. GOOGLE_CLOUD_PROJECT envvar
// 2. ADC creds.ProjectID
// 3. A static value if the environment is emulated.
func ProjectID(ctx context.Context, projectID string, emulatorEnvVar string, opts ...option.ClientOption) (string, error) {
if projectID != projectIDSentinel {
func ProjectID(ctx context.Context, projectID, emulatorEnvVar string, opts ...option.ClientOption) (string, error) {
if projectID != ProjectIDSentinel {
return projectID, nil
}
// 1. Try a well known environment variable
Expand Down
6 changes: 3 additions & 3 deletions internal/detect/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func TestIt(t *testing.T) {
},
{
name: "environment project id",
projectID: projectIDSentinel,
projectID: ProjectIDSentinel,
env: map[string]string{envProjectID: "environment-project-id"},
want: "environment-project-id",
},
{
name: "adc project id",
projectID: projectIDSentinel,
projectID: ProjectIDSentinel,
adcProjectID: "adc-project-id",
want: "adc-project-id",
},
{
name: "emulator project id",
projectID: projectIDSentinel,
projectID: ProjectIDSentinel,
env: map[string]string{"EMULATOR_HOST": "something"},
want: "emulated-project",
},
Expand Down

0 comments on commit ead286e

Please sign in to comment.