Skip to content

Commit

Permalink
Pass configuration file as second parameter to configSelector (#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Oct 6, 2023
1 parent aa86b3f commit 7b568c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-colts-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/node-config-provider": minor
---

Pass configuration file as second parameter to configSelector
7 changes: 4 additions & 3 deletions packages/node-config-provider/src/fromSharedConfigFiles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CredentialsProviderError } from "@smithy/property-provider";
import { getProfileName, loadSharedConfigFiles, SourceProfileInit } from "@smithy/shared-ini-file-loader";
import { Profile, Provider } from "@smithy/types";
import { ParsedIniData, Profile, Provider } from "@smithy/types";

export interface SharedConfigInit extends SourceProfileInit {
/**
Expand All @@ -11,7 +11,7 @@ export interface SharedConfigInit extends SourceProfileInit {
preferredFile?: "config" | "credentials";
}

export type GetterFromConfig<T> = (profile: Profile) => T | undefined;
export type GetterFromConfig<T> = (profile: Profile, configFile?: ParsedIniData) => T | undefined;

/**
* Get config value from the shared config files with inferred profile name.
Expand All @@ -31,7 +31,8 @@ export const fromSharedConfigFiles = <T = string>(
: { ...profileFromConfig, ...profileFromCredentials };

try {
const configValue = configSelector(mergedProfile);
const cfgFile = preferredFile === "config" ? configFile : credentialsFile;
const configValue = configSelector(mergedProfile, cfgFile);
if (configValue === undefined) {
throw new Error();
}
Expand Down

0 comments on commit 7b568c3

Please sign in to comment.