Class: Chef::Utils::LicensingHandler
- Inherits:
-
Object
- Object
- Chef::Utils::LicensingHandler
- Defined in:
- lib/chef/utils/licensing_handler.rb
Constant Summary collapse
- 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
Instance Attribute Summary collapse
-
#license_key ⇒ Object
readonly
Returns the value of attribute license_key.
-
#license_type ⇒ Object
readonly
Returns the value of attribute license_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, type) ⇒ LicensingHandler
constructor
A new instance of LicensingHandler.
- #install_sh_url ⇒ Object
- #omnitruck_url ⇒ Object
Constructor Details
#initialize(key, type) ⇒ LicensingHandler
Returns a new instance of LicensingHandler.
16 17 18 19 |
# File 'lib/chef/utils/licensing_handler.rb', line 16 def initialize(key, type) @license_key = key @license_type = type end |
Instance Attribute Details
#license_key ⇒ Object (readonly)
Returns the value of attribute license_key.
14 15 16 |
# File 'lib/chef/utils/licensing_handler.rb', line 14 def license_key @license_key end |
#license_type ⇒ Object (readonly)
Returns the value of attribute license_type.
14 15 16 |
# File 'lib/chef/utils/licensing_handler.rb', line 14 def license_type @license_type end |
Class Method Details
.validate! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/utils/licensing_handler.rb', line 32 def validate! license_keys = ChefLicensing::LicenseKeyFetcher.fetch return new(nil, nil) if license_keys.blank? = ChefLicensing::Api::Describe.list({ license_keys: license_keys, }) new(.last.id, .last.license_type) end |
Instance Method Details
#install_sh_url ⇒ Object
27 28 29 |
# File 'lib/chef/utils/licensing_handler.rb', line 27 def install_sh_url format(omnitruck_url, "install.sh") end |
#omnitruck_url ⇒ Object
21 22 23 24 25 |
# File 'lib/chef/utils/licensing_handler.rb', line 21 def omnitruck_url url = OMNITRUCK_URLS[license_type] || LEGACY_OMNITRUCK_URL "#{url}/%s#{license_key ? "?license_id=#{license_key}" : ""}" end |