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

lazy doesn't work with 'action' attribute #3615

Closed
docwhat opened this issue Jun 29, 2015 · 7 comments
Closed

lazy doesn't work with 'action' attribute #3615

docwhat opened this issue Jun 29, 2015 · 7 comments
Labels
Type: Enhancement Adds new functionality.

Comments

@docwhat
Copy link
Contributor

docwhat commented Jun 29, 2015

This recipe code doesn't work:

directory('/tmp/foobar') do
  action lazy { [:create, :delete].sample }
end

The code in the {} is just random code for the example. I know it is useless.

I expected it to work, but instead I get:

NoMethodError: undefined method `to_sym' for #<Chef::DelayedEvaluator:0x00000004b1b5d0>
@coderanger
Copy link
Contributor

Action is not actually an attribute, but 👍 for this being supported anyway.

@lamont-granquist lamont-granquist added this to the Help Wanted milestone Jul 1, 2015
@pu239ppy
Copy link

pu239ppy commented Jul 2, 2015

Forgive me if my commentary may seem ignorant I am new to both Chef and Ruby

Encountered this issue as well recently, at first glance my naive assumption was that I could modify action in chef/lib/chef/resource.rb to pass arg through set_or_return would unwind the DelayedEvaluator as I assumed is the purpose in other resource definition that accept lazy such as chef/lib/chef/resource/template.rb variables. Then pass it to the rest of the function code but that
did not work, instead it just returned DelayedEvaluator again

@docwhat what version/commit are you running?

@docwhat
Copy link
Contributor Author

docwhat commented Jul 9, 2015

This was in chef 12.4.0.

sempervictus pushed a commit to sempervictus/chef that referenced this issue Jul 13, 2015
Fixes chef#3615

Addressed by checking the action param of self.action for Resource
for a response to :call. If found, action.call.to_sym is used
instead of the original action.to_sym which doesn't work on a proc.
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 25, 2017
tomhughes added a commit to openstreetmap/chef that referenced this issue Mar 17, 2019
@zedtux
Copy link

zedtux commented Aug 7, 2019

This is still true today with version 15.1.36.

@sempervictus
Copy link

Their CLA nonsense prevented me from getting the fix merged. We just have it in our base cookbook. Since this issue was created, chef has basically become the red headed step child of devops. We still use actively, but vendors like IBM and their own stepchild, redhat back the "declarative" modalities stating that IT people are too stupid to write actual code (seriously). Meanwhile no corp wants to sign that cla mess either, pay for silly addons only needed because the platform can't be expanded with these functions via FOSS, meaning so many community fixes and improvements don't hit master. In the history books of comp sci, chef will be a sad allegory about the lawyers leading the horse to a desert in search of water for fear of rain.

@zedtux
Copy link

zedtux commented Aug 8, 2019

@sempervictus is there a way to implement it via a gem which would extends Chef?

@lamont-granquist why did you closed that issue?

@lock
Copy link

lock bot commented Aug 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

No branches or pull requests

7 participants