Skip to content

Commit

Permalink
write: update config file section with same name if no cred process flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gord5500 committed Jun 17, 2024
1 parent 6495405 commit a1d91ee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/D2L.Bmx/WriteHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ bool useCredentialProcess
+ $" --role {awsCredsInfo.Role}"
+ $" --duration {awsCredsInfo.Duration}";
} else {
if( File.Exists( SharedCredentialsFile.DefaultConfigFilePath ) ) {
string profileName = $"profile {profile}";
var defaultConfigFile = parser.ReadFile( SharedCredentialsFile.DefaultConfigFilePath );
if( defaultConfigFile.Sections.ContainsSection( profileName )
&& defaultConfigFile[profileName].ContainsKey( "credential_process" ) ) {

if( defaultConfigFile[profileName].Count == 1 ) {
defaultConfigFile.Sections.RemoveSection( profileName );
} else {
defaultConfigFile[profileName].RemoveKey( "credential_process" );
}
parser.WriteFile( SharedCredentialsFile.DefaultConfigFilePath, defaultConfigFile );
Console.WriteLine(
"""
An existing profile with the same name using the `credential_process` key was found in the default config file.
The key has been removed, and static credentials will be used for the profile.
To continue using non-static credentials, rerun the command with the --use-credential-process flag.
"""
);
}
}
if( !data.Sections.ContainsSection( profile ) ) {
data.Sections.AddSection( profile );
}
Expand Down

0 comments on commit a1d91ee

Please sign in to comment.