-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate sso-session and services sections when loading config files (#…
…993)
- Loading branch information
Showing
12 changed files
with
121 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@smithy/types": patch | ||
--- | ||
|
||
Add enum IniSectionType |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@smithy/shared-ini-file-loader": minor | ||
--- | ||
|
||
Populate sso-session and services sections when loading config files |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IniSectionType, ParsedIniData } from "@smithy/types"; | ||
|
||
import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles"; | ||
|
||
/** | ||
* Returns the config data from parsed ini data. | ||
* * Returns data for `default` | ||
* * Returns profile name without prefix. | ||
* * Returns non-profiles as is. | ||
*/ | ||
export const getConfigData = (data: ParsedIniData): ParsedIniData => | ||
Object.entries(data) | ||
// filter out | ||
.filter(([key]) => { | ||
const sections = key.split(CONFIG_PREFIX_SEPARATOR); | ||
if (sections.length === 2 && Object.values(IniSectionType).includes(sections[0] as IniSectionType)) { | ||
return true; | ||
} | ||
return false; | ||
}) | ||
// replace profile prefix, if present. | ||
.reduce( | ||
(acc, [key, value]) => { | ||
const updatedKey = key.startsWith(IniSectionType.PROFILE) ? key.split(CONFIG_PREFIX_SEPARATOR)[1] : key; | ||
acc[updatedKey] = value; | ||
return acc; | ||
}, | ||
{ | ||
// Populate default profile, if present. | ||
...(data.default && { default: data.default }), | ||
} as ParsedIniData | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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