Awesome work on the new style guide!
== Section 5
Why the arbitrary line length? Puppet's DSL does not have the ability to
break lines, such as '\' in bash, so imposing any limit does not buy
anything, certainly not readability. If you want to give clear error
messages that improve readability they will include the variable and its
data which could be greater than 140 characters. In essence, until there
is a way to break lines in the DSL, there should not be any limit to how
long a line could be.
== Section 9.6
This suggests that using symbolic modes (mode => 'u=rw,g=r,o=r') are
acceptable. What is the purpose of this? This decreases readability and
understanding.
== Section 10.2
Would add that includes should happen right after defining parameters
and before validation.
== Section 10.4
Suggest adding that chaining arrow syntax should only be used with the
reference syntax and not between resources. The example below is a bad
use of the chaining arrows that leads to changing ordering by
inadvertently moving resources around. This is easy to do when merging
software.
package { 'foo':
ensure => present,
} ->
service { 'food':
ensure => running,
}
== Section 10.6
Suggest that while having required parameters for defines is OK, having
them for classes is not. There should never be required parameters for a
class. This breaks the ability to `include` a class.
<snip/>
== Section 5
Why the arbitrary line length? Puppet's DSL does not have the ability to
break lines, such as '\' in bash, so imposing any limit does not buy
anything, certainly not readability. [...]
== Section 9.6
This suggests that using symbolic modes (mode => 'u=rw,g=r,o=r') are
acceptable. What is the purpose of this? This decreases readability and
understanding.
== Section 10.2
Would add that includes should happen right after defining parameters
and before validation.
== Section 10.4
Suggest adding that chaining arrow syntax should only be used with the
reference syntax and not between resources. The example below is a bad
use of the chaining arrows that leads to changing ordering by
inadvertently moving resources around. This is easy to do when merging
software.
Inline....On Mon, Feb 2, 2015 at 3:24 PM, Garrett Honeycutt <g...@garretthoneycutt.com> wrote:
I'd like to vote for putting all validation at the bottom of the file.Honestly, we're getting quite heavy in the amount of cruft in the files in general.
== Section 10.2.7
I tend to order things in resource alphabetical order because then, if I'm looking for a file resource, it's in the 'F' section. And I still like the fact that order doesn't matter in Puppet unless I tell it to. Accordingly, should I happen to break my order accidentally, I really don't want to care.
== Section 10.6
Suggest that while having required parameters for defines is OK, having
them for classes is not. There should never be required parameters for a
class. This breaks the ability to `include` a class.
No, I disagree here. There are (many) times that I *need* you to give me a parameter, I can't make one up that is magically correct. Moving this to a define-only state means that we have to start slinging around singleton defines which is what parameterized classes got us away from.I'd rather have my compile break than end up with a system doing something nonsensical, particularly when the security of the system may be at risk.
The Modules team and I are excited to finally announce the newest version of the Puppet Language Style Guide.
We've reworked the guide to reflect the new features and capabilities of Puppet 3.7, and we've expanded it to cover more topics related to building manifests and modules. If you're interested in publishing a module to the Puppet Forge or are looking to get your module "Puppet Approved," the updated guide is a great place to start.
It was a massive, company-wide effort to update this style guide, but I'm sure we didn't catch everything. If you notice a mistake or would like more information on something that's not currently covered, please file a ticket. We plan to regularly update the guide from here on out, and we definitely anticipate another big release in the months after Puppet 4 comes out.
myclass::params parameter defaults." That's a lot more specific than the rather large volume of text and examples preceding it. If it's really what the section is trying to say then you should make it the guideline and lead off with it; otherwise you should omit it.--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/011324f7-4983-4baf-891d-e8b8a72f7a8c%40googlegroups.com.
tl;dr Summarizing the feedback from Garrett, Trevor, and John (because email is hard), and see if we have resolution on some points and which ones we still need to clarify.= Questions:These need further discussion and clarification.== Section 10.7 Defines can't use inherits for parameter defaultsShould this be reduced to only cover classes, or should the description be expanded to cover the style of setting defined resource defaults also? (Which happen to be the "bad" example; whoops.)
== Section 11.2 Recommendation against using "include" is unclear or harmfulI think this was to describe how an over-zealous use of `include` may cause classes to be declared with the default parameters before a user may declare them with parameters. Or it could have been about cross-module class inclusion in public modules. What should we do with this section?
= Proposals:If the below changes sound good, then we'll go with that.== Section 5 line length is an issueManaging line lengths in puppet is difficult. This point should change to describe where to do syntax-wise linebreak rather than character-wise breaks (ie, any hashes containing more than a single key/value pair, etc.).
== Section 9.6 symbolic modesThis was answered in that symbolic modes can perform operations that numeric modes cannot. The style guide does not dictate which form to use, so this should not be an issue.
== Section 10.6 No required class parametersSome classes just MUST have required parameters and there is no way around it. The style guide should be modified to include "should minimize the number of required parameters" as a style recommendation.
== Section 10.2 item 7, resource ordering alphabeticallyRemove the mention of ordering so that it is simply "Should declare resources." This also impacts section 9.4 and should be reconciled.
== Section 10.2 includes vs validation firstValidation cannot come at the end of the file due to parse order, but it is possible to allow includes to come before validation, so we should just not dictate this bit of ordering.(This issue will go away entirely after the release of puppet 4, as validation may happen inline with the parameters themselves due to the typing system.)
== Section 10.2 Unclear description of "items 7 & 8"I'm not exactly sure what this is describing either. Most likely superfluous and will be removed.
== Section 10.4 Chaining arrow syntax with only references, not declarationsAgreed. And perhaps that if there are line breaks around arrow syntax, they must only happen to the right of the arrow and not the left so that arrows are not "hidden" at the end of previous lines.
== Section 12.1 $unique_name = $name is unclearI believe this was to describe how the continued use of $name throughout a define can lead to confusion, as $name has no strong semantic meaning. Thus a "good" example would be https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/listen.pp#L2 and a bad example would be... https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/vhost.pp (because $name is scattered throughout the define and has no definite meaning).
== Section 18 Parameter ordering unclearThe paragraph about ordering should be moved to 10.6 or removed altogether.
== Section 19 should be moved to Section 2Because if becoming a specification for puppet-lint is a purpose, then section 2 is best.
== "Style guide" vs "specification" discussion from jcbollingerTo paraphrase, "the 'language style guide' is written as a technical specification covering more than the language; it covers module structure and module contribution conduct. This is not 'style' and is beyond the scope of this document."In answer... we should change the title to something other than "The Puppet Language Style Guide" :). I personally feel that "Module Style Guide" would still encompass what is included here, when the above edits are taken into account.
== Section 10.7 Defines can't use inherits for parameter defaultsShould this be reduced to only cover classes, or should the description be expanded to cover the style of setting defined resource defaults also? (Which happen to be the "bad" example; whoops.)
The guide's preferred form works for defined types, too, provided the default values are static (but then why would you even consider the other style?). On the other hand, the guide's preferred style does not work even for classes when a parameter's default value needs to be computed from the actual values of other parameters. I think the guideline should be softened to a recommendation, its applicability narrowed to classes only, and the example labels changed from "GOOD" and "BAD" to something like "Preferred" and "Discouraged". The non-applicability to defined types should be explicitly called out, for clarity.
== Section 11.2 Recommendation against using "include" is unclear or harmfulI think this was to describe how an over-zealous use of `include` may cause classes to be declared with the default parameters before a user may declare them with parameters. Or it could have been about cross-module class inclusion in public modules. What should we do with this section?
I don't think there is any over-zealousness problem associated with using 'include', unless it is with respect to declaring classes that are not directly required in the scope of the declaration. Needed classes should be declared, and that generally should be done via an 'include', 'require', or 'contain' call. (And note, too, that 'contain' and 'require' have all the same declaration semantics as 'include', but the current text ignores them.)
In fact, I think the guide is almost exactly backward on this matter. The style points that should be recommended are:All that can be well justified based on Puppet's design and implementation, though I grant that "if at all possible" is pretty wishy-washy. I'd go further with a style guide for my own site, but the things I'd add would be a bit more controversial.
- Classes and defined types should declare the classes on which they rely
- Data should generally be bound to classes via Puppet's Hiera-based automatic data-binding facility, instead of via resource-style class declarations. In particular,
- In modules, the resource style should never be be used to declare public classes of that or any other module.
- Everywhere, the 'include', 'require', and / or 'contain' functions should be used instead of resource-style class declarations if at all possible.
== Section 10.4 Chaining arrow syntax with only references, not declarationsAgreed. And perhaps that if there are line breaks around arrow syntax, they must only happen to the right of the arrow and not the left so that arrows are not "hidden" at the end of previous lines.
I'm missing it: how does allowing line breaks only to the right of a chain operator prevent it from being hidden at the end of a line? Shouldn't that be "left"?
Chaining resource declarations doesn't actually bother me, personally. I won't particularly resist the style guide discouraging that, but I'd be at least as well satisfied by a softer guideline. For example, "a chain operator should appear on the same line as its right-hand operand." Or the still-softer "a chain operator should appear either on the same line as its right-hand operand or on a line by itself."
== Section 12.1 $unique_name = $name is unclearI believe this was to describe how the continued use of $name throughout a define can lead to confusion, as $name has no strong semantic meaning. Thus a "good" example would be https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/listen.pp#L2 and a bad example would be... https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/vhost.pp (because $name is scattered throughout the define and has no definite meaning).
I don't think "unique_name" has any more or less clear of a meaning in such contexts than does "name". Any lack of clarity is about which entity the name belongs to, and describing it as "unique" doesn't really help with that.
Moreover, I observe that what you're saying the section is about is not at all how I read it. (Lack of clarity? Check.) I don't think we can talk about the wording details until we settle more generally what the section is trying to say. If you're confident about that (you don't sound it) then we can discuss the wording, but at this point my position would be that the section should just be deleted.
== "Style guide" vs "specification" discussion from jcbollingerTo paraphrase, "the 'language style guide' is written as a technical specification covering more than the language; it covers module structure and module contribution conduct. This is not 'style' and is beyond the scope of this document."In answer... we should change the title to something other than "The Puppet Language Style Guide" :). I personally feel that "Module Style Guide" would still encompass what is included here, when the above edits are taken into account.
A bona fide style guide is appropriate and wanted. Moreover, it is inappropriate to present a document that purports to be a general specification for how all modules must be implemented, when in fact there are many viable alternatives. PL has a lot of standing in this area, but not so much as to lay down hard general rules like that.
Instead of recasting the current document as something else, it should be split into at least two documents. One would be a true style guide (or even a "manual") describing PuppetLabs's official style for DSL code. Key there would be that any "must", "must not", or equivalent in it be explicitly in the context of "in order to comply with the style described in this document". Another document might be a module design and layout specification, perhaps for enforcement on modules published on the Forge. This second document might require the modules to which it pertains to comply with the style described in the separate style guide, so as to have the effect (in its scope) of a combined document.
== Section 12.1 $unique_name = $name is unclearI believe this was to describe how the continued use of $name throughout a define can lead to confusion, as $name has no strong semantic meaning. Thus a "good" example would be https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/listen.pp#L2 and a bad example would be... https://github.com/puppetlabs/puppetlabs-apache/blob/1.2.0/manifests/vhost.pp (because $name is scattered throughout the define and has no definite meaning).
I don't think "unique_name" has any more or less clear of a meaning in such contexts than does "name". Any lack of clarity is about which entity the name belongs to, and describing it as "unique" doesn't really help with that.
Moreover, I observe that what you're saying the section is about is not at all how I read it. (Lack of clarity? Check.) I don't think we can talk about the wording details until we settle more generally what the section is trying to say. If you're confident about that (you don't sound it) then we can discuss the wording, but at this point my position would be that the section should just be deleted.I do know what I want, but I'm not a great wordsmith :(. The point of the section was to say that "$name in a define doesn't have a semantic meaning, so if you're going to use $name for anything programatic then assign it to a semantically-meaningful variable for clarity's sake and use that instead." But if you think that's not really a useful pattern then we could delete the section.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f623ece2-cd9a-45f0-9a7a-ae3a4d758e2a%40googlegroups.com.