How do I check if Chef's version mets a gem requirement from inside a recipe?

拜拜、爱过 提交于 2019-12-04 09:24:16

Alternatively, you can use Chef’s built-in version comparison mechanisms (available since at least Chef 12):

Chef::VersionConstraint.new('>= 14.0.0').include? Chef::VERSION

Use Gem::Requirement and Gem::Version:

Gem::Requirement.new("~> 10.14").satisfied_by?(Gem::Version.new(Chef::VERSION))

This returns a boolean value - true if Chef::VERSION satisfies ~> 10.14.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!