- From: Noah Kantrowitz <
>
- To: Jesse Nelson <
>
- Cc: Scott Sanders <
>, Andrea Campi <
>, Akzhan Abdulin <
>, Mike <
>, Avishai Ish-Shalom <
>, Chef Dev <
>
- Subject: [chef-dev] Re: Re: Re: Re: Re: Re: Re: ::File notation
- Date: Tue, 16 Apr 2013 14:02:58 -0700
Yeah, inside LWRPs is enough of an advanced user-case to not be a worry. I
think Andrea pointed out the important bit, it used to be a problem for
normal recipe code but was fixed as part of other structural changes a while
ago and we all just didn't notice and kept repeating the ::File pattern.
--Noah
On Apr 16, 2013, at 2:01 PM, Jesse Nelson wrote:
>
If you're writing a provider and you don't grok namespaces you might
>
benefit from educating yourself. Is the expectation that admins are writing
>
LWRP's without at least reading a basic introduction to ruby ?
>
>
It would seem to me that they would want in most cases to actually use
>
chefs File more often than ::File or even FileUtils for most of the
>
operations at this level in LWRP.
>
>
Chef::Resource::File makes perfect sense to me, but
>
Chef::Resource::FileResource seem quite redundant. I rather keep the
>
internals concise. If its a common issue then you can probe tell if someone
>
is trying to use Chef::Resource::File or ::File in the Chef::Resource::File
>
by the way they call it, and raise a nice message explaining that you
>
probably meant to use ::File.
>
>
my $0.02
>
>
>
>
>
On Tue, Apr 16, 2013 at 1:40 PM, Scott Sanders
>
<
>
>
wrote:
>
I believe this affects resources and providers, not recipes.
>
>
% grep -r 'class File ' *
>
chef/provider/file.rb: class File < Chef::Provider
>
chef/resource/file.rb: class File < Chef::Resource
>
>
>
Scott Sanders | Tech Operations | 803.767.0060 | @scott_sanders
>
taximagic : http://taximagic.com | sedanmagic : http://sedanmagic.com
>
>
>
On Tue, Apr 16, 2013 at 4:37 PM, Andrea Campi
>
<
>
>
wrote:
>
BTW, I was writing my thoughts on this and fired up chef-shell to try it.
>
And guess what, this works like a charm in recipe_mode without any ::
>
>
chef:recipe > file "test" do
>
chef:recipe > not_if { File.exists?("test") }
>
chef:recipe ?> end
>
>
Are we even sure this is still a problem or are we cargo-culting something
>
that is in the past?!
>
>
>
>
>
On Tue, Apr 16, 2013 at 8:31 PM, Akzhan Abdulin
>
<
>
>
wrote:
>
Noah, I suppose that it MUST be a choice of core team. This is a missed
>
usability issue.
>
>
>
2013/4/16 Noah Kantrowitz
>
<
>
>
Make a patch and open a ticket and I'm sure btm and crew will be glad to
>
take a look :) It might need to wait for a major release since it would be
>
a backwards-incompatible change, but this would only affect people
>
subclassing the file resource I think, which should be somewhat rare so
>
maybe we can just put out a warning.
>
>
--Noah
>
>
On Apr 16, 2013, at 11:25 AM, Akzhan Abdulin wrote:
>
>
> Mike, take a note that recipe authors aren't ruby pro's (more
>
> administrators than programmers). So we need to keep recipe syntax as
>
> simple as can.
>
>
>
> File.exists? phrase is more intuitive than ::File.exists? one. No
>
> namespace collision issue in mind.
>
>
>
>
>
>
>
> 2013/4/16 Mike
>
> <
>
>
> So we're back to me not understanding the problem that Akzhan is stating.
>
>
>
> On Tue, Apr 16, 2013 at 1:51 PM, Noah Kantrowitz
>
> <
>
>
> wrote:
>
> > Yep, the issue is that recipe code is executed in the Chef::Recipe
>
> > namespace, so "File" gets you Chef::File. Not sure there is a
>
> > workaround given Ruby's structure for name lookups.
>
> >
>
> > --Noah
>
> >
>
> > On Apr 16, 2013, at 10:18 AM, Mike wrote:
>
> >
>
> >> I don't understand.
>
> >>
>
> >> By using ::File, aren't you guaranteeing that you're using the root
>
> >> namespace?
>
> >>
>
> >> On Tue, Apr 16, 2013 at 12:56 PM, Akzhan Abdulin
>
> >> <
>
>
> >> wrote:
>
> >>> Hello Chiefs,
>
> >>>
>
> >>> I have insight, - Chef classes should never be named as system ones.
>
> >>>
>
> >>> We need to eliminate ::File and so on notation.
>
> >>>
>
> >>> Yours sincerely,
>
> >>> Akzhan.
>
> >>>
>
> >>>
>
> >>> 2013/4/16 Avishai Ish-Shalom
>
> >>> <
>
>
> >>>>
>
> >>>> inline_recipe "test" do
>
> >>>>
>
> >>>> block do
>
> >>>> log "testing resource group"
>
> >>>>
>
> >>>> file "/tmp/test1" do
>
> >>>>
>
> >>>> mode "0600"
>
> >>>>
>
> >>>> end
>
> >>>> end
>
> >>>> action :nothing
>
> >>>>
>
> >>>> notifies :write, "log[test]"
>
> >>>>
>
> >>>> only_if { ::File.exists? "/tmp/test2" }
>
> >>>>
>
> >>>> end
>
> >>>>
>
> >>>>
>
> >>>>
>
> >>>> https://github.com/avishai-ish-shalom/chef-inline-recipe/blob/master/recipes/default.rb
>
> >>>>
>
> >>>>
>
> >>>
>
> >
>
>
>
>
>
>
>
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail
- [chef-dev] Re: Re: RE: Re: Re: Re: Re: ::File notation, (continued)
- Message not available
- [chef-dev] Re: Re: Re: Re: Re: ::File notation, Scott Sanders, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: ::File notation, Andrea Campi, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: Re: ::File notation, Noah Kantrowitz, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: Re: Re: ::File notation, Daniel DeLeo, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: Re: Re: Re: ::File notation, AJ Christensen, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: Re: ::File notation, Jesse Nelson, 04/16/2013
- [chef-dev] Re: Re: Re: Re: Re: Re: Re: ::File notation, Noah Kantrowitz, 04/16/2013
Archive powered by MHonArc 2.6.16.