ruby 自定义Logs in Logs Chef

to94eoyn  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(118)

鲁比/厨师/菜鸟在这里。
我们正在使用techchef来测试用户在Linux中的存在性。
当运行类似于

describe user(username) do
      it "should exist" do
        # The existence check itself is included in the custom description.
        expect(subject.exists?).to eq(true)
      end
    end

它会打印以下消息。

User user1 is expected to exist

有没有什么方法可以隐藏或自定义消息?
谢谢

mzmfm0qo

mzmfm0qo1#

Inspec支持reporters自定义输出。我并不完全清楚您希望从输出中更改什么,但如果您想要更简洁的东西,progressprogress-bar报告器似乎是您可能需要的。

inspec exec example_profile --reporter progress

看起来它会给你给予经典的点的级数。
如果要自定义该行的输出,请在https://github.com/inspec/inspec/blob/main/lib/inspec/resources/users.rb#L314的XML中定义User类
它只有一个简单的to_s方法。
您可以在设置中覆盖该方法。比如说,

module Inspec::Resources
  class User
    def to_s
      "User (redacted)"
    end
  end
end

相关问题