Sha256: 491720a15d386f24a41646fcb0ff69ce0459d9bd5a3e4c6a17ac6113dfb6f2b1
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require_relative "licensing_config" class Chef class Utils class LicensingHandler LEGACY_OMNITRUCK_URL = "https://omnitruck.chef.io".freeze OMNITRUCK_URLS = { "free" => "https://chefdownload-trial.chef.io", "trial" => "https://chefdownload-trial.chef.io", "commercial" => "https://chefdownload-commerical.chef.io", }.freeze attr_reader :license_key, :license_type def initialize(key, type) @license_key = key @license_type = type end def omnitruck_url url = OMNITRUCK_URLS[license_type] || LEGACY_OMNITRUCK_URL "#{url}/%s#{license_key ? "?license_id=#{license_key}" : ""}" end def install_sh_url format(omnitruck_url, "install.sh") end class << self def validate! license_keys = begin ChefLicensing::LicenseKeyFetcher.fetch # If the env is airgapped or the local licensing service is unreachable, # the licensing gem will raise ChefLicensing::RestfulClientConnectionError. # In such cases, we are assuming the license is not available. rescue ChefLicensing::RestfulClientConnectionError [] end return new(nil, nil) if license_keys&.empty? licenses_metadata = ChefLicensing::Api::Describe.list({ license_keys: license_keys, }) new(licenses_metadata.last.id, licenses_metadata.last.license_type) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knife-18.6.13 | lib/chef/utils/licensing_handler.rb |