Skip to content
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

Adds subproperty as new literal type #2308

Closed

Conversation

isaiahvita
Copy link
Contributor

@isaiahvita isaiahvita commented Oct 10, 2023

To support subproperties in the aws config file, it was decided to extend the ini lexer to treat subproperties as literals. Then parse these literals in the config parser.

It was specifically avoided to add this support in the INI parser. This is because the current state of the INI parser:

  • does not follow traditional language parser construction from a CFG (or BNF) into a parse table.
  • parser logic from a parse table is obscure and is non-standard
  • all institutional knowledge of this implementation is lost

@isaiahvita isaiahvita requested a review from a team as a code owner October 10, 2023 16:37
@lucix-aws
Copy link
Contributor

lucix-aws commented Oct 10, 2023

Is there going to be followup to bubble this further up to the actual parsed Sections? We have test data right now that still expects nested fields to be skipped:

[foo]                            
aws_access_key_id =              
    aws_secret_access_key = valid
aws_session_token = valid        
[bar]                            
aws_access_key_id = valid        
aws_secret_access_key = valid    
aws_session_token = valid        
[baz]                            
aws_access_key_id = valid        
aws_secret_access_key = valid    
aws_session_token = valid        

expects

{
    "foo": {
        "aws_session_token": "valid"
        // doesn't expect {"aws_access_key_id": { "aws_secret_access_key": "valid"} }
    },
    "bar": {
        "aws_access_key_id": "valid",
        "aws_secret_access_key": "valid",
        "aws_session_token": "valid"
    },
    "baz": {
        "aws_access_key_id": "valid",
        "aws_secret_access_key": "valid",
        "aws_session_token": "valid"
    }
}

I would think that test case should fail as written and be updated with this change.

@isaiahvita
Copy link
Contributor Author

@lucix-aws

Is there going to be followup to bubble this further up to the actual parsed Sections? We have test data right now that still expects nested fields to be skipped:

with the last commit, the data is now bubbled up in Sections.container["section_name"].values["item_name"].mp
additionally, the referenced test data has been amended

Copy link
Contributor

@lucix-aws lucix-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So given that this new token is "greedy" (like, it's made up of smaller tokens that could be recognized on their own) we probably want to extend the test data (can do nested_fields) to cover a few more things

  • multiple nested fields
  • nested fields at the end of a profile where the next line is a [profile] declaration
  • nested fields at the end of a file
  • nested fields at the end of a file + newlines

LGTM otherwise, fixandship.

@@ -60,7 +60,6 @@ const (
NoneType = ValueType(iota)
StringType
QuotedStringType
// FUTURE(2226) MapType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no MapType? I don't fully remember what all uses this, though.

return 0, fmt.Errorf("no sub property")
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have gofmt running? It should clean up extra newlines like this.

@lucix-aws lucix-aws closed this Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants