有没有办法为Chef资源的name属性指定默认值?

问题描述 投票:0回答:1

理想情况下,我希望能够做到:

resource_name :house

property :material, String, default: 'brick', name_property: true
...

这样我才能做到

house do
  ...
end

和material属性将设置为'brick',但这会导致错误消息:

A property cannot be both a name_property/name_attribute and have a default value ...

这很清楚。我有理由肯定我要求的是不可能的,但是,我可能也会错过另一种实现相同的方法,所以我想我会问。

ruby chef
1个回答
1
投票

不,你必须在名称级别本身。见https://github.com/chef/chef/blob/master/lib/chef/resource/apt_update.rb#L31

这应该非常谨慎地使用,这对于真正的全球单身人士来说是非常罕见的。

© www.soinside.com 2019 - 2024. All rights reserved.