Class: Mixlib::Install::Options
- Inherits:
-
Object
- Object
- Mixlib::Install::Options
- Defined in:
- lib/mixlib/install/options.rb
Defined Under Namespace
Classes: InvalidOptions
Constant Summary collapse
- SUPPORTED_ARCHITECTURES =
%w{ aarch64 armv7l i386 powerpc ppc64 ppc64le s390x sparc universal x86_64 }
- SUPPORTED_CHANNELS =
[ :stable, :current, :unstable, ]
- SUPPORTED_SHELL_TYPES =
[ :ps1, :sh, ]
- SUPPORTED_OPTIONS =
[ :architecture, :channel, :platform, :platform_version, :product_name, :product_version, :shell_type, :platform_version_compatibility_mode, :include_metadata, :user_agent_headers, :install_command_options, ]
- SUPPORTED_WINDOWS_DESKTOP_VERSIONS =
%w{10}
- SUPPORTED_WINDOWS_NANO_VERSIONS =
%w{2016nano}
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original_platform_version ⇒ Object
readonly
Returns the value of attribute original_platform_version.
-
#supported_product_names ⇒ Object
readonly
Returns the value of attribute supported_product_names.
Instance Method Summary collapse
- #for_ps1? ⇒ Boolean (also: #for_windows?)
- #include_metadata? ⇒ Boolean
-
#initialize(options) ⇒ Options
constructor
A new instance of Options.
- #latest_version? ⇒ Boolean
- #partial_version? ⇒ Boolean
- #platform_info ⇒ Object
-
#resolve_platform_version_compatibility_mode! ⇒ Object
Calling this method will give queries more of an opportunity to collect compatible artifacts where there may not always be an exact match.
-
#set_platform_info(info) ⇒ Object
Set the platform info on the instance info [Hash] Hash with keys :platform, :platform_version and :architecture.
- #validate! ⇒ Object
- #validate_options! ⇒ Object
Constructor Details
#initialize(options) ⇒ Options
Returns a new instance of Options.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mixlib/install/options.rb', line 72 def initialize() @options = @errors = [] # Store original options in cases where we must remap @original_platform_version = [:platform_version] # Eval extra products definition extra_products = ENV.fetch("EXTRA_PRODUCTS_FILE", nil) unless extra_products.nil? PRODUCT_MATRIX.instance_eval(::File.read(extra_products), extra_products) end # Store supported product names @supported_product_names = PRODUCT_MATRIX.products resolve_platform_version_compatibility_mode! map_windows_versions! validate! end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
29 30 31 |
# File 'lib/mixlib/install/options.rb', line 29 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/mixlib/install/options.rb', line 29 def @options end |
#original_platform_version ⇒ Object (readonly)
Returns the value of attribute original_platform_version.
29 30 31 |
# File 'lib/mixlib/install/options.rb', line 29 def original_platform_version @original_platform_version end |
#supported_product_names ⇒ Object (readonly)
Returns the value of attribute supported_product_names.
29 30 31 |
# File 'lib/mixlib/install/options.rb', line 29 def supported_product_names @supported_product_names end |
Instance Method Details
#for_ps1? ⇒ Boolean Also known as: for_windows?
116 117 118 |
# File 'lib/mixlib/install/options.rb', line 116 def for_ps1? platform == "windows" || shell_type == :ps1 end |
#include_metadata? ⇒ Boolean
139 140 141 |
# File 'lib/mixlib/install/options.rb', line 139 def .to_s == "true" end |
#latest_version? ⇒ Boolean
121 122 123 |
# File 'lib/mixlib/install/options.rb', line 121 def latest_version? product_version.to_sym == :latest end |
#partial_version? ⇒ Boolean
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/mixlib/install/options.rb', line 125 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 [: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 ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/mixlib/install/options.rb', line 156 def platform_info { platform: [:platform], platform_version: [:platform_version], architecture: [:architecture], } end |
#resolve_platform_version_compatibility_mode! ⇒ Object
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.
173 174 175 176 177 |
# File 'lib/mixlib/install/options.rb', line 173 def resolve_platform_version_compatibility_mode! unless [:platform_version_compatibility_mode] [:platform_version_compatibility_mode] = true if platform_info.values.none? end end |
#set_platform_info(info) ⇒ Object
Set the platform info on the instance info [Hash]
Hash with keys :platform, :platform_version and :architecture
148 149 150 151 152 153 154 |
# File 'lib/mixlib/install/options.rb', line 148 def set_platform_info(info) [:platform] = info[:platform] [:platform_version] = info[:platform_version] [:architecture] = info[:architecture] end |
#validate! ⇒ Object
101 102 103 |
# File 'lib/mixlib/install/options.rb', line 101 def validate! end |
#validate_options! ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mixlib/install/options.rb', line 105 def validate_architecture validate_product_names validate_channels validate_shell_type validate_user_agent_headers raise InvalidOptions, errors.join("\n") unless errors.empty? end |