Skip to content

Commit

Permalink
fix(credential-provider): address feedbacks
Browse files Browse the repository at this point in the history
Co-authored-by: Trivikram Kamat <[email protected]>
  • Loading branch information
AllanZhengYP and trivikr authored Feb 19, 2021
1 parent 6ebe687 commit 956fd89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions packages/credential-provider-ini/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ const isAssumeRoleProfile = (arg: any): arg is AssumeRoleProfile =>
* Creates a credential provider that will read from ini files and supports
* role assumption and multi-factor authentication.
*/
export const fromIni = (init: FromIniInit = {}): CredentialProvider => () =>
parseKnownFiles(init).then((profiles) => resolveProfileData(getMasterProfileName(init), profiles, init));
export const fromIni = (init: FromIniInit = {}): CredentialProvider => async () => {
const profiles = await parseKnownFiles(init);
return resolveProfileData(getMasterProfileName(init), profiles, init);
};

/**
* Load profiles from credentials and config INI files and normalize them into a
Expand All @@ -123,13 +125,11 @@ export const fromIni = (init: FromIniInit = {}): CredentialProvider => () =>
export const parseKnownFiles = async (init: SourceProfileInit): Promise<ParsedIniData> => {
const { loadedConfig = loadSharedConfigFiles(init) } = init;

return loadedConfig.then((parsedFiles) => {
const { configFile, credentialsFile } = parsedFiles;
return {
...configFile,
...credentialsFile,
};
});
const parsedFiles = await loadedConfig;
return {
...parsedFiles.configFile,
...parsedFiles.credentialsFile,
};
};

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/credential-provider-process/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export interface FromProcessInit extends SourceProfileInit {}
* Creates a credential provider that will read from a credential_process specified
* in ini files.
*/
export const fromProcess = (init: FromProcessInit = {}): CredentialProvider => () =>
parseKnownFiles(init).then((profiles) => resolveProcessCredentials(getMasterProfileName(init), profiles));
export const fromProcess = (init: FromProcessInit = {}): CredentialProvider => async () => {
const profiles = await parseKnownFiles(init);
return resolveProcessCredentials(getMasterProfileName(init), profiles);
};

async function resolveProcessCredentials(profileName: string, profiles: ParsedIniData): Promise<Credentials> {
const profile = profiles[profileName];
Expand Down

0 comments on commit 956fd89

Please sign in to comment.