gpt4 book ai didi

ruby - 我如何将 '-t azure://' 目标传递到 ruby​​ inspec 脚本中?

转载 作者:行者123 更新时间:2023-12-03 02:28:34 24 4
gpt4 key购买 nike

如果在我的脚本中我想使用在容器中运行的 ruby​​ 库(不是 inspec 二进制文件)来测试 azure 资源:

def my_resource_groups
rg = Inspec::Runner.new(conf={:vendor_cache=>'/app'})
rg.add_target('/app/profiles/azure')
rg.run
end

my_resource_groups()

使用此 inspec.yml 定义

name: inspector
title: Azure InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8d1c7dde8cdd0c9c5d8c4cd86cbc7c5" rel="noreferrer noopener nofollow">[email protected]</a>
license: Apache-2.0
summary: An InSpec Compliance Profile For Azure
version: 0.1.0
inspec_version: '>= 2.2.7'
depends:
- name: inspec-azure
url: https://github.com/inspec/inspec-azure/archive/master.tar.gz

这个测试:

title "Azure Resource group spike"

control 'azure_resource_groups' do
describe azure_resource_group do
its('names') { should include 'my_resource_group1' }
end
end

我得到:

Skipping profile: 'inspector' on unsupported platform: 'debian/10.7'.

如何将等效的 -t azure:// 参数传递给我的 ruby​​ 脚本,就像我这样做一样:

sudo docker run \
-v /home/vagrant/scratch/share:/share \
-e AZURE_CLIENT_SECRET="some_secret" \
-e AZURE_CLIENT_ID="some_client_id" \
-e AZURE_TENANT_ID="some_tenant_id" \
-e AZURE_SUBSCRIPTION_ID="some_subscription_id" \
chef/inspec \
exec /share/inspector \
-t azure:// \
--chef-license=accept

最佳答案

以防万一其他人遇到这个麻烦,请在实例化它时将选项作为映射传递到运行器对象中。 (请注意供应商缓存也已整理)

def my_resource_groups
rg = Inspec::Runner.new({:target=>'azure://',:vendor_cache=>'/app'})
rg.add_target('/app/profiles/azure')
rg.run
end

my_resource_groups()

关于ruby - 我如何将 '-t azure://' 目标传递到 ruby​​ inspec 脚本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66013869/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com