mixlib-install 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4764a817f6f781c4fad2b870666b1bdf96c057f0
4
- data.tar.gz: 36350ca6f4849c9468d0af8492373eac5e8a6147
3
+ metadata.gz: 4893a11fa816d4a5f41a23ba5fc240581814e01c
4
+ data.tar.gz: b63a27ed56a22506d8d239e94fdaa5996a86d316
5
5
  SHA512:
6
- metadata.gz: e3fc2ba02d777c4dc5011d65a48643291373b4982b95b2160b551ff20b3cb929d7c2bf20635e3cafd9c92386b05c7229ccd646e265fbcf5c647ca864006e82ac
7
- data.tar.gz: c8b48e71d606e9b45058ba4b9b16f1d247b2ae272c4b3879a5c4dea2e043342162653e85078059658b1df392e5b0d5f46397627f9b7111ed1afb27db8bcde137
6
+ metadata.gz: 4e4fa265d321456e0eb32c805680965ba28b1022794863bdf4a8d2e82cb2bb86e2ebd567b1a909925255ad94b070623db658c49bb498b63d4d6c4ec2049b4eab
7
+ data.tar.gz: aff7a8bdfa4fd774209e0cca484304eddcae3e3af35ca55e41f50b1826a64781470486b73cdf2c312148f49a0246f4ccbc51e0a99e34d735e490caad11fc3fa7
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.1.5]
4
+ - Add `install_path` properties to the products inside PRODUCT_MATRIX.
5
+
3
6
  ## [2.1.4]
4
7
  - Fix Cumulus Linux and Cumulus Networks platform detection
5
8
 
data/README.md CHANGED
@@ -103,11 +103,22 @@ Mixlib::Install.available_versions("chef", "stable")
103
103
  # => ["12.13.3", "12.13.7"]
104
104
  ```
105
105
 
106
+ ### User-Agent Request Headers
107
+ By default, all requests made by `mixlib-install` will include a `User-Agent` request header as `mixlib-install/<version>`.
108
+ Additional `User-Agent` request headers can be added by setting the `user_agent_headers` option.
109
+ When you want to identify a product using mixlib-install as a dependency we recommend the format `product/version`.
110
+ ```ruby
111
+ options = {
112
+ channel: :stable,
113
+ product_name: 'chef',
114
+ user_agent_headers: ["my_product/1.2.3", "somethingelse"],
115
+ }
116
+ ```
117
+
106
118
  ### Collecting Software Dependencies and License Content
107
119
  Collecting software dependencies and license content for ArtifactInfo instances
108
120
  requires additional requests to the repository server. By default, collection is disabled.
109
121
  To return data for instance methods `software_dependencies` and `license_content`, the `include_metadata` option must be enabled.
110
-
111
122
  ```
112
123
  options = {
113
124
  channel: :current,
@@ -147,16 +147,32 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
147
147
  uri = URI.parse(endpoint)
148
148
  http = Net::HTTP.new(uri.host, uri.port)
149
149
  http.use_ssl = (uri.scheme == "https")
150
-
151
150
  full_path = File.join(uri.path, url)
152
- request = Net::HTTP::Get.new(full_path)
153
151
 
154
- res = http.request(request)
152
+ res = http.request(create_http_request(full_path))
155
153
 
156
154
  res.value
157
155
  JSON.parse(res.body)
158
156
  end
159
157
 
158
+ def create_http_request(full_path)
159
+ require "mixlib/install/version"
160
+
161
+ request = Net::HTTP::Get.new(full_path)
162
+
163
+ user_agents = ["mixlib-install/#{Mixlib::Install::VERSION}"]
164
+
165
+ if options.user_agent_headers
166
+ options.user_agent_headers.each do |header|
167
+ user_agents << header
168
+ end
169
+ end
170
+
171
+ request.add_field("User-Agent", user_agents.join(" "))
172
+
173
+ request
174
+ end
175
+
160
176
  def create_artifact(artifact_map)
161
177
  # set normalized platform and platform version
162
178
  platform, platform_version = normalize_platform(
@@ -39,6 +39,7 @@ module Mixlib
39
39
  :shell_type,
40
40
  :platform_version_compatibility_mode,
41
41
  :include_metadata,
42
+ :user_agent_headers,
42
43
  ]
43
44
 
44
45
  def initialize(options)
@@ -57,6 +58,7 @@ module Mixlib
57
58
  errors << validate_product_names
58
59
  errors << validate_channels
59
60
  errors << validate_shell_type
61
+ errors << validate_user_agent_headers
60
62
 
61
63
  unless errors.compact.empty?
62
64
  raise InvalidOptions, errors.join("\n")
@@ -132,6 +134,20 @@ Must be one of: #{SUPPORTED_SHELL_TYPES.join(", ")}
132
134
  end
133
135
  end
134
136
 
137
+ def validate_user_agent_headers
138
+ error = nil
139
+ if user_agent_headers
140
+ if user_agent_headers.is_a? Array
141
+ user_agent_headers.each do |header|
142
+ error = "user agent headers can not have spaces." if header.include?(" ")
143
+ end
144
+ else
145
+ error = "user_agent_headers must be an Array."
146
+ end
147
+ end
148
+
149
+ error
150
+ end
135
151
  end
136
152
  end
137
153
  end
@@ -29,6 +29,8 @@ module Mixlib
29
29
  :ctl_command,
30
30
  :package_name,
31
31
  :product_name,
32
+ :install_path,
33
+ :omnibus_project,
32
34
  ]
33
35
 
34
36
  #
@@ -49,7 +51,7 @@ module Mixlib
49
51
  if block.nil?
50
52
  if prop_string.nil?
51
53
  value = instance_variable_get("@#{prop}".to_sym)
52
- return nil if value.nil?
54
+ return default_value_for(prop) if value.nil?
53
55
 
54
56
  if value.is_a? String
55
57
  value
@@ -67,14 +69,16 @@ module Mixlib
67
69
  end
68
70
 
69
71
  #
70
- # Set omnibus_project when configured, otherwise fall back to
71
- # package_name
72
+ # Return the default values for DSL properties
72
73
  #
73
- def omnibus_project(value = nil)
74
- if value.nil?
75
- @omnibus_project || package_name
74
+ def default_value_for(prop)
75
+ case prop
76
+ when :install_path
77
+ "/opt/#{package_name}"
78
+ when :omnibus_project
79
+ package_name
76
80
  else
77
- @omnibus_project = value
81
+ nil
78
82
  end
79
83
  end
80
84
 
@@ -217,7 +221,20 @@ PRODUCT_MATRIX = Mixlib::Install::ProductMatrix.new do
217
221
  end
218
222
  omnibus_project "chef-server"
219
223
  ctl_command "chef-server-ctl"
220
- config_file "/etc/opscode/chef-server.rb"
224
+ config_file do |v|
225
+ if (v < version_for("12.0.0")) && (v > version_for("11.0.0"))
226
+ "/etc/chef-server/chef-server.rb"
227
+ else
228
+ "/etc/opscode/chef-server.rb"
229
+ end
230
+ end
231
+ install_path do |v|
232
+ if (v < version_for("12.0.0")) && (v > version_for("11.0.0"))
233
+ "/opt/chef-server"
234
+ else
235
+ "/opt/opscode"
236
+ end
237
+ end
221
238
  end
222
239
 
223
240
  product "chef-server-ha-provisioning" do
@@ -294,6 +311,7 @@ PRODUCT_MATRIX = Mixlib::Install::ProductMatrix.new do
294
311
  package_name "private-chef"
295
312
  ctl_command "private-chef-ctl"
296
313
  config_file "/etc/opscode/private-chef.rb"
314
+ install_path "/opt/opscode"
297
315
  end
298
316
 
299
317
  product "push-jobs-client" do
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "2.1.4"
3
+ VERSION = "2.1.5"
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.1.4
4
+ version: 2.1.5
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-10-20 00:00:00.000000000 Z
12
+ date: 2016-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: artifactory