mixlib-install 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b9844b39b2a0f932cc0c28d8ea483257be98e66
4
- data.tar.gz: 6a57e3f38c78962adbbb4a49fb9af22f33689dfc
3
+ metadata.gz: 71d5046b449ed3757363647374ffc39eeb05f07c
4
+ data.tar.gz: ae951ab2c716f58ffa374fcfb0602bf610dfaf29
5
5
  SHA512:
6
- metadata.gz: 20883ba88a6dc6886422e4396fe4ef01340c905c7f1f81fd6d67800b83ede9856a0b975f93b24958c12c613831b0dbe326c7b0afd97d2d3483d5e3f1bcfa8092
7
- data.tar.gz: 2da868dcb318fd3973833004dc09235cae1b948771aab3fceba9a2fbda51262c5ac4e869ec091f96527079e2e099341bcbcd3c81d4f0040eb02065f55fd87ec0
6
+ metadata.gz: ba5b829af49cc93b5d25ae17f617641bdf9a02cf0bb614dbb76dca789af977a5daa0603d994a414dea4639d93a8638e281af7d5d6431db686d64a2b97eef5d2b
7
+ data.tar.gz: 515fedd4a41787f1dbee8e6e697846f595e2e166d4664a82fcc27d248d0de6189ebaf2436cc2e0150c48d5252fd2f08b23c03bc9614f530ac322c9c4cb276203
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.1.0]
4
+ - Added new attributes to ArtifactInfo
5
+ - product_name, product_description, license, license_content, software_dependencies
6
+ - Added static `#available_versions` method to API
7
+ - Architecture normalization cleanup
8
+ - Fixed race condition in acceptance suites
9
+
3
10
  ## [2.0.4]
4
11
  - Normalize auto detect platform architectures
5
12
 
data/README.md CHANGED
@@ -26,9 +26,9 @@ artifact.url
26
26
  ```ruby
27
27
  options = {
28
28
  channel: :current,
29
- product_name: 'chef',
30
- product_version: :latest
29
+ product_name: 'chef'
31
30
  }
31
+ # product_version: :latest is the default
32
32
 
33
33
  artifacts = Mixlib::Install.new(options).artifact_info
34
34
  # => [#<Mixlib::Install::ArtifactInfo>, ...]
@@ -70,16 +70,23 @@ artifact.platform_version # => "14.04"
70
70
  ```
71
71
 
72
72
  ### List the available versions for a product and channel
73
+ #### Instance method
73
74
  ```ruby
74
- # Note that this feature currently only works for :unstable channel
75
75
  options = {
76
- channel: :unstable,
76
+ channel: :stable,
77
77
  product_name: 'chef',
78
78
  }
79
79
 
80
80
  Mixlib::Install.new(options).available_versions
81
81
 
82
- # => ["12.13.3", "12.13.7", "12.13.8+20160721014124", "12.13.11+20160721165202"]
82
+ # => ["12.13.3", "12.13.7"]
83
+ ```
84
+
85
+ #### Static method
86
+ ```ruby
87
+ Mixlib::Install.available_versions("chef", "stable")
88
+
89
+ # => ["12.13.3", "12.13.7"]
83
90
  ```
84
91
 
85
92
  ## Development
@@ -1,4 +1,4 @@
1
- execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_ps1, 'install'\" > ../.acceptance_data/install.ps1" do
1
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_ps1, 'install'\" > ../.acceptance_data/powershell_install.ps1" do
2
2
  cwd node['chef-acceptance']['suite-dir']
3
3
  end
4
4
 
@@ -77,7 +77,7 @@ EOF
77
77
  }
78
78
 
79
79
  provisioner "file" {
80
- source = "../../.acceptance_data/install.ps1"
80
+ source = "../../.acceptance_data/powershell_install.ps1"
81
81
  destination = "/tmp/install.ps1"
82
82
  }
83
83
 
@@ -1,4 +1,4 @@
1
- execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'omnibus-toolchain', product_version: :latest, channel: :stable).install_command\" > ../.acceptance_data/install.sh" do
1
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.new(product_name: 'omnibus-toolchain', product_version: :latest, channel: :stable).install_command\" > ../.acceptance_data/ubuntu_install_command.sh" do
2
2
  cwd node['chef-acceptance']['suite-dir']
3
3
  end
4
4
 
@@ -65,7 +65,7 @@ resource "aws_instance" "mixlib_install_sh" {
65
65
  }
66
66
 
67
67
  provisioner "file" {
68
- source = "../../.acceptance_data/install.sh"
68
+ source = "../../.acceptance_data/ubuntu_install_command.sh"
69
69
  destination = "/tmp/install.sh"
70
70
  }
71
71
 
@@ -1,4 +1,4 @@
1
- execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_sh\" > ../.acceptance_data/install.sh" do
1
+ execute "bundle exec ruby -e \"require 'mixlib/install'; puts Mixlib::Install.install_sh\" > ../.acceptance_data/ubuntu_install.sh" do
2
2
  cwd node['chef-acceptance']['suite-dir']
3
3
  end
4
4
 
@@ -65,7 +65,7 @@ resource "aws_instance" "mixlib_install_sh" {
65
65
  }
66
66
 
67
67
  provisioner "file" {
68
- source = "../../.acceptance_data/install.sh"
68
+ source = "../../.acceptance_data/ubuntu_install.sh"
69
69
  destination = "/tmp/install.sh"
70
70
  }
71
71
 
data/ci/script.sh CHANGED
@@ -11,8 +11,6 @@ if [ "${TRAVIS_REPO_SLUG}" = "chef/mixlib-install" ]; then
11
11
  cd acceptance && export BUNDLE_GEMFILE=$PWD/Gemfile && /opt/chefdk/embedded/bin/bundle install && export APPBUNDLER_ALLOW_RVM=true
12
12
  # run acceptances tests and force cleanup
13
13
  # only testing ubuntu until issues with powershell suite resovled:
14
- # 1) inspec not finding chef package once connected (not reproducible locally)
15
- # 2) currently no way to mask password (sensitive true) AND know what the error is if inspec fails
16
- /opt/chefdk/embedded/bin/bundle exec chef-acceptance test ubuntu_install_command --force-destroy
17
- /opt/chefdk/embedded/bin/bundle exec chef-acceptance test ubuntu_install_sh --force-destroy
14
+ # - currently no way to mask password (sensitive true) AND know what the error is if inspec fails
15
+ /opt/chefdk/embedded/bin/bundle exec chef-acceptance test ubuntu --force-destroy
18
16
  fi
@@ -52,7 +52,25 @@ module Mixlib
52
52
  # @return [Array<String>] list of available versions for the given
53
53
  # product_name and channel.
54
54
  def available_versions
55
- Backend.available_versions(options)
55
+ self.class.available_versions(options.product_name, options.channel)
56
+ end
57
+
58
+ #
59
+ # List available versions
60
+ #
61
+ # @param [String] product name
62
+ #
63
+ # @param [String, Symbol] channel
64
+ #
65
+ # @return [Array<String>] list of available versions for the given
66
+ # product_name and channel.
67
+ def self.available_versions(product_name, channel)
68
+ Backend.available_versions(
69
+ Mixlib::Install::Options.new(
70
+ product_name: product_name,
71
+ channel: channel.to_sym
72
+ )
73
+ )
56
74
  end
57
75
 
58
76
  #
@@ -19,25 +19,31 @@
19
19
  module Mixlib
20
20
  class Install
21
21
  class ArtifactInfo
22
- attr_reader :url
23
- attr_reader :md5
24
- attr_reader :sha256
25
- attr_reader :sha1
26
- attr_reader :version
27
22
 
28
- attr_reader :platform
29
- attr_reader :platform_version
30
- attr_reader :architecture
23
+ ATTRIBUTES = %w{
24
+ architecture
25
+ license
26
+ license_content
27
+ md5
28
+ platform
29
+ platform_version
30
+ product_description
31
+ product_name
32
+ sha1
33
+ sha256
34
+ software_dependencies
35
+ url
36
+ version
37
+ }.freeze
38
+
39
+ # Dynamically create readers
40
+ ATTRIBUTES.each { |attribute| attr_reader attribute.to_sym }
31
41
 
32
42
  def initialize(data)
33
- @url = data[:url]
34
- @md5 = data[:md5]
35
- @sha256 = data[:sha256]
36
- @sha1 = data[:sha1]
37
- @version = data[:version]
38
- @platform = data[:platform]
39
- @platform_version = data[:platform_version]
40
- @architecture = data[:architecture]
43
+ # Create an instance variable for each attribute
44
+ ATTRIBUTES.each do |attribute|
45
+ instance_variable_set("@#{attribute}", data[attribute.to_sym])
46
+ end
41
47
  end
42
48
 
43
49
  def self.from_json(json, platform_info)
@@ -63,16 +69,8 @@ module Mixlib
63
69
  end
64
70
 
65
71
  def to_hash
66
- {
67
- url: url,
68
- md5: md5,
69
- sha256: sha256,
70
- sha1: sha1,
71
- version: version,
72
- platform: platform,
73
- platform_version: platform_version,
74
- architecture: architecture,
75
- }
72
+ # Create a Hash of the instance data
73
+ Hash[ATTRIBUTES.map { |attribute| [attribute.to_sym, eval(attribute)] }]
76
74
  end
77
75
 
78
76
  def clone_with(data)
@@ -186,7 +186,7 @@ module Mixlib
186
186
  case architecture
187
187
  when "amd64"
188
188
  "x86_64"
189
- when "x86", "i86pc", "i686"
189
+ when "i86pc", "i686"
190
190
  "i386"
191
191
  when "sun4u", "sun4v"
192
192
  "sparc"
@@ -158,10 +158,15 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
158
158
  end
159
159
 
160
160
  def create_artifact(artifact_map)
161
- platform, platform_version = normalize_platform(artifact_map["omnibus.platform"],
162
- artifact_map["omnibus.platform_version"])
161
+ # set normalized platform and platform version
162
+ platform, platform_version = normalize_platform(
163
+ artifact_map["omnibus.platform"],
164
+ artifact_map["omnibus.platform_version"]
165
+ )
163
166
 
164
- chef_standard_path = generate_chef_standard_path(options.channel,
167
+ # create the standardized file path
168
+ chef_standard_path = generate_chef_standard_path(
169
+ options.channel,
165
170
  artifact_map["omnibus.project"],
166
171
  artifact_map["omnibus.version"],
167
172
  platform,
@@ -169,18 +174,59 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
169
174
  artifact_map["filename"]
170
175
  )
171
176
 
177
+ # retrieve the metadata using the standardized path
178
+ begin
179
+ metadata = get("#{chef_standard_path}.metadata.json")
180
+ license_content = metadata["license_content"]
181
+ software_dependencies = metadata["version_manifest"]["software"]
182
+ rescue Net::HTTPServerException => e
183
+ if e.message =~ /404/
184
+ license_content, software_dependencies = nil
185
+ else
186
+ raise e
187
+ end
188
+ end
189
+
190
+ # create the download path with the correct endpoint
191
+ base_url = if use_compat_download_url_endpoint?(platform, platform_version)
192
+ COMPAT_DOWNLOAD_URL_ENDPOINT
193
+ else
194
+ endpoint
195
+ end
196
+
172
197
  ArtifactInfo.new(
173
- md5: artifact_map["omnibus.md5"],
174
- sha256: artifact_map["omnibus.sha256"],
175
- sha1: artifact_map["omnibus.sha1"],
176
- version: artifact_map["omnibus.version"],
177
- platform: platform,
178
- platform_version: platform_version,
179
- architecture: normalize_architecture(artifact_map["omnibus.architecture"]),
180
- url: chef_standard_path
198
+ architecture: normalize_architecture(artifact_map["omnibus.architecture"]),
199
+ license: artifact_map["omnibus.license"],
200
+ license_content: license_content,
201
+ md5: artifact_map["omnibus.md5"],
202
+ platform: platform,
203
+ platform_version: platform_version,
204
+ product_description: product_description,
205
+ product_name: options.product_name,
206
+ sha1: artifact_map["omnibus.sha1"],
207
+ sha256: artifact_map["omnibus.sha256"],
208
+ software_dependencies: software_dependencies,
209
+ url: "#{base_url}/#{chef_standard_path}",
210
+ version: artifact_map["omnibus.version"]
181
211
  )
182
212
  end
183
213
 
214
+ #
215
+ # For some older platform & platform_version combinations we need to
216
+ # use COMPAT_DOWNLOAD_URL_ENDPOINT since these versions have an
217
+ # OpenSSL version that can not verify the ENDPOINT based urls
218
+ #
219
+ # @return [boolean] use compat download url endpoint
220
+ #
221
+ def use_compat_download_url_endpoint?(platform, platform_version)
222
+ case "#{platform}-#{platform_version}"
223
+ when "freebsd-9", "el-5", "solaris2-5.9", "solaris2-5.10"
224
+ true
225
+ else
226
+ false
227
+ end
228
+ end
229
+
184
230
  private
185
231
 
186
232
  # Converts Array<Hash> where the Hash is a key pair and
@@ -194,28 +240,17 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
194
240
  end
195
241
 
196
242
  # Generates a chef standard download uri in the form of
197
- # http://endpoint/files/:channel/:project/:version/:platform/:platform_version/:file
243
+ # /files/:channel/:project/:version/:platform/:platform_version/:file
198
244
  def generate_chef_standard_path(channel, project, version, platform, platform_version, filename)
199
- # For some older platform & platform_version combinations we need to
200
- # use COMPAT_DOWNLOAD_URL_ENDPOINT since these versions have an
201
- # OpenSSL version that can not verify the ENDPOINT based urls
202
- base_url = case "#{platform}-#{platform_version}"
203
- when "freebsd-9", "el-5", "solaris2-5.9", "solaris2-5.10"
204
- COMPAT_DOWNLOAD_URL_ENDPOINT
205
- else
206
- endpoint
207
- end
208
-
209
- uri = []
210
- uri << base_url.sub(/\/$/, "")
211
- uri << "files"
212
- uri << channel
213
- uri << project
214
- uri << version
215
- uri << platform
216
- uri << platform_version
217
- uri << filename
218
- uri.join("/")
245
+ path = []
246
+ path << "files"
247
+ path << channel
248
+ path << project
249
+ path << version
250
+ path << platform
251
+ path << platform_version
252
+ path << filename
253
+ path.join("/")
219
254
  end
220
255
 
221
256
  def endpoint
@@ -225,6 +260,10 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
225
260
  def omnibus_project
226
261
  @omnibus_project ||= PRODUCT_MATRIX.lookup(options.product_name, options.product_version).omnibus_project
227
262
  end
263
+
264
+ def product_description
265
+ PRODUCT_MATRIX.lookup(options.product_name, options.product_version).product_name
266
+ end
228
267
  end
229
268
  end
230
269
  end
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "2.0.4"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May