mixlib-install 1.0.2 → 1.0.3

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: f4bbebe8c34d32ee85913bbc2909706b61eae0c1
4
- data.tar.gz: 8bacb078f62eac0966167958adb11042aec45790
3
+ metadata.gz: 8fa0731a332dd953d20aa43e53480e804409aa0f
4
+ data.tar.gz: 6df34bf9b664cda250fd3c312980630a4e95c386
5
5
  SHA512:
6
- metadata.gz: 3b614b75aa5bafd8f8f75b472628f4a452a2c343d83df7738c1b5c02eceb615cf7fcc4bc50ccf01d7110551db7c84ea384c0571e9783195d309a01e5ea751177
7
- data.tar.gz: 6921b10c9c5d86b4cecd87ac2ddd88c319d115684d7afa8d6fa76973bf01ef8d9dd009beae092511b27698a07ca6380df86a154fd65c6fe79d9617e046d599f6
6
+ metadata.gz: 5f6455a5e05a9cd10cdf54600bc8fd2e7b95599cb64f4ee8021ffb53b721dc83d3d94bafae43c1d5dc9f234c3a6bd7e84b2b9d791daaaf4999e22fb24019340b
7
+ data.tar.gz: 72542b720536309e129357a835931e88812d3d973ab98fd6e2b38594f898931b37c71bb1713f40cd63c0906d872f05df3a705779ee7ca753beb6554eb841d82c
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [1.0.3]
4
+ ### Changed
5
+ - Artifactory credentials are no longer required. A designated account has been hard-coded as default.
6
+ - Exception is raised if Bintray can not find the version for channel/product.
7
+
8
+ ### Fixed
9
+ - freebsd 9 artifacts return chef.bintray.com based urls
10
+
3
11
  ## [1.0.2]
4
12
  ### Added
5
13
  - Use 32 bit windows artifacts for 64-bit, when there is no 64-bit native artifact.
data/README.md CHANGED
@@ -51,14 +51,11 @@ artifact.platform_version # => "10.10"
51
51
 
52
52
  ## Unstable channel
53
53
  The `:unstable` channel is currently only available when connected to Chef's internal network.
54
- Configure Artifactory access by setting the following environment variables:
55
- ```
56
- export ARTIFACTORY_USERNAME='username'
57
- export ARTIFACTORY_PASSWORD='password'
58
- ```
59
54
 
60
- ### Unstable channel specs
61
- Some spec examples are tagged `:unstable` and can only run when connected to Chef's internal network. These are excluded by default. To run the `:unstable` tests run: `rake unstable`.
55
+ ## Development
56
+ Since mixlib-install needs to interact with Bintray and Artifactory and since Artifactory instances are only available in Chef's network, this project uses [vcr](https://github.com/vcr/vcr).
57
+
58
+ VCR is a tool that helps cache and replay http responses. When these responses change or when you add more tests you might need to update cached responses. Check out [spec_helper.rb](https://github.com/chef/mixlib-install/blob/master/spec/spec_helper.rb) for instructions on how to do this.
62
59
 
63
60
  ## Contributing
64
61
 
data/Rakefile CHANGED
@@ -19,19 +19,7 @@ rescue LoadError
19
19
  end
20
20
 
21
21
  desc "Run all tests"
22
- task test: [:style, :spec, :unstable]
23
-
24
- desc "Run unstable channel tests"
25
- task "unstable" do
26
- if ENV["ARTIFACTORY_USERNAME"].nil? || ENV["ARTIFACTORY_PASSWORD"].nil?
27
- abort <<-EOS.gsub(/^\s+/, "")
28
- Must set ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD environment
29
- variables to run unstable tests
30
- EOS
31
- end
32
- Rake::Task["style"].invoke
33
- system("bundle exec rspec -t unstable")
34
- end
22
+ task test: [:style, :spec]
35
23
 
36
24
  desc "Run tests for Travis CI"
37
25
  task ci: [:style, :spec]
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "mixlib/install/backend/omnitruck"
20
19
  require "mixlib/install/backend/artifactory"
21
20
  require "mixlib/install/backend/bintray"
22
21
 
@@ -32,6 +32,11 @@ module Mixlib
32
32
 
33
33
  ENDPOINT = "http://artifactory.chef.co".freeze
34
34
 
35
+ # These credentials are read-only credentials in Chef's artifactory
36
+ # server which is only available in Chef's internal network.
37
+ ARTIFACTORY_USERNAME = "mixlib-install".freeze
38
+ ARTIFACTORY_PASSWORD = "%mKPtzbT1JH1wm333kjkkjs39oeuFLgZ8vNoOdLBPd)TZAJsURs9w0HloWR$l6h".freeze
39
+
35
40
  # Create filtered list of artifacts
36
41
  #
37
42
  # @return [Array<ArtifactInfo>] list of artifacts for the configured
@@ -174,8 +179,8 @@ items.find(
174
179
  def client
175
180
  @client ||= ::Artifactory::Client.new(
176
181
  endpoint: endpoint,
177
- username: ENV["ARTIFACTORY_USERNAME"],
178
- password: ENV["ARTIFACTORY_PASSWORD"]
182
+ username: ARTIFACTORY_USERNAME,
183
+ password: ARTIFACTORY_PASSWORD
179
184
  )
180
185
  end
181
186
 
@@ -193,10 +198,7 @@ the endpoint is correct and there is an open connection to Chef's private networ
193
198
  MSG
194
199
  rescue ::Artifactory::Error::HTTPError => e
195
200
  if e.code == 401 && e.message =~ /Bad credentials/
196
- raise AuthenticationError, <<-MSG
197
- Artifactory server denied credentials. Verify ARTIFACTORY_USERNAME and
198
- ARTIFACTORY_PASSWORD environment variables are configured properly.
199
- MSG
201
+ raise AuthenticationError, "Artifactory server denied credentials."
200
202
  else
201
203
  raise e
202
204
  end
@@ -38,15 +38,14 @@ module Mixlib
38
38
  class Backend
39
39
  class Bintray < Base
40
40
  class UnknownArchitecture < StandardError; end
41
-
42
- ENDPOINT = "https://bintray.com/api/v1/".freeze
43
-
41
+ class VersionNotFound < StandardError; end
44
42
  # Bintray credentials for api read access. These are here intentionally.
45
43
  BINTRAY_USERNAME = "mixlib-install@chef".freeze
46
-
47
44
  BINTRAY_PASSWORD = "a83d3a2ffad50eb9a2230f281a2e19b70fe0db2d".freeze
48
45
 
46
+ ENDPOINT = "https://bintray.com/api/v1/".freeze
49
47
  DOWNLOAD_URL_ENDPOINT = "https://packages.chef.io".freeze
48
+ COMPAT_DOWNLOAD_URL_ENDPOINT = "http://chef.bintray.com".freeze
50
49
 
51
50
  def endpoint
52
51
  @endpoint ||= ENV.fetch("BINTRAY_ENDPOINT", ENDPOINT)
@@ -114,15 +113,25 @@ module Mixlib
114
113
  #
115
114
  def bintray_artifacts
116
115
  version = options.latest_version? ? latest_version : options.product_version
117
- results = bintray_get("#{options.channel}/#{options.product_name}/versions/#{version}/files")
116
+ begin
117
+ results = bintray_get("#{options.channel}/#{options.product_name}/versions/#{version}/files")
118
+ rescue Net::HTTPServerException => e
119
+ if e.message =~ /404 "Not Found"/
120
+ raise VersionNotFound,
121
+ "Specified version (#{version}) not found for #{options.product_name} in #{options.channel} channel."
122
+ else
123
+ raise
124
+ end
125
+ end
118
126
 
119
127
  #
120
- # Delete .asc files
121
- # Also delete .pkg files which are uploaded along with dmg files for
128
+ # Delete files that we don't want as part of the artifact info array
129
+ # Windows: .asc files
130
+ # MAC OS _X: .pkg files which are uploaded along with dmg files for
122
131
  # some chef versions.
123
132
  #
124
- results.reject! do |r|
125
- r["name"].end_with?(".asc") || r["name"].end_with?(".pkg")
133
+ %w{ asc pkg }.each do |ext|
134
+ results.reject! { |r| r["name"].end_with?(".#{ext}") }
126
135
  end
127
136
 
128
137
  # Convert results to build records
@@ -182,8 +191,6 @@ module Mixlib
182
191
  def create_artifact(artifact_map)
183
192
  platform_info = parse_platform_info(artifact_map)
184
193
 
185
- url = "#{DOWNLOAD_URL_ENDPOINT}/#{options.channel}/#{artifact_map["path"]}"
186
-
187
194
  ArtifactInfo.new(
188
195
  sha1: artifact_map["sha1"],
189
196
  sha256: artifact_map["sha256"],
@@ -191,10 +198,36 @@ module Mixlib
191
198
  platform: platform_info[:platform],
192
199
  platform_version: platform_info[:platform_version],
193
200
  architecture: platform_info[:architecture],
194
- url: url
201
+ url: url(artifact_map)
195
202
  )
196
203
  end
197
204
 
205
+ #
206
+ # Creates the URL for the artifact.
207
+ #
208
+ # For some older platform & platform_version combinations we need to
209
+ # use COMPAT_DOWNLOAD_URL_ENDPOINT since these versions have an
210
+ # OpenSSL version that can not verify the DOWNLOAD_URL_ENDPOINT
211
+ # based urls
212
+ #
213
+ # @param artifact_map
214
+ # see #create_artifact for details.
215
+ #
216
+ # @return [String] url for the artifact
217
+ #
218
+ def url(artifact_map)
219
+ platform_info = parse_platform_info(artifact_map)
220
+
221
+ base_url = case "#{platform_info[:platform]}-#{platform_info[:platform_version]}"
222
+ when "freebsd-9"
223
+ COMPAT_DOWNLOAD_URL_ENDPOINT
224
+ else
225
+ DOWNLOAD_URL_ENDPOINT
226
+ end
227
+
228
+ "#{base_url}/#{options.channel}/#{artifact_map["path"]}"
229
+ end
230
+
198
231
  #
199
232
  # Parses platform info
200
233
  #
@@ -23,7 +23,6 @@ module Mixlib
23
23
  class Install
24
24
  class Options
25
25
  class InvalidOptions < ArgumentError; end
26
- class ArtifactoryCredentialsNotFound < StandardError; end
27
26
 
28
27
  attr_reader :options
29
28
 
@@ -50,7 +49,6 @@ module Mixlib
50
49
 
51
50
  def validate!
52
51
  validate_options!
53
- validate_unstable_channel! if for_artifactory?
54
52
  end
55
53
 
56
54
  def validate_options!
@@ -139,15 +137,6 @@ Must be one of: #{SUPPORTED_SHELL_TYPES.join(", ")}
139
137
  end
140
138
  end
141
139
 
142
- def validate_unstable_channel!
143
- if ENV["ARTIFACTORY_USERNAME"].nil? || ENV["ARTIFACTORY_PASSWORD"].nil?
144
- raise ArtifactoryCredentialsNotFound,
145
- <<-EOS
146
- Must set ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD environment variables
147
- when using the unstable channel.
148
- EOS
149
- end
150
- end
151
140
  end
152
141
  end
153
142
  end
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.3"
27
27
  spec.add_development_dependency "pry"
28
- spec.add_development_dependency "sinatra"
28
+ spec.add_development_dependency "vcr"
29
+ spec.add_development_dependency "webmock"
29
30
  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: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-31 00:00:00.000000000 Z
12
+ date: 2016-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: artifactory
@@ -110,7 +110,21 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: sinatra
113
+ name: vcr
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
114
128
  requirement: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - ">="