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

MODULES-1382: support multiple access log directives #951

Merged
merged 1 commit into from
Jan 15, 2015

Conversation

jlambert121
Copy link
Contributor

@jlambert121
Copy link
Contributor Author

Feedback on this implementation would be great!

@igalic
Copy link
Contributor

igalic commented Dec 22, 2014

@jlambert121 i like the general look and feel of the design: the hash (struct, really ;) makes the intent very obvious.
what i don't like is the impenetrable nature of the implementation: the erb's ternary operators are unreadable.

<% elsif @access_log -%>
CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %>
<% @_access_logs.each do |log| -%>
<% log['env'] ? env = "env=#{log['env']}" : env = '' -%>
Copy link
Contributor

Choose a reason for hiding this comment

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

this line can be simplified as:

env ||= "env=#{log['env']}" if log['env']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This being easier to read/simpler is a matter of opinion, I prefer ternary operators because I think they're easier to read. That being said, I don't mind changing it. I think later on in the template though <%= env %> could result to the literal 'nil' or 'undef' for older versions of ruby if log['env'](and therefore env) was unset, wouldn't it? The purpose of setting it to if log['env'] was undefined was to ensure the template was clean on output.

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think so, but maybe that's why we need more tests ;)

Choose a reason for hiding this comment

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

Actually:

env ||= "env=#{log['env']}" if log['env']
env ||= ''

That said, I'd say this is not logic that should be in a template but should be passed and used as-is with the logic whereever the template is included at.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but, puppet 3 :(

@jlambert121 jlambert121 force-pushed the modules_1382 branch 3 times, most recently from ebce295 to 80c5f68 Compare December 22, 2014 15:25
igalic added a commit that referenced this pull request Jan 15, 2015
MODULES-1382: support multiple access log directives
@igalic igalic merged commit 76fd199 into puppetlabs:master Jan 15, 2015
@igalic
Copy link
Contributor

igalic commented Jan 15, 2015

thank you @jlambert121!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants