I just read through lib/puppet/provider per your footnote 3. It looks a
little over-engineered. I'm not sure how to approach threading an argument
hash through that many layers. I'm not even sure why there are so many
layers of wrappers there.

Awesome that you're digging into the git vcsrepo module -- it's been on my
todo-list to fix a couple of cases where the exit code is important to
capture and use (e.g. rev-parse branch or tag name) to decide what to do
next (e.g. fetch --all), and the current code makes it painful :/

Cheers,
Aaron


On Fri, Feb 22, 2013 at 1:23 PM, Micah Anderson <[email protected]> wrote:

>
> Hi,
>
> I've made some changes to the vcsrepo module[0] provider. It all works
> fine, but I'm trying to improve it to be more in-line with how the
> original module works. The original module uses 'optional_commands'[1]
> to define the 'git' command and then when the provider needs to do
> something with git it uses a define called 'git_with_identity'[2] which
> makes sure that certain variables are set and then just runs git using
> the optional_commands methods.
>
> I want to do the same thing, but I want to operate on the exit code of
> the git command that I am running. So while the following works fine:
>
>   def valid_repo?
>     Dir.chdir(@resource.value(:path)){ system('git rev-parse > /dev/null
> 2>&1')}
>   end
>
> it is using system() to call 'git rev-parse' instead of
> 'git_with_identity'.
>
> If I simply change my 'system' above to 'git_with_identity', when 'git
> revparse' fails with a non-zero exit code, it causes puppet to fail.
>
> It seems like optional_commands eventually uses
> Puppet::Util::Execution[4] and that has the optional parameter
> 'failonfail', defaulting to 'true'. I am guessing that what I want to do
> is somehow toggle that so it wont fail, but I'm at a loss as to how.
>
> Any ideas or pointers to other providers that are doing this would be
> mighty appreciated!
>
> micah
>
>
> 0. https://github.com/puppetlabs/puppetlabs-vcsrepo
> 1.
> https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/master/lib/puppet/provider/vcsrepo/git.rb#L7
> 2.
> https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/master/lib/puppet/provider/vcsrepo/git.rb#L278
> 3. if you follow the indirection through this path:
>
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider.rb#L186-L201
>
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider.rb#L221-L238
>
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider.rb#L272
>
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/execution.rb
>
> --
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to