Skip to content

Commit

Permalink
refactor: remove unsupported cloud identifiers (#3666)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko authored Dec 5, 2024
1 parent d8e72de commit 57ef01b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 62 deletions.
6 changes: 6 additions & 0 deletions .changeset/friendly-doors-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-frontend/application-config': minor
'@commercetools-backend/express': minor
---

Remove unsupported cloud identifiers
17 changes: 5 additions & 12 deletions packages-backend/express/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,17 @@ const mapCloudIdentifierToIssuer = <Request extends TBaseRequest>(
): string | undefined => {
switch (issuer) {
case CLOUD_IDENTIFIERS.GCP_AU:
return MC_API_URLS.GCP_AU;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_AU];
case CLOUD_IDENTIFIERS.GCP_EU:
return MC_API_URLS.GCP_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_EU];
case CLOUD_IDENTIFIERS.GCP_US:
return MC_API_URLS.GCP_US;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_US];
case CLOUD_IDENTIFIERS.AWS_EU:
case CLOUD_IDENTIFIERS.AWS_FRA:
return MC_API_URLS.AWS_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.AWS_EU];
case CLOUD_IDENTIFIERS.AWS_US:
case CLOUD_IDENTIFIERS.AWS_OHIO:
return MC_API_URLS.AWS_US;
// TODO: remove it
case CLOUD_IDENTIFIERS.AWS_CN:
return MC_API_URLS.AWS_CN;
case CLOUD_IDENTIFIERS.AZURE_US:
return MC_API_URLS.AZURE_US;
case CLOUD_IDENTIFIERS.AZURE_EU:
return MC_API_URLS.AZURE_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.AWS_US];
default:
return undefined;
}
Expand Down
32 changes: 13 additions & 19 deletions packages-backend/express/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,28 @@ export const CLOUD_IDENTIFIERS = {
* @deprecated: use `AWS_US` instead
*/
AWS_OHIO: 'aws-ohio',
/**
* @deprecated: not supported anymore
*/
AWS_CN: 'aws-cn',
AZURE_US: 'azure-us',
AZURE_EU: 'azure-eu',
} as const;

export const MC_API_URLS = {
GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
AWS_EU: 'https://mc-api.eu-central-1.aws.commercetools.com',
AWS_US: 'https://mc-api.us-east-2.aws.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_AU]:
'https://mc-api.australia-southeast1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_EU]:
'https://mc-api.europe-west1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_US]:
'https://mc-api.us-central1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_EU]:
'https://mc-api.eu-central-1.aws.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_US]: 'https://mc-api.us-east-2.aws.commercetools.com',
/**
* @deprecated: use `AWS_EU` instead
*/
AWS_FRA: 'https://mc-api.eu-central-1.aws.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_FRA]:
'https://mc-api.eu-central-1.aws.commercetools.com',
/**
* @deprecated: use `AWS_US` instead
*/
AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com',
/**
* @deprecated: not supported anymore
*/
AWS_CN: 'https://mc-api.cn-northwest-1.aws.commercetools.cn',
AZURE_US: 'https://mc-api.eastus.azure.commercetools.com',
AZURE_EU: 'https://mc-api.germanywestcentral.azure.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_OHIO]:
'https://mc-api.us-east-2.aws.commercetools.com',
} as const;

export const MC_API_PROXY_HEADERS = {
Expand Down
32 changes: 13 additions & 19 deletions packages/application-config/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,28 @@ export const CLOUD_IDENTIFIERS = {
* @deprecated: use `AWS_US` instead
*/
AWS_OHIO: 'aws-ohio',
/**
* @deprecated: not supported anymore
*/
AWS_CN: 'aws-cn',
AZURE_US: 'azure-us',
AZURE_EU: 'azure-eu',
} as const;

export const MC_API_URLS = {
GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
AWS_EU: 'https://mc-api.eu-central-1.aws.commercetools.com',
AWS_US: 'https://mc-api.us-east-2.aws.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_AU]:
'https://mc-api.australia-southeast1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_EU]:
'https://mc-api.europe-west1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.GCP_US]:
'https://mc-api.us-central1.gcp.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_EU]:
'https://mc-api.eu-central-1.aws.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_US]: 'https://mc-api.us-east-2.aws.commercetools.com',
/**
* @deprecated: use `AWS_EU` instead
*/
AWS_FRA: 'https://mc-api.eu-central-1.aws.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_FRA]:
'https://mc-api.eu-central-1.aws.commercetools.com',
/**
* @deprecated: use `AWS_US` instead
*/
AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com',
/**
* @deprecated: not supported anymore
*/
AWS_CN: 'https://mc-api.cn-northwest-1.aws.commercetools.cn',
AZURE_US: 'https://mc-api.eastus.azure.commercetools.com',
AZURE_EU: 'https://mc-api.germanywestcentral.azure.commercetools.com',
[CLOUD_IDENTIFIERS.AWS_OHIO]:
'https://mc-api.us-east-2.aws.commercetools.com',
} as const;

export const LOADED_CONFIG_TYPES = {
Expand Down
17 changes: 5 additions & 12 deletions packages/application-config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@ const mapCloudIdentifierToApiUrl = (
): string => {
switch (key) {
case CLOUD_IDENTIFIERS.GCP_AU:
return MC_API_URLS.GCP_AU;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_AU];
case CLOUD_IDENTIFIERS.GCP_EU:
return MC_API_URLS.GCP_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_EU];
case CLOUD_IDENTIFIERS.GCP_US:
return MC_API_URLS.GCP_US;
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_US];
case CLOUD_IDENTIFIERS.AWS_EU:
case CLOUD_IDENTIFIERS.AWS_FRA:
return MC_API_URLS.AWS_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.AWS_EU];
case CLOUD_IDENTIFIERS.AWS_US:
case CLOUD_IDENTIFIERS.AWS_OHIO:
return MC_API_URLS.AWS_US;
// TODO: remove it
case CLOUD_IDENTIFIERS.AWS_CN:
return MC_API_URLS.AWS_CN;
case CLOUD_IDENTIFIERS.AZURE_US:
return MC_API_URLS.AZURE_US;
case CLOUD_IDENTIFIERS.AZURE_EU:
return MC_API_URLS.AZURE_EU;
return MC_API_URLS[CLOUD_IDENTIFIERS.AWS_US];
default:
// We would probably never get to this point, as the JSON schema validation
// kicks in before.
Expand Down

0 comments on commit 57ef01b

Please sign in to comment.