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

Implement GLOME login INI config parsing in Go. #169

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

lukegb
Copy link
Collaborator

@lukegb lukegb commented Aug 10, 2023

This implements INI parsing internally, rather than pulling in a library because
we want to exactly match the behaviour of the C library, and our INI-parsing has
a few quirks (as do all INI parsers...) - for instance, we only support comments
if they're on their own line.

Additionally, the code that does the INI parsing is relatively small; the bulk of
the code is actually parsing things into application specific structs, which we
would need to do anyway. Possibly this is ripe for switching to TOML, but we'd still
have to e.g. parse string encoded keys to binary/validate that the options set
are compatible with each other.

Fixes #168.

Copy link
Member

@pkern pkern left a comment

Choose a reason for hiding this comment

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

I overcame my struggles with having to maintain an INI parser implementation in the future. Turns out our config format feels very bespoke anyway.

go/config/config_x_test.go Outdated Show resolved Hide resolved
go/config/config.go Show resolved Hide resolved
go/config/config.go Show resolved Hide resolved
go/config/config_x_test.go Outdated Show resolved Hide resolved
@burgerdev
Copy link
Collaborator

LGTM, but can we please keep track of the problems with our config format that prevent us from using an ini parser dependency? Next time we touch the config format, we could aim to fix those.

@lukegb lukegb requested review from pkern and burgerdev September 18, 2023 09:20
Copy link
Member

@pkern pkern left a comment

Choose a reason for hiding this comment

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

From my side this LGTM now. I'm with Markus that we shoud document somewhere (maybe in the commit description? or in a source comment...) why we chose this route. If it's just about the value parsing, we should've been able to do that also with another implementation. That said, Parse() is actually very small and the remainder is spent on putting the values into the right places, so this is fine with me for now.

This implements INI parsing internally, rather than pulling in a library because
we want to exactly match the behaviour of the C library, and our INI-parsing has
a few quirks (as do all INI parsers...) - for instance, we only support comments
if they're on their own line.

Additionally, the code that does the INI parsing is relatively small; the bulk of
the code is actually parsing things into application specific structs, which we
would need to do anyway. Possibly this is ripe for switching to TOML, but we'd still
have to e.g. parse string encoded keys to binary/validate that the options set
are compatible with each other.

Fixes google#168.
@burgerdev burgerdev merged commit 6c100fd into google:master Oct 5, 2023
9 checks passed
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.

Add Go GLOME config file parsing
3 participants