mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Enable persistence of license key and license server url in file when passed via test kitchen
Signed-off-by: Nik08 <nikita.mathur@progress.com>
This commit is contained in:
parent
7bd146d793
commit
d30cfdc3df
2 changed files with 6 additions and 2 deletions
|
@ -171,6 +171,8 @@ module Inspec
|
||||||
if Inspec::Dist::EXEC_NAME == "inspec"
|
if Inspec::Dist::EXEC_NAME == "inspec"
|
||||||
if Inspec::Telemetry::RunContextProbe.guess_run_context == "test-kitchen"
|
if Inspec::Telemetry::RunContextProbe.guess_run_context == "test-kitchen"
|
||||||
configure_licensing_config_for_kitchen(@conf)
|
configure_licensing_config_for_kitchen(@conf)
|
||||||
|
# Persist the license key in file when passed via test-kitchen
|
||||||
|
ChefLicensing.fetch_and_persist if @conf[:chef_license_key]
|
||||||
end
|
end
|
||||||
ChefLicensing.check_software_entitlement!
|
ChefLicensing.check_software_entitlement!
|
||||||
end
|
end
|
||||||
|
@ -188,6 +190,9 @@ module Inspec
|
||||||
Inspec::Telemetry.run_starting(runner: self, conf: @conf)
|
Inspec::Telemetry.run_starting(runner: self, conf: @conf)
|
||||||
load
|
load
|
||||||
run_tests(with)
|
run_tests(with)
|
||||||
|
rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError
|
||||||
|
Inspec::Log.error "#{Inspec::Dist::PRODUCT_NAME} cannot execute without valid licenses."
|
||||||
|
Inspec::UI.new.exit(:license_not_set)
|
||||||
rescue ChefLicensing::SoftwareNotEntitled
|
rescue ChefLicensing::SoftwareNotEntitled
|
||||||
Inspec::Log.error "License is not entitled to use InSpec."
|
Inspec::Log.error "License is not entitled to use InSpec."
|
||||||
Inspec::UI.new.exit(:license_not_entitled)
|
Inspec::UI.new.exit(:license_not_entitled)
|
||||||
|
|
|
@ -15,8 +15,7 @@ def configure_licensing_config_for_kitchen(opts = {})
|
||||||
# Reset Chef License server via kitchen when passed in kitchen.yml
|
# Reset Chef License server via kitchen when passed in kitchen.yml
|
||||||
opts["chef_license_server"] = opts["chef_license_server"].join(",") if opts["chef_license_server"].is_a? Array
|
opts["chef_license_server"] = opts["chef_license_server"].join(",") if opts["chef_license_server"].is_a? Array
|
||||||
unless opts["chef_license_server"].nil? || opts["chef_license_server"].empty?
|
unless opts["chef_license_server"].nil? || opts["chef_license_server"].empty?
|
||||||
config.license_server_url_check_in_file = true
|
ENV["CHEF_LICENSE_SERVER"] = opts["chef_license_server"]
|
||||||
config.license_server_url = opts["chef_license_server"]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Reset Chef License key via kitchen when passed in kitchen.yml
|
# Reset Chef License key via kitchen when passed in kitchen.yml
|
||||||
|
|
Loading…
Reference in a new issue