mixlib-install 0.4.0 → 0.5.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: 7592663e9dc88898464abf226ad8b1e905331e23
4
- data.tar.gz: 689ed39a2569a84473a9fe542cd44340c2d82359
3
+ metadata.gz: ecaa8915b2caba7f9a5cf72b0764b911232a9ed4
4
+ data.tar.gz: b993b484009f8d4d27b18d3dbb3a92e6d8661273
5
5
  SHA512:
6
- metadata.gz: bc3f0cc2bc318043963135505b1a3a8c9bd34daec489d8cd6b642f35f5274825d545128a0b9744571f7e0bfc3ad2cb4572aa3c90670959bdd01b09f47cc366de
7
- data.tar.gz: 75411cd38ab03f9518d3b98f74f058d4ac9356da97356b11e79b42e759b4bdee787c46842fb2ba9549f89b61423b85f71035ef6ad3e121088f0bca14c34cf556
6
+ metadata.gz: c661c621177bbe5010f31245662b6481a09e01e0f9dbfb67f706bc0ff6aa292c337cc15d8200dd2c761798f2561e4d0230aee57e0facb648118d38aefeec37ee
7
+ data.tar.gz: f28da052b3f374e165e54161151cd9b3ae858b36579aa81038e944b826cf3037ac4f9c5b2bc0948d7e0fce8da717a9dea6c70e54d5dd7e8e2123464be3ee42db
@@ -36,14 +36,35 @@ module Mixlib
36
36
  attr_accessor :root
37
37
 
38
38
  attr_accessor :use_sudo
39
- attr_accessor :sudo_command
39
+
40
+ attr_reader :sudo_command
41
+
42
+ def sudo_command=(cmd)
43
+ if cmd.nil?
44
+ @use_sudo = false
45
+ else
46
+ @sudo_command = cmd
47
+ end
48
+ end
40
49
 
41
50
  attr_accessor :http_proxy
42
51
  attr_accessor :https_proxy
43
52
 
44
- attr_accessor :base_url
53
+ attr_accessor :omnibus_url
45
54
  attr_accessor :install_msi_url
46
55
 
56
+ VALID_INSTALL_OPTS = %w(omnibus_url
57
+ endpoint
58
+ http_proxy
59
+ https_proxy
60
+ install_flags
61
+ install_msi_url
62
+ nightlies
63
+ prerelease
64
+ project
65
+ use_sudo
66
+ sudo_command)
67
+
47
68
  def initialize(version, powershell = false, opts = {})
48
69
  @version = version
49
70
  @powershell = powershell
@@ -53,7 +74,7 @@ module Mixlib
53
74
  @prerelease = false
54
75
  @nightly = false
55
76
  @endpoint = "metadata"
56
- @base_url = "https://www.chef.io/chef/install.sh"
77
+ @omnibus_url = "https://www.chef.io/chef/install.sh"
57
78
  @use_sudo = true
58
79
  @sudo_command = "sudo -E"
59
80
 
@@ -90,7 +111,7 @@ module Mixlib
90
111
 
91
112
  [
92
113
  shell_var("chef_omnibus_root", root),
93
- shell_var("chef_omnibus_url", base_url),
114
+ shell_var("chef_omnibus_url", omnibus_url),
94
115
  shell_var("install_flags", flags.strip),
95
116
  shell_var("pretty_version", Util.pretty_version(version)),
96
117
  shell_var("sudo_sh", sudo("sh")),
@@ -120,31 +141,21 @@ module Mixlib
120
141
  }.join("\n")
121
142
  end
122
143
 
123
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
144
+ def validate_opts!(opt)
145
+ err_msg = ["#{opt} is not a valid option",
146
+ "valid options are #{VALID_INSTALL_OPTS.join(' ')}"].join(',')
147
+ fail ArgumentError, err_msg unless VALID_INSTALL_OPTS.include?(opt.to_s)
148
+ end
149
+
150
+ # rubocop:disable Metrics/MethodLength
124
151
  def parse_opts(opts)
125
152
  opts.each do |opt, setting|
153
+ validate_opts!(opt)
126
154
  case opt.to_s
127
- when "http_proxy"
128
- self.http_proxy = setting
129
- when "https_proxy"
130
- self.https_proxy = setting
131
- when "install_flags"
132
- self.install_flags = setting
133
- when "prerelease"
134
- self.prerelease = setting
135
- when "endpoint"
155
+ when 'project', 'endpoint'
136
156
  self.endpoint = metadata_endpoint_from_project(setting)
137
- when "base"
138
- self.base_url = setting
139
- when "nightlies"
140
- self.nightlies = setting
141
- when "sudo"
142
- self.use_sudo = setting
143
- when "sudo_command"
144
- self.use_sudo = true
145
- self.sudo_command = setting
146
- when "install_msi_url"
147
- self.install_msi_url = setting
157
+ else
158
+ send("#{opt.to_sym}=", setting)
148
159
  end
149
160
  end
150
161
  end
@@ -179,8 +190,8 @@ module Mixlib
179
190
  end
180
191
 
181
192
  def windows_metadata_url
182
- base = if base_url =~ %r{/install.sh$}
183
- "#{File.dirname(base_url)}/"
193
+ base = if omnibus_url =~ %r{/install.sh$}
194
+ "#{File.dirname(omnibus_url)}/"
184
195
  end
185
196
 
186
197
  url = "#{base}#{endpoint}"
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class Install
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler