-
Notifications
You must be signed in to change notification settings - Fork 168
Warn instead of erroring when generating a cookbook with a hyphen in the name. #955
Warn instead of erroring when generating a cookbook with a hyphen in the name. #955
Conversation
…g, shown when a user is generating a cookbook with a hyphen in the cookbook name.
@@ -5,7 +5,6 @@ | |||
|
|||
**Implemented enhancements:** | |||
|
|||
- Do not allow hyphenated cookbook names to be generated [\#915](https://github.com/chef/chef-dk/pull/915) |
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.
this doesn't change history so we'd keep the 0.16 docs alone.
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.
Do you mean, leave these messages in and add a new entry for switching to a warning?
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.
when we do a release, we "auto" generate the changelog and releasenotes based on GH commits. So if this were merged, it would show up in 0.17.
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.
Basically you can leave these 2 files alone.
With the comments above in mind, I like this. |
👍 |
The change to disallow hyphens in the generator came about as part of a larger effort to remediate a recurring pain felt by many different people. Copy/pasting from the internal issue tracker to provide context: User StoryAs a creator of custom resources with the Chef DSL, I should be able to reference those custom resources by the default resource name, even if the cookbook name has hyphens, so that I can reference those custom resources by a predictable name. Background and causeIf a person has a cookbook with a dash in its name, e.g.
This will fail because hyphens aren't allowed in Ruby identifier names or, more specifically, because the Ruby parser interprets History and workaroundThe first found recorded report of this issue was was in reported in Dec. 2011, and a workaround was implemented: When compiling a resource, hyphens and other non-alphanumeric characters are replaced by underscores, so the author need only make a small adjustment:
This works today. Nevertheless, this issue is still reported by a (rightfully) confused person about once a year (1, 2, 3). These people are usually given the above advice (use underscores where your cookbook name has hyphens), which solves their immediate problem. The bigger pictureThe issue keeps coming up because we only ever explain it to those who get bitten. The only place our docs mention restrictions for cookbook names is in the Chef Style Guide. Until recently, Chef even use hyphens in cookbook names in some of our official tutorials and many of our own cookbooks. RemediationThe solution decided upon was to educate and, when possible, guide cookbook authors. To that end, the following changes were made, in different areas: Docs changes:
Learnchef changes:
Generator changes:
ConclusionWhile I don't believe it's necessary to change the Chef specification to fully disallow hyphens in cookbook names, I do believe that disallowing the use of hyphens in the generator is a useful guard that will reduce long-term confusion. In addition, because As such, while I appreciate the contribution very much, I am hard 👎 on this change. |
What would it take to move ChefDK over to a versioning model, similar to Chef itself? https://github.com/chef/chef-rfc/blob/master/rfc047-release-process.md I appreciate the background above, but I think we could have done better in three respects -
I filed my original concern from #915 as a support request and was largely fobbed off, and maybe this Pull Request isn't the right place to solve this either, what is the correct forum? |
@charlesjohnson thank you for the background on this. I understand, and am sympathetic to the situation, and support making it easier for you guys to handle The change in behavior is reasonable in a vacuum. However, as @agh mentions, where it's hurting us is that we internally have years of documentation, existing cookbooks, and automation code around naming practices that expect (and in many cases, require) hyphenated cookbook names to adhere to our internal specifications. So we're in a situation now where we must immediately change all of these things, re-educate out internal customers, rename existing cookbooks along with the concomitant role/doc/node changes, touching every node in our fleet with the best case outcome being 'nothing goes wrong'. Finally, the idea of putting in this level of effort to avoid having a "confused person about once a year" sticks in my craw. <-- I'm joking. A little bit. |
I would have rather preferred that chef-client required the resource name be always specified instead of trying to infer it from the cookbook name. |
I'm also not a fan of the change to make
There's varying degrees of convenience, and I get the pain and frustration we've felt in things like custom resources not allowing dashes in the cookbook name, and other potential hazards of having a dash in the name. However, precedent is established through years of people and teams establishing practices of using dashes in the name, and breaking their workflows feels like a bad UX to me. |
This is still open as a place to discuss the options. Again, to be very clear: Cookbooks with hyphenated names are allowed in Chef. There is no plan to disallow the usage of cookbooks with hyphenated names. People rely on cookbooks created with this convention, it has been an allowed practice for as long as there's been Chef, and this change would break the world. There is no plan to disallow the usage of cookbooks with hyphenated names. We hear loud and clear that this generator limitation feels too strict in its current implementation. As @jtimberman outlined above, we're looking at ways of achieving the goal of discouraging the use of hyphens in the cookbook generator without disabling them completely. Unfortunately, it's unlikely that the change to loosen this restriction will land in the ChefDK slated for release on August 17th, but we'll aim for September. |
I just hit the bug in 'chef generate cookbook' where instead of actually generating the cookbook, it bombs out complaining about completely legal dashes in the cookbook name. The solution being to change the generate cookbook name to have underscores instead of dashes in order to get it to work, then manually renaming the directory and editing all the files it creates to change the underscores back to dashes is a ridiculous exercise. I whole-heartedly agree with the above comments that this heavy-handed method of getting the occasional annually confused individual to not footgun himself is breaking existing workflows, like ours. There is too much history around dashes in cookbook names. Let's find another way, please. |
Just gonna copy/paste myself again:
|
👍 |
1 similar comment
👍 |
We're electing to make this a warning now because we feel like that's the best way forward at the moment. @charlesjohnson is not around to defend the new prompt UX proposed, however, so this may show back up as a prompt in the future. We'll consider it carefully when we do. In the meantime, we place a higher priority on making it possible for users to use |
Changes the error message introduced in #915 to a warning, shown when a user is generating a cookbook with a hyphen in the name.