8000 AWS config ini quirks · Issue #238 · go-ini/ini · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

AWS config ini quirks #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mtibben opened this issue Apr 30, 2020 · 8 comments · Fixed by #253
Closed

AWS config ini quirks #238

mtibben opened this issue Apr 30, 2020 · 8 comments · Fixed by #253
Labels
feature Categorizes as related to a new feature

Comments

@mtibben
Copy link
mtibben commented Apr 30, 2020

The AWS ini config has a few quirks that are hard to handle with this library

  1. The default section is [default], not [DEFAULT] as go-ini defaults to. This is an issue when using ini.Insensitive = true, as the real default section name also reports as default. Could there be some way to override the default section when using ini.DefaultHeader = true?
  2. Key names are case insensitive, and section names are case sensitive. go-ini's Insensitive handles both keys and sections with the one setting. Could there be a way to separate this?
@unknwon
Copy link
Member
unknwon commented May 2, 2020

Hi,

  1. The default section is [default], not [DEFAULT] as go-ini defaults to. This is an issue when using ini.Insensitive = true, as the real default section name also reports as default.

Sorry I couldn't understand what is the problem here?

2. y names are case insensitive, and section names are case sensitive. go-ini's Insensitive handles both keys and sections with the one setting. Could there be a way to separate this?

Why are section names being case insensitive a problem?

@unknwon unknwon added the status: needs feedback Needs more feedback to proceed label May 2, 2020
@mtibben
Copy link
Author
mtibben commented May 2, 2020

Sorry I couldn't understand what is the problem here?

I know, it's a weird one. I previously reported #217, and I've run into it again.

When you use ini.Insensitive = true you can't differentiate between the ini DEFAULT section and aws config's actual [default] section. I've managed to work around the problem now because I'm not using ini.Insensitive

Why are section names being case insensitive a problem?

Because the section names are case sensitive, I can't use ini.Insensitive = true. This means the keys also become case sensitive, but aws treats them as case insensitive, so I want to do the same.

I've hacked around this with a regex that lowercases all the keys before passing it though to go-ini, but thought I'd raise it here in case you had a better solution.

@unknwon
Copy link
Member
unknwon commented May 2, 2020

Sorry I couldn't understand what is the problem here?

I know, it's a weird one. I previously reported #217, and I've run into it again.

When you use ini.Insensitive = true you can't differentiate between the ini DEFAULT section and aws config's actual [default] section. I've managed to work around the problem now because I'm not using ini.Insensitive

Ah OK, I see the problem here. AWS's [default] is not the same default we have in this package.

Why are section names being case insensitive a problem?

Because the section names are case sensitive, I can't use ini.Insensitive = true. This means the keys also become case sensitive, but aws treats them as case insensitive, so I want to do the same.

Just to be clear, AWS wants section names to be case sensitive and key names case insensitive? If so, does AWS ever have a section name not in lower case?

@mtibben
Copy link
Author
mtibben commented May 3, 2020

Just to be clear, AWS wants section names to be case sensitive and key names case insensitive?

Yes, that's how the aws cli currently interprets the user config. Any tool wanting to also use the config needs to replicate the aws cli parsing quirks

@mtibben
Copy link
Author
mtibben commented May 3, 2020

I think Problem 1 (default section confusion) won't be an issue if we find a solution to Problem 2 (case sensitivity differences between sections and keys)

@unknwon
Copy link
Member
unknwon commented May 3, 2020

Just to be clear, AWS wants section names to be case sensitive and key names case insensitive?

Yes, that's how the aws cli currently interprets the user config. Any tool wanting to also use the config needs to replicate the aws cli parsing quirks

Thanks, could you also answer the second part of the question?

"... If so, does AWS ever have a section name not in lower case?"

@mtibben
Copy link
Author
mtibben commented May 3, 2020

"... If so, does AWS ever have a section name not in lower case?"

Yes, the aws config file can have section names that not in lower case. Here's an example.

[profile foo]
Mfa_Serial=xxxxxxx

[profile FOO]
mfa_serial=yyyyyyy

The section name are case sensitive. Profile FOO and profile foo are different.

The key names are case insensitive. An Mfa_Serial is the same as a mfa_serial

@unknwon unknwon added feature Categorizes as related to a new feature and removed status: needs feedback Needs more feedback to proceed labels May 3, 2020
@ygj6
Copy link
Contributor
ygj6 commented Jul 30, 2020

Hello, @unknwon I want to have a try to resolve this issue.
After a preliminary analysis, I found two solutions that support only section insensitivity or only key insensitivity. The following table lists the differences between the two solutions.
I have implemented Solution 2

Solution 1: Only one option InsensitiveSectionOrKey needs to be added to support scenario overwriting. However, InsensitiveSectionOrKey must be used with Insensitive ,it is difficult for users to understand and easily confuse.

Scenario Insensitive InsensitiveSectionOrKey Analysis
section insensitive,key insensitive TRUE FALSE Compatible with the original logic
section sensitive,key sensitive FALSE FALSE Compatible with the original logic
section sensitive,key insensitive FALSE TRUE Add
section insensitive,key sensitive TRUE TRUE Add

Solution 2: Add two options InsensitiveKey and InsensitiveSection to support scenario overwriting.

Scenario Insensitive InsensitiveKey InsensitiveSection Analysis
section insensitive,key insensitive TRUE - - Compatible with the original logic
section insensitive,key insensitive FALSE TRUE TRUE Add
section sensitive,key sensitive FALSE FALSE FALSE Compatible with the original logic
section sensitive,key insensitive FALSE TRUE FALSE Add
section insensitive,key sensitive FALSE FALSE TRUE Add

Which one do you think is better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Categorizes as related to a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0