-
Notifications
You must be signed in to change notification settings - Fork 140
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
fix(fb_apache): render arrays inside of hash configs #218
base: main
Are you sure you want to change the base?
Conversation
Hi @ericnorris! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!
This is interesting. It doesn't handle hashes because of https://github.com/facebook/chef-cookbooks/blob/main/cookbooks/fb_apache/templates/default/apache_conf.erb#L4 where we handle arrays. However, if there's an array embedded in a Hash, you're right, we don't handle it.
So, let's DRY this up a bit. Update apache_conf.erb
to call this function if it's array or a hash, and rename the method to template_data_handler
(or if you have a better name, I'm open).
And finally, you'll need to sign the CLA.
Hey @jaymzh, thanks for the quick review! I hope you don't mind but I went a step further and moved all of the template logic into the function. This had the added benefit of allowing the Edit: I'm still looking into the CLA on my side, waiting for some information from legal. |
Can you even have rewrites inside a directory? I thought they only worked inside a VirtualHost |
I believe so! I tested this locally, and per https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule:
Edit: I reread the original |
Yeah I was gonna say, it definitely worked at the top level, we use it at SCALE: |
This looks reasonable, but you need to rebase. I kicked off the tests... I know a lot are broken (sorry), but lets make sure any Apache ones pass. |
This commit moves all template logic into a single function and drops the separate `apache_conf.erb`, which should prevent things from only working in one context (e.g. at the top-level of the config) and not another (e.g. as a sub-hash of the config). I replaced the check for `Fixnum` with `Integer` when moving the logic, per the `Lint/UnifiedInteger` lint.
8c0e2d2
to
0236780
Compare
@jaymzh I'm still waiting on getting the CLA signed, apologies for that. That said, I've rebased the branch and fixed a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Once you've signed the CLA, someone at Meta can pull this in internally, test it, and merge it.
I'm still stuck on trying to get the CLA signed; we already had an existing CLA and we've sent an email to [email protected] to update it but have not yet received a response. We're interested in potentially submitting other PRs in the future so we're motivated to figure this out. |
Hey @davide125 or @joshuamiller01 - maybe one of you can poke the opensource folks on the status of Eric's request? |
Taking a look into the CLA issue now - did you try https://code.facebook.com/cla as well? |
Thanks @jaymzh and @dafyddcrosby! I was considering signing a separate CLA, but it seems that someone responded soon after I left the earlier GitHub message. I believe my coworkers and myself are now squared away with the CLA, although I see the check hasn't yet updated. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@dafyddcrosby has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Description
This PR fixes a bug where the
template_hash_handler
infb_apache
silently skips overArray
values. Now these values are rendered as if they were in the top-levelVirtualHost
directive.For example:
...will now properly include multiple
Header ...
lines in theLocation /foo
directive.Impact
These values were ignored previously, so it is possible that it would cause changes in hosts where this was happening.