-
Notifications
You must be signed in to change notification settings - Fork 8
[JS]Removes usage of non-prod regions in observability. #65
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,72 +1,59 @@ | ||
| // ------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // ------------------------------------------------------------------------------ | ||
|
|
||
| /** | ||
| * Utility logic for environment-related operations. | ||
| */ | ||
|
|
||
| // Authentication scopes for different environments | ||
| export const TEST_OBSERVABILITY_SCOPE = 'https://api.test.powerplatform.com/.default'; | ||
| export const PREPROD_OBSERVABILITY_SCOPE = 'https://api.preprod.powerplatform.com/.default'; | ||
| export const PROD_OBSERVABILITY_SCOPE = 'https://api.powerplatform.com/.default'; | ||
| export const PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = 'ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default'; | ||
|
|
||
| // Cluster categories for different environments | ||
| export const TEST_OBSERVABILITY_CLUSTER_CATEGORY = 'test'; | ||
| export const PREPROD_OBSERVABILITY_CLUSTER_CATEGORY = 'preprod'; | ||
| export const PROD_OBSERVABILITY_CLUSTER_CATEGORY = 'prod'; | ||
|
|
||
| // Default environment names | ||
| export const PRODUCTION_ENVIRONMENT_NAME = 'production'; | ||
| export const DEVELOPMENT_ENVIRONMENT_NAME = 'Development'; | ||
|
|
||
| /** | ||
| * Returns the scope for authenticating to the observability service based on the current environment. | ||
| * | ||
| * @returns The authentication scope for the current environment. | ||
| */ | ||
| export function getObservabilityAuthenticationScope(): string[] { | ||
| const clusterCategory = getClusterCategory(); | ||
|
|
||
| if (['local', 'dev', 'test', 'preprod'].includes(clusterCategory)) { | ||
| return [PREPROD_OBSERVABILITY_SCOPE]; | ||
| } else { | ||
| // Default to production scope for 'prod' and any other values | ||
| return [PROD_OBSERVABILITY_SCOPE]; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the cluster category from environment variables. | ||
| * | ||
| * @returns The cluster category from CLUSTER_CATEGORY env var, defaults to 'prod'. | ||
| */ | ||
| export function getClusterCategory(): string { | ||
| const clusterCategory = process.env.CLUSTER_CATEGORY; | ||
|
|
||
| if (!clusterCategory) { | ||
| return 'prod'; | ||
| } | ||
|
|
||
| return clusterCategory.toLowerCase(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the current environment is a development environment. | ||
| * | ||
| * @returns True if the current environment is development, false otherwise. | ||
| */ | ||
| export function isDevelopmentEnvironment(): boolean { | ||
| const clusterCategory = getClusterCategory(); | ||
| return ['local', 'dev'].includes(clusterCategory); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the MCP platform authentication scope from environment variables. | ||
| * | ||
| * @returns The MCP platform authentication scope from MCP_PLATFORM_AUTHENTICATION_SCOPE env var, defaults to production scope. | ||
| */ | ||
| export function getMcpPlatformAuthenticationScope(): string { | ||
| return process.env.MCP_PLATFORM_AUTHENTICATION_SCOPE || PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE; | ||
| } | ||
| // ------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // ------------------------------------------------------------------------------ | ||
|
|
||
| /** | ||
| * Utility logic for environment-related operations. | ||
| */ | ||
|
|
||
| export const PROD_OBSERVABILITY_SCOPE = 'https://api.powerplatform.com/.default'; | ||
| export const PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = 'ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default'; | ||
| export const PROD_OBSERVABILITY_CLUSTER_CATEGORY = 'prod'; | ||
|
|
||
| // Default environment names | ||
| export const PRODUCTION_ENVIRONMENT_NAME = 'production'; | ||
| export const DEVELOPMENT_ENVIRONMENT_NAME = 'Development'; | ||
|
|
||
| /** | ||
| * Returns the scope for authenticating to the observability service | ||
| * | ||
| * @returns The authentication scope for the current environment. | ||
| */ | ||
| export function getObservabilityAuthenticationScope(): string[] { | ||
| // Always return production scope | ||
| return [PROD_OBSERVABILITY_SCOPE]; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the cluster category from environment variables. | ||
| * | ||
| * @returns The cluster category from CLUSTER_CATEGORY env var, defaults to 'prod'. | ||
| */ | ||
| export function getClusterCategory(): string { | ||
| const clusterCategory = process.env.CLUSTER_CATEGORY; | ||
|
|
||
| if (!clusterCategory) { | ||
| return 'prod'; | ||
| } | ||
|
|
||
| return clusterCategory.toLowerCase(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the current environment is a development environment. | ||
| * | ||
| * @returns True if the current environment is development, false otherwise. | ||
| */ | ||
| export function isDevelopmentEnvironment(): boolean { | ||
| const clusterCategory = getClusterCategory(); | ||
| return ['local', 'dev'].includes(clusterCategory); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the MCP platform authentication scope from environment variables. | ||
| * | ||
| * @returns The MCP platform authentication scope from MCP_PLATFORM_AUTHENTICATION_SCOPE env var, defaults to production scope. | ||
| */ | ||
| export function getMcpPlatformAuthenticationScope(): string { | ||
| return process.env.MCP_PLATFORM_AUTHENTICATION_SCOPE || PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.