poise-languages 1.2.0 → 1.3.0

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: f4a05fa47de317277eae76e90f0e2f8fd4f03d72
4
- data.tar.gz: e3c4ef2901a9c2ccb9f0467334389060533448e2
3
+ metadata.gz: 6f6513d765b3d69409dbd7a4ae5e30d71a0b78c9
4
+ data.tar.gz: 73b6d0b35651da918deeee5ecfc6acdc726576a8
5
5
  SHA512:
6
- metadata.gz: dce25fe02f0b2c9c66764c19d1278d95262b0a2ae7aa2ff865a223baa21f6acc97df83ef22cd1e438e378ca9043f2bfca19d522c24e63be5818cae7394142557
7
- data.tar.gz: b0ec72f8eda800c9a0a0423920c5bd704697af0c4561431d3e30e14e471b495b9b240e6e2aa288b5f1fc38c19203d27a9e859ff9577ee8d16a97032f3e2d1cc5
6
+ metadata.gz: d600c8ede972ec0d5b5f63e6b0466539ec756844f85dcf41286fcc6335c7722567620d173d9668ae4dfa7edabfd9b63c8136bd1cb03e8e6ca4f350286cb0ac78
7
+ data.tar.gz: 72c3191bd757a71db694ff83bd41d71b31ec80ecc162789c7c8438f5d659766f5de3a785cf7bda66558ea546f56857a10684ef18ba5ab946ebe980acc1fcb899
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.3.0
4
+
5
+ * `%{machine_label}` is available in URL template for static download.
6
+ * Automatically retry `remote_file` downloads to handle transient HTTP failures.
7
+ * All `*_shell_out` language command helpers use `poise_shell_out` to set `$HOME`
8
+ and other environment variables by default.
9
+
3
10
  ## v1.2.0
4
11
 
5
12
  * Support for installing development headers with SCL providers.
@@ -16,7 +16,6 @@
16
16
 
17
17
  require 'shellwords'
18
18
 
19
- require 'chef/mixin/shell_out'
20
19
  require 'poise'
21
20
 
22
21
  require 'poise_languages/utils'
@@ -161,7 +160,7 @@ module PoiseLanguages
161
160
 
162
161
  # A mixin for providers that run language commands.
163
162
  module Provider
164
- include Chef::Mixin::ShellOut
163
+ include Poise::Utils::ShellOut
165
164
 
166
165
  private
167
166
 
@@ -171,16 +170,12 @@ module PoiseLanguages
171
170
  # @param name [Symbol] Language name.
172
171
  # @param command_args [Array] Arguments to `shell_out`.
173
172
  # @return [Mixlib::ShellOut]
174
- def language_command_shell_out(name, *command_args)
175
- options = if command_args.last.is_a?(Hash)
176
- command_args.pop.dup
177
- else
178
- {}
179
- end
173
+ def language_command_shell_out(name, *command_args, **options)
180
174
  # Inject our environment variables if needed.
175
+ options[:environment] ||= {}
181
176
  parent = new_resource.send(:"parent_#{name}")
182
177
  if parent
183
- options[:environment] = parent.send(:"#{name}_environment").merge(options[:environment] || {})
178
+ options[:environment].update(parent.send(:"#{name}_environment"))
184
179
  end
185
180
  # Inject other options.
186
181
  options[:timeout] ||= new_resource.timeout
@@ -193,7 +188,7 @@ module PoiseLanguages
193
188
  end
194
189
  Chef::Log.debug("[#{new_resource}] Running #{name} command: #{command.is_a?(Array) ? Shellwords.shelljoin(command) : command}")
195
190
  # Run the command
196
- shell_out(command, options)
191
+ poise_shell_out(command, options)
197
192
  end
198
193
 
199
194
  # Run a command using the configured language via `shell_out!`.
@@ -52,6 +52,7 @@ module PoiseLanguages
52
52
  version: options['static_version'],
53
53
  kernel: node['kernel']['name'].downcase,
54
54
  machine: node['kernel']['machine'],
55
+ machine_label: self.class.static_machine_label(node),
55
56
  }
56
57
  end
57
58
 
@@ -61,6 +62,7 @@ module PoiseLanguages
61
62
  attr_accessor :static_machines
62
63
  attr_accessor :static_url
63
64
  attr_accessor :static_strip_components
65
+ attr_accessor :static_retries
64
66
 
65
67
  def provides_auto?(node, resource)
66
68
  # Check that the version starts with our project name and the machine
@@ -77,6 +79,8 @@ module PoiseLanguages
77
79
  super.merge({
78
80
  # Path to install the package. Defaults to /opt/name-version.
79
81
  path: nil,
82
+ # Number of times to retry failed downloads.
83
+ retries: static_retries,
80
84
  # Full version number for use in interpolation.
81
85
  static_version: static_version(node, resource),
82
86
  # Value to pass to tar --strip-components.
@@ -86,17 +90,18 @@ module PoiseLanguages
86
90
  })
87
91
  end
88
92
 
89
- def static_options(name: nil, versions: [], machines: %w{linux-i686 linux-x86_64}, url: nil, strip_components: 1)
93
+ def static_options(name: nil, versions: [], machines: %w{linux-i686 linux-x86_64}, url: nil, strip_components: 1, retries: 5)
90
94
  raise PoiseLanguages::Error.new("Static archive URL is required, on #{self}") unless url
91
95
  self.static_name = name || provides.to_s
92
96
  self.static_versions = versions
93
97
  self.static_machines = Set.new(machines)
94
98
  self.static_url = url
95
99
  self.static_strip_components = strip_components
100
+ self.static_retries = retries
96
101
  end
97
102
 
98
103
  def static_version(node, resource)
99
- raw_version = resource.version.gsub(/^#{static_name}(-|$)/, '')
104
+ raw_version = resource.version.to_s.gsub(/^#{static_name}(-|$)/, '')
100
105
  if static_versions.include?(raw_version)
101
106
  raw_version
102
107
  else
@@ -39,6 +39,10 @@ module PoiseLanguages
39
39
  # Directory to install to.
40
40
  # @return [String]
41
41
  attribute(:path, kind_of: String, name_attribute: true)
42
+ # @!attribute download_retries
43
+ # Number of times to retry failed downloads. Defaults to 5.
44
+ # @return [Integer]
45
+ attribute(:download_retries, kind_of: Integer, default: 5)
42
46
  # @!attribute source
43
47
  # URL to download from.
44
48
  # @return [String]
@@ -112,6 +116,7 @@ module PoiseLanguages
112
116
  group 0
113
117
  mode '644'
114
118
  notifies :run, unpack_resource, :immediately
119
+ retries new_resource.download_retries
115
120
  end
116
121
  end
117
122
 
@@ -69,9 +69,9 @@ module PoiseLanguages
69
69
  # @return [String]
70
70
  def system_package_name
71
71
  # Look up all packages for this language on this platform.
72
- system_packages = node.value_for_platform(self.class.packages)
72
+ system_packages = self.class.packages && node.value_for_platform(self.class.packages)
73
73
  if !system_packages && self.class.default_package
74
- Chef::Log.debug("[#{new_resource}] No known packages for #{node['platform']} #{node['platform_version']}, defaulting to '#{self.class.default_package}'.")
74
+ Chef::Log.debug("[#{new_resource}] No known packages for #{node['platform']} #{node['platform_version']}, defaulting to '#{self.class.default_package}'.") if self.class.packages
75
75
  system_packages = Array(self.class.default_package)
76
76
  end
77
77
 
@@ -188,7 +188,7 @@ module PoiseLanguages
188
188
  define_method(:load_current_resource) do
189
189
  super().tap do |_|
190
190
  each_package do |package_name, new_version, current_version, candidate_version|
191
- unless candidate_version.start_with?(version)
191
+ unless candidate_version && candidate_version.start_with?(version)
192
192
  raise PoiseLanguages::Error.new("Package #{package_name} would install #{candidate_version}, which does not match #{version.empty? ? version.inspect : version}. Please set the package_name or package_version provider options.")
193
193
  end
194
194
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseLanguages
19
- VERSION = '1.2.0'
19
+ VERSION = '1.3.0'
20
20
  end
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.require_paths = %w{lib}
35
35
 
36
36
  spec.add_dependency 'halite', '~> 1.0'
37
- spec.add_dependency 'poise', '~> 2.3'
37
+ spec.add_dependency 'poise', '~> 2.5'
38
38
 
39
39
  spec.add_development_dependency 'poise-boiler', '~> 1.0'
40
40
  end
@@ -259,7 +259,7 @@ describe PoiseLanguages::Command::Mixin do
259
259
  recipe do
260
260
  poise_test 'test' do
261
261
  command 'foo'
262
- expect ['/which/mylang foo', {timeout: 900}]
262
+ expect ['/which/mylang foo', {environment:{}, timeout: 900}]
263
263
  end
264
264
  end
265
265
  it { run_chef }
@@ -293,7 +293,7 @@ describe PoiseLanguages::Command::Mixin do
293
293
  recipe do
294
294
  poise_test 'test' do
295
295
  command ['foo']
296
- expect [['/which/mylang', 'foo'], {timeout: 900}]
296
+ expect [['/which/mylang', 'foo'], {environment: {}, timeout: 900}]
297
297
  end
298
298
  end
299
299
  it { run_chef }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-languages
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.3'
33
+ version: '2.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.3'
40
+ version: '2.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: poise-boiler
43
43
  requirement: !ruby/object:Gem::Requirement