Skip to content

Commit

Permalink
fix(middleware-bucket-endpoint): throw in selector if config name not…
Browse files Browse the repository at this point in the history
… exists
  • Loading branch information
AllanZhengYP committed Aug 7, 2020
1 parent 106fdeb commit 8c0ad49
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
8 changes: 0 additions & 8 deletions packages/middleware-bucket-endpoint/src/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ describe("Node useArnRegion config loader", () => {
delete env[NODE_USE_ARN_REGION_ENV_NAME];
});

it(`should return undefined if the environment variable doesn't have ${NODE_USE_ARN_REGION_ENV_NAME}`, () => {
expect(loadOptions.environmentVariableSelector(env)).toBeUndefined();
});

[
{ envValue: "true", parsed: true },
{ envValue: "false", parsed: false },
Expand Down Expand Up @@ -42,10 +38,6 @@ describe("Node useArnRegion config loader", () => {
delete profileContent[NODE_USE_ARN_REGION_INI_NAME];
});

it(`should return undefined if shared config profile doesn't have ${NODE_USE_ARN_REGION_INI_NAME}`, () => {
expect(loadOptions.configFileSelector(profileContent)).toBeUndefined();
});

[
{ value: "true", parsed: true },
{ value: "false", parsed: false },
Expand Down
2 changes: 0 additions & 2 deletions packages/middleware-bucket-endpoint/src/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ export const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
*/
export const NODE_USE_ARN_REGION_CONFIG_OPTIONS: LoadedConfigSelectors<boolean> = {
environmentVariableSelector: (env: NodeJS.ProcessEnv) => {
if (!Object.prototype.hasOwnProperty.call(env, NODE_USE_ARN_REGION_ENV_NAME)) return undefined;
if (env[NODE_USE_ARN_REGION_ENV_NAME] === "true") return true;
if (env[NODE_USE_ARN_REGION_ENV_NAME] === "false") return false;
throw new Error(
`Cannot load env ${NODE_USE_ARN_REGION_ENV_NAME}. Expected "true" or "false", got ${env[NODE_USE_ARN_REGION_ENV_NAME]}.`
);
},
configFileSelector: (profile) => {
if (!Object.prototype.hasOwnProperty.call(profile, NODE_USE_ARN_REGION_INI_NAME)) return undefined;
if (profile[NODE_USE_ARN_REGION_INI_NAME] === "true") return true;
if (profile[NODE_USE_ARN_REGION_INI_NAME] === "false") return false;
throw new Error(
Expand Down

0 comments on commit 8c0ad49

Please sign in to comment.