Skip to content

chore(cloud/shelf): split package#231

Draft
brianquinlan wants to merge 1 commit intogoogleapis:mainfrom
brianquinlan:shelf-split
Draft

chore(cloud/shelf): split package#231
brianquinlan wants to merge 1 commit intogoogleapis:mainfrom
brianquinlan:shelf-split

Conversation

@brianquinlan
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the project by extracting shelf-related HTTP serving functionality from package:google_cloud into a new standalone package, package:shelf_google_cloud. The changes include moving source code, tests, and documentation, as well as updating the workspace configuration. Feedback was provided regarding the duplication of constants in the new package that are already available in the core google_cloud package, suggesting they should be reused to maintain consistency and reduce synchronization risks.

Comment on lines +1 to +86
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// The standard environment variable for specifying the port a service should
/// listen on.
const portEnvironmentVariable = 'PORT';

/// Standard environment variable for specifying the path to a service account
/// JSON file.
///
/// See: https://docs.cloud.google.com/docs/authentication/application-default-credentials
const credentialsPathEnvironmentVariable = 'GOOGLE_APPLICATION_CREDENTIALS';

/// A set of standard environment variables that are likely to represent the
/// current Google Cloud project ID.
///
/// For context, see:
/// * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts
/// * https://cloud.google.com/functions/docs/env-var
///
/// Note: these are ordered starting from the most current/canonical to least.
/// (At least as could be determined at the time of writing.)
const projectIdEnvironmentVariableOptions = {
projectIdEnvironmentVariable,
'GCP_PROJECT',
'GCLOUD_PROJECT',
'CLOUDSDK_CORE_PROJECT',
};

/// The standard environment variable for specifying the Google Cloud project
/// ID.
const projectIdEnvironmentVariable = 'GOOGLE_CLOUD_PROJECT';

/// The default port a service should listen on if [portEnvironmentVariable] is
/// not set.
const defaultListenPort = 8080;

/// Standard HTTP header used by
/// [Cloud Trace](https://cloud.google.com/trace/docs/setup).
const cloudTraceContextHeader = 'x-cloud-trace-context';

/// Standard HTTP request headers expected by the
/// [Metadata Server](https://cloud.google.com/compute/docs/metadata).
const metadataFlavorHeaders = {'Metadata-Flavor': 'Google'};

/// The name of the Cloud Run service being run.
///
/// See https://docs.cloud.google.com/run/docs/container-contract#services-env-vars
const serviceEnvironmentVariable = 'K_SERVICE';

/// The name of the Cloud Run revision being run.
///
/// See https://docs.cloud.google.com/run/docs/container-contract#services-env-vars
const revisionEnvironmentVariable = 'K_REVISION';

/// The name of the Cloud Run configuration being run.
///
/// See https://docs.cloud.google.com/run/docs/container-contract#services-env-vars
const configurationEnvironmentVariable = 'K_CONFIGURATION';

/// The `payload` key used to correlate log entries with Cloud Trace.
///
/// See https://docs.cloud.google.com/logging/docs/agent/logging/configuration#special-fields
const logTraceKey = 'logging.googleapis.com/trace';

/// The `payload` key used to correlate log entries with a specific span within
/// a Cloud Trace.
///
/// See https://docs.cloud.google.com/logging/docs/agent/logging/configuration#special-fields
const logSpanIdKey = 'logging.googleapis.com/spanId';

/// The `payload` key used to indicate whether a trace is sampled.
///
/// See https://docs.cloud.google.com/logging/docs/agent/logging/configuration#special-fields
const logTraceSampledKey = 'logging.googleapis.com/trace_sampled';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This file duplicates constants that are already defined in package:google_cloud/constants.dart. Since shelf_google_cloud depends on google_cloud, it should reuse the existing constants to ensure consistency and simplify maintenance. Redefining them here creates a synchronization risk if the standard GCP environment variables or logging keys ever change.

@brianquinlan brianquinlan marked this pull request as draft April 8, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant