class Mixlib::Install::Options
Constants
- SUPPORTED_ARCHITECTURES
- SUPPORTED_CHANNELS
- SUPPORTED_OPTIONS
- SUPPORTED_PRODUCT_NAMES
- SUPPORTED_SHELL_TYPES
- SUPPORTED_WINDOWS_DESKTOP_VERSIONS
- SUPPORTED_WINDOWS_NANO_VERSIONS
Attributes
errors[R]
options[R]
original_platform_version[R]
Public Class Methods
new(options)
click to toggle source
# File lib/mixlib/install/options.rb, line 73 def initialize(options) @options = options @errors = [] # Store original options in cases where we must remap @original_platform_version = options[:platform_version] resolve_platform_version_compatibility_mode! map_windows_versions! validate! end
Public Instance Methods
for_ps1?()
click to toggle source
# File lib/mixlib/install/options.rb, line 108 def for_ps1? platform == "windows" || shell_type == :ps1 end
Also aliased as: for_windows?
include_metadata?()
click to toggle source
# File lib/mixlib/install/options.rb, line 131 def include_metadata? include_metadata.to_s == "true" end
latest_version?()
click to toggle source
# File lib/mixlib/install/options.rb, line 113 def latest_version? product_version.to_sym == :latest end
partial_version?()
click to toggle source
# File lib/mixlib/install/options.rb, line 117 def partial_version? # If PartialSemVer is defined than the version of mixlib-versioning loaded can parse partial versions # Otherwise parsing a partial version will return nil is_partial = if defined?(Mixlib::Versioning::Format::PartialSemVer) # remove if there's a trailing period for mixlib-versioning compatibility options[:product_version] = product_version.chomp(".") if product_version.is_a? String Mixlib::Versioning.parse(product_version).is_a?(Mixlib::Versioning::Format::PartialSemVer) else !Mixlib::Versioning.parse(product_version) end !latest_version? && is_partial end
platform_info()
click to toggle source
# File lib/mixlib/install/options.rb, line 148 def platform_info { platform: options[:platform], platform_version: options[:platform_version], architecture: options[:architecture], } end
resolve_platform_version_compatibility_mode!()
click to toggle source
Calling this method will give queries more of an opportunity to collect compatible artifacts where there may not always be an exact match.
This option is set to false by default.
-
In cases where no platform options are configured it will set this option to true.
-
In cases where all platform options are configured it will remain false UNLESS the option has been configured to be true.
# File lib/mixlib/install/options.rb, line 165 def resolve_platform_version_compatibility_mode! unless options[:platform_version_compatibility_mode] options[:platform_version_compatibility_mode] = true if platform_info.values.none? end end
set_platform_info(info)
click to toggle source
Set the platform info on the instance info [Hash]
Hash with keys :platform, :platform_version and :architecture
# File lib/mixlib/install/options.rb, line 140 def set_platform_info(info) options[:platform] = info[:platform] options[:platform_version] = info[:platform_version] options[:architecture] = info[:architecture] validate_options! end
validate!()
click to toggle source
# File lib/mixlib/install/options.rb, line 93 def validate! validate_options! end
validate_options!()
click to toggle source
# File lib/mixlib/install/options.rb, line 97 def validate_options! validate_architecture validate_product_names validate_channels validate_shell_type validate_user_agent_headers validate_platform_options raise InvalidOptions, errors.join("\n") unless errors.empty? end
Private Instance Methods
all_or_none?(items)
click to toggle source
# File lib/mixlib/install/options.rb, line 247 def all_or_none?(items) items.all? || items.compact.empty? end
default_options()
click to toggle source
# File lib/mixlib/install/options.rb, line 173 def default_options { shell_type: :sh, platform_version_compatibility_mode: false, product_version: :latest, include_metadata: false, } end
map_windows_versions!()
click to toggle source
# File lib/mixlib/install/options.rb, line 241 def map_windows_versions! return unless for_windows? options[:platform_version] = Util.map_windows_version(platform_version) end
validate_architecture()
click to toggle source
# File lib/mixlib/install/options.rb, line 182 def validate_architecture unless architecture.nil? || SUPPORTED_ARCHITECTURES.include?(architecture) errors << <<-EOS Unknown architecture #{architecture}. Must be one of: #{SUPPORTED_ARCHITECTURES.join(", ")} EOS end end
validate_channels()
click to toggle source
# File lib/mixlib/install/options.rb, line 200 def validate_channels unless SUPPORTED_CHANNELS.include? channel errors << <<-EOS Unknown channel #{channel}. Must be one of: #{SUPPORTED_CHANNELS.join(", ")} EOS end end
validate_platform_options()
click to toggle source
# File lib/mixlib/install/options.rb, line 233 def validate_platform_options unless all_or_none?(platform_info.values) errors << <<-EOS Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details EOS end end
validate_product_names()
click to toggle source
# File lib/mixlib/install/options.rb, line 191 def validate_product_names unless SUPPORTED_PRODUCT_NAMES.include? product_name errors << <<-EOS Unknown product name #{product_name}. Must be one of: #{SUPPORTED_PRODUCT_NAMES.join(", ")} EOS end end
validate_shell_type()
click to toggle source
# File lib/mixlib/install/options.rb, line 209 def validate_shell_type unless SUPPORTED_SHELL_TYPES.include? shell_type errors << <<-EOS Unknown shell type. Must be one of: #{SUPPORTED_SHELL_TYPES.join(", ")} EOS end end
validate_user_agent_headers()
click to toggle source
# File lib/mixlib/install/options.rb, line 218 def validate_user_agent_headers error = nil if user_agent_headers if user_agent_headers.is_a? Array user_agent_headers.each do |header| error = "user agent headers can not have spaces." if header.include?(" ") end else error = "user_agent_headers must be an Array." end end errors << error if error end