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

caddyfile: Support for raw token values, improve map, expression #4643

Merged
merged 3 commits into from Mar 18, 2022

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Mar 18, 2022

Followup to 93c99f6 as pointed out in caddyserver/website#221, and fixing the issue mentioned in caddyserver/website#220

See the adapt tests, which cover how it behaves.

Note: This is a breaking change, because people using map with numbers used to get strings, and will now get numbers.

@francislavoie francislavoie added the bug 🐞 Something isn't working label Mar 18, 2022
@francislavoie francislavoie force-pushed the better-caddyfile-quotes branch 2 times, most recently from 7a548b8 to 41d1f56 Compare March 18, 2022 02:54
@mholt
Copy link
Member

mholt commented Mar 18, 2022

No way, Francis, you are a WIZARD. I look forward to reviewing this, hopefully tomorrow

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Awesome, thanks. This is a neat improvement. Just a few nits/questions/ideas.

caddyconfig/caddyfile/dispenser.go Show resolved Hide resolved
caddyconfig/caddyfile/dispenser.go Outdated Show resolved Hide resolved
modules/caddyhttp/celmatcher.go Outdated Show resolved Hide resolved

// ScalarVal gets value of the current token, converted to the
// appropriate scalar type. If there is no token loaded, it returns nil.
func (d *Dispenser) ScalarVal() interface{} {
Copy link
Member

Choose a reason for hiding this comment

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

Good name choice, but TypedVal() also came to mind. Not sure which is better. I'm fine with this, but wanted to ask anyway to see what you thought.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think Typed would be better if we supported returning somekind of struct, but I think Scalar is clearer that only scalars will be returned (for now)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, and that's what I was wondering too, if in the future we'd ever deserialize a string as a structured data type. But I can't see that happening in the near future nor do I have any idea why or what that would look like. So Scalar is fine... hopefully we don't have to change it.

caddyconfig/caddyfile/lexer.go Outdated Show resolved Hide resolved
caddyconfig/caddyfile/lexer.go Outdated Show resolved Hide resolved
@mholt mholt added this to the v2.5.0 milestone Mar 18, 2022
@mholt mholt added the under review 🧐 Review is pending before merging label Mar 18, 2022
Copy link
Member Author

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

LGTM

caddyconfig/caddyfile/dispenser.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working under review 🧐 Review is pending before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants