omnijack 0.2.0 → 1.0.0.rc.1

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.
@@ -5,12 +5,12 @@
5
5
  "prerelease": false,
6
6
  "nightlies": false,
7
7
  "expected": {
8
- "url": "https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.2.2-1_amd64.deb",
9
- "filename": "chefdk_0.2.2-1_amd64.deb",
10
- "version": "0.2.2",
8
+ "url": "https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.3.0-1_amd64.deb",
9
+ "filename": "chefdk_0.3.0-1_amd64.deb",
10
+ "version": "0.3.0",
11
11
  "build": "1",
12
- "md5": "1b097776840aa10f092063d1579bf155",
13
- "sha256": "a6384851473779d3b0d0bedc509607b924751ea3b356e7df4b9c7ab16dd25788"
12
+ "md5": "8c658c64df47a60dcd52f5c9399c3833",
13
+ "sha256": "88e84dfdf6ed16b1018d76f033a176a13c845a86de2f00ad733112b92c98bff0"
14
14
  }
15
15
  },
16
16
  {
@@ -40,12 +40,12 @@
40
40
  "prerelease": false,
41
41
  "nightlies": true,
42
42
  "expected": {
43
- "url": "https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.2.2%2B20140918085104.git.23.997cf31-1_amd64.deb",
44
- "filename": "chefdk_0.2.2+20140918085104.git.23.997cf31-1_amd64.deb",
45
- "version": "0.2.2+20140918085104.git.23.997cf31",
43
+ "url": "https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.3.0%2B20141008085108-1_amd64.deb",
44
+ "filename": "chefdk_0.3.0+20141008085108-1_amd64.deb",
45
+ "version": "0.3.0+20141008085108",
46
46
  "build": "1",
47
- "md5": "424793c215d387041a9d620eeab1ed34",
48
- "sha256": "801d36aa94aa452dbe81c05eb4422fb022e2e7cba3d35a67f02cfa7416ac628f"
47
+ "md5": "d19b2f5b24389fe3fd95927f372c5ec1",
48
+ "sha256": "9f28c7d4425b08424b9a810bf77240cb6449a1449ac5de1c552f2c77b265ed23"
49
49
  }
50
50
  },
51
51
  {
@@ -120,7 +120,7 @@
120
120
  }
121
121
  },
122
122
  {
123
- "platform": {"name": "windows", "version": "2008r2" },
123
+ "platform": {"name": "windows", "version": "6.1.7600" },
124
124
  "version": "0.2.2",
125
125
  "prerelease": false,
126
126
  "nightlies": false,
@@ -134,7 +134,7 @@
134
134
  }
135
135
  },
136
136
  {
137
- "platform": {"name": "windows", "version": "2012" },
137
+ "platform": {"name": "windows", "version": "6.2.9200" },
138
138
  "version": "0.2.2",
139
139
  "prerelease": false,
140
140
  "nightlies": false,
@@ -23,19 +23,19 @@ class Chef
23
23
  # namespace.
24
24
  class Exceptions
25
25
 
26
- # Backcompat with Chef::ShellOut code:
27
- require 'mixlib/shellout/exceptions'
28
-
29
- def self.const_missing(const_name)
30
- if const_name == :ShellCommandFailed
31
- Chef::Log.warn("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed")
32
- called_from = caller[0..3].inject("Called from:\n") {|msg, trace_line| msg << " #{trace_line}\n" }
33
- Chef::Log.warn(called_from)
34
- Mixlib::ShellOut::ShellCommandFailed
35
- else
36
- super
37
- end
38
- end
26
+ # # Backcompat with Chef::ShellOut code:
27
+ # require 'mixlib/shellout/exceptions'
28
+
29
+ # def self.const_missing(const_name)
30
+ # if const_name == :ShellCommandFailed
31
+ # Chef::Log.warn("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed")
32
+ # called_from = caller[0..3].inject("Called from:\n") {|msg, trace_line| msg << " #{trace_line}\n" }
33
+ # Chef::Log.warn(called_from)
34
+ # Mixlib::ShellOut::ShellCommandFailed
35
+ # else
36
+ # super
37
+ # end
38
+ # end
39
39
 
40
40
  class Application < RuntimeError; end
41
41
  class Cron < RuntimeError; end
@@ -118,6 +118,10 @@ class Chef
118
118
  class InvalidDataBagPath < ArgumentError; end
119
119
  class DuplicateDataBagItem < RuntimeError; end
120
120
 
121
+ class PowershellCmdletException < RuntimeError; end
122
+
123
+ class CannotDetermineHomebrewOwner < Package; end
124
+
121
125
  # A different version of a cookbook was added to a
122
126
  # VersionedRecipeList than the one already there.
123
127
  class CookbookVersionConflict < ArgumentError ; end
@@ -179,6 +183,8 @@ class Chef
179
183
 
180
184
  class ChildConvergeError < RuntimeError; end
181
185
 
186
+ class NoProviderAvailable < RuntimeError; end
187
+
182
188
  class MissingRole < RuntimeError
183
189
  NULL = Object.new
184
190
 
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnijack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Hartman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-19 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ohai
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: json
14
+ name: multi_json
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -203,17 +189,19 @@ files:
203
189
  - features/support/env.rb
204
190
  - lib/omnijack.rb
205
191
  - lib/omnijack/config.rb
206
- - lib/omnijack/list.rb
207
- - lib/omnijack/metadata.rb
208
- - lib/omnijack/platforms.rb
192
+ - lib/omnijack/endpoint.rb
193
+ - lib/omnijack/endpoint/list.rb
194
+ - lib/omnijack/endpoint/metadata.rb
195
+ - lib/omnijack/endpoint/platforms.rb
209
196
  - lib/omnijack/project.rb
210
197
  - lib/omnijack/project/metaprojects.rb
211
198
  - lib/omnijack/version.rb
212
199
  - omnijack.gemspec
213
200
  - spec/omnijack/config_spec.rb
214
- - spec/omnijack/list_spec.rb
215
- - spec/omnijack/metadata_spec.rb
216
- - spec/omnijack/platforms_spec.rb
201
+ - spec/omnijack/endpoint/list_spec.rb
202
+ - spec/omnijack/endpoint/metadata_spec.rb
203
+ - spec/omnijack/endpoint/platforms_spec.rb
204
+ - spec/omnijack/endpoint_spec.rb
217
205
  - spec/omnijack/project/angry_chef_spec.rb
218
206
  - spec/omnijack/project/chef_container_spec.rb
219
207
  - spec/omnijack/project/chef_dk_spec.rb
@@ -242,9 +230,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
230
  version: 1.9.3
243
231
  required_rubygems_version: !ruby/object:Gem::Requirement
244
232
  requirements:
245
- - - ">="
233
+ - - ">"
246
234
  - !ruby/object:Gem::Version
247
- version: '0'
235
+ version: 1.3.1
248
236
  requirements: []
249
237
  rubyforge_project:
250
238
  rubygems_version: 2.4.1
@@ -261,9 +249,10 @@ test_files:
261
249
  - features/step_definitions/project.rb
262
250
  - features/support/env.rb
263
251
  - spec/omnijack/config_spec.rb
264
- - spec/omnijack/list_spec.rb
265
- - spec/omnijack/metadata_spec.rb
266
- - spec/omnijack/platforms_spec.rb
252
+ - spec/omnijack/endpoint/list_spec.rb
253
+ - spec/omnijack/endpoint/metadata_spec.rb
254
+ - spec/omnijack/endpoint/platforms_spec.rb
255
+ - spec/omnijack/endpoint_spec.rb
267
256
  - spec/omnijack/project/angry_chef_spec.rb
268
257
  - spec/omnijack/project/chef_container_spec.rb
269
258
  - spec/omnijack/project/chef_dk_spec.rb
data/lib/omnijack/list.rb DELETED
@@ -1,94 +0,0 @@
1
- # Encoding: UTF-8
2
- #
3
- # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
- #
5
- # Copyright (C) 2014, Jonathan Hartman
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require 'json'
20
- require 'open-uri'
21
- require_relative 'config'
22
- require_relative '../omnijack'
23
-
24
- class Omnijack
25
- # A class for representing an Omnitruck full list object
26
- #
27
- # @author Jonathan Hartman <j@p4nt5.com>
28
- class List < Omnijack
29
- include Config
30
-
31
- #
32
- # Make list items accessible via methods
33
- #
34
- # @param [Symbol] method_id
35
- #
36
- def method_missing(method_id, args = nil)
37
- args.nil? && to_h[method_id] || super
38
- end
39
-
40
- #
41
- # Make list items accessible via hash keys
42
- #
43
- # @param [Symbol] key
44
- # @return [String, NilClass]
45
- #
46
- def [](key)
47
- to_h[key]
48
- end
49
-
50
- #
51
- # Offer a hash representation of the list
52
- #
53
- # @return [Hash]
54
- #
55
- def to_h
56
- # TODO: Use a Mash -- some keys are better off addressed as strings
57
- JSON.parse(raw_data, symbolize_names: true)
58
- end
59
-
60
- #
61
- # Use the raw data string as a string representation
62
- #
63
- define_method(:to_s) { raw_data }
64
-
65
- private
66
-
67
- #
68
- # Fetch the raw list from the configured URI
69
- #
70
- # @return [String]
71
- #
72
- def raw_data
73
- @raw_data ||= api_url.open.read
74
- end
75
-
76
- #
77
- # Construct the full API query URL from base + endpoint
78
- #
79
- # @return [URI::HTTP, URI::HTTPS]
80
- #
81
- def api_url
82
- @api_url ||= URI.parse(::File.join(base_url, endpoint))
83
- end
84
-
85
- #
86
- # Return the API endpoint for the package list of this project
87
- #
88
- # @return [String]
89
- #
90
- def endpoint
91
- OMNITRUCK_PROJECTS[name][:endpoints][:package_list]
92
- end
93
- end
94
- end
@@ -1,238 +0,0 @@
1
- # Encoding: UTF-8
2
- #
3
- # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
- #
5
- # Copyright (C) 2014, Jonathan Hartman
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require 'ohai'
20
- require 'open-uri'
21
- require_relative 'config'
22
- require_relative '../omnijack'
23
-
24
- class Omnijack
25
- # A class for representing an Omnitruck metadata object
26
- #
27
- # @author Jonathan Hartman <j@p4nt5.com>
28
- class Metadata < Omnijack
29
- include ::Chef::Mixin::ParamsValidate
30
- include Config
31
-
32
- def initialize(name, args = {})
33
- super
34
- args.each { |k, v| send(k, v) unless v.nil? } unless args.nil?
35
- to_h
36
- end
37
-
38
- #
39
- # Set up an accessor method for each piece of metadata
40
- #
41
- METADATA_ATTRIBUTES.each do |a|
42
- define_method(a) { to_h[a] }
43
- end
44
- define_method(:filename) { to_h[:filename] }
45
- define_method(:build) { to_h[:build] }
46
-
47
- #
48
- # Make metadata accessible via hash keys
49
- #
50
- # @param [Symbol] key
51
- # @return [String, NilClass]
52
- #
53
- def [](key)
54
- to_h[key]
55
- end
56
-
57
- #
58
- # Offer a hash representation of the metadata
59
- #
60
- # @return [Hash]
61
- #
62
- def to_h
63
- raw_metadata.split("\n").each_with_object({}) do |line, hsh|
64
- key = line.split[0].to_sym
65
- val = line.split[1]
66
- val = true if val == 'true'
67
- val = false if val == 'false'
68
- hsh[key] = val
69
- key == :url && hsh.merge!(parse_url_data(val)) && version(hsh[:version])
70
- end
71
- end
72
-
73
- #
74
- # Use the raw metadata string as a string representation
75
- #
76
- define_method(:to_s) { raw_metadata }
77
-
78
- #
79
- # The version of the project
80
- #
81
- # @param [String, NilClass] arg
82
- # @return [String]
83
- #
84
- def version(arg = nil)
85
- set_or_return(:version, arg, kind_of: String, default: 'latest')
86
- end
87
-
88
- #
89
- # Whether to enable prerelease and/or nightly packages
90
- #
91
- # @param [TrueClass, FalseClass, NilClass] arg
92
- # @return [TrueClass, FalseClass]
93
- #
94
- [:prerelease, :nightlies].each do |m|
95
- define_method(m) do |arg = nil|
96
- set_or_return(m, arg, kind_of: [TrueClass, FalseClass], default: false)
97
- end
98
- end
99
-
100
- #
101
- # The name of the desired platform
102
- #
103
- # @param [String, NilClass]
104
- # @return [String]
105
- #
106
- def platform(arg = nil)
107
- set_or_return(:platform, arg, kind_of: String, default: node[:platform])
108
- end
109
-
110
- #
111
- # The version of the desired platform
112
- #
113
- # @param [String, NilClass] arg
114
- # @return [String]
115
- #
116
- def platform_version(arg = nil)
117
- # TODO: The platform version parser living in `node` means passing e.g.
118
- # '10.9.2' here won't result in it being shortened to '10.9'
119
- set_or_return(:platform_version,
120
- arg,
121
- kind_of: String,
122
- default: node[:platform_version])
123
- end
124
-
125
- #
126
- # The machine architecture of the desired platform
127
- #
128
- # @param [String, NilClass]
129
- # @return [String]
130
- #
131
- def machine_arch(arg = nil)
132
- set_or_return(:machine_arch,
133
- arg,
134
- kind_of: String,
135
- default: node[:kernel][:machine])
136
- end
137
-
138
- private
139
-
140
- #
141
- # Fetch the raw metadata from the configured URI
142
- #
143
- # @return [String]
144
- #
145
- def raw_metadata
146
- @raw_metadata ||= api_url.open.read
147
- end
148
-
149
- #
150
- # Construct the full API query URL from base + endpoint + params
151
- #
152
- # @return [URI::HTTP, URI::HTTPS]
153
- #
154
- def api_url
155
- @api_url ||= URI.parse(
156
- File.join(base_url, "#{endpoint}?#{URI.encode_www_form(query_params)}")
157
- )
158
- end
159
-
160
- #
161
- # Convert all the metadata attrs into params Omnitruck understands
162
- #
163
- # @return [Hash]
164
- #
165
- def query_params
166
- { v: version,
167
- prerelease: prerelease,
168
- nightlies: nightlies,
169
- p: platform,
170
- pv: platform_version,
171
- m: machine_arch }
172
- end
173
-
174
- #
175
- # Return the API endpoint for the metadata of this project
176
- #
177
- # @return [String]
178
- #
179
- def endpoint
180
- OMNITRUCK_PROJECTS[name][:endpoints][:metadata]
181
- end
182
-
183
- #
184
- # Fetch and return node data from Ohai
185
- #
186
- # @return [Mash]
187
- #
188
- def node
189
- unless @node
190
- @node = Ohai::System.new.all_plugins('platform')[0].data
191
- case @node[:platform]
192
- when 'mac_os_x'
193
- @node[:platform_version] = platform_version_mac_os_x
194
- when 'windows'
195
- @node[:platform_version] = platform_version_windows
196
- end
197
- end
198
- @node
199
- end
200
-
201
- #
202
- # Apply special logic for the version of an OS X platform
203
- #
204
- # @return [String]
205
- #
206
- def platform_version_mac_os_x
207
- node[:platform_version].match(/^[0-9]+\.[0-9]+/).to_s
208
- end
209
-
210
- #
211
- # Apply special logic for the version of a Windows platform
212
- #
213
- # @return [String]
214
- #
215
- def platform_version_windows
216
- # Make a best guess and assume a server OS
217
- # See: http://msdn.microsoft.com/en-us/library/windows/
218
- # desktop/ms724832(v=vs.85).aspx
219
- {
220
- '6.3' => '2012r2', '6.2' => '2012', '6.1' => '2008r2', '6.0' => '2008',
221
- '5.2' => '2003r2', '5.1' => 'xp', '5.0' => '2000'
222
- }[node[:platform_version].match(/^[0-9]+\.[0-9]+/).to_s]
223
- end
224
-
225
- #
226
- # Extract a filename, package version, and build from a package URL
227
- #
228
- # @param [String] url
229
- # @return [[String] filename, [String] version, [String] build]
230
- #
231
- def parse_url_data(url)
232
- filename = URI.decode(url).split('/')[-1]
233
- { filename: filename,
234
- version: filename.split('-')[-2].split('_')[-1],
235
- build: filename.split('-')[-1].split('.')[0].split('_')[0] }
236
- end
237
- end
238
- end
@@ -1,132 +0,0 @@
1
- # Encoding: UTF-8
2
- #
3
- # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
- #
5
- # Copyright (C) 2014, Jonathan Hartman
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative '../spec_helper'
20
- require_relative '../../lib/omnijack/platforms'
21
-
22
- describe Omnijack::Platforms do
23
- let(:name) { :chef_dk }
24
- let(:obj) { described_class.new(name) }
25
-
26
- describe '#method_missing' do
27
- let(:to_h) { { thing1: 'yup', thing2: 'nope', thing3: 'maybe' } }
28
-
29
- before(:each) do
30
- allow_any_instance_of(described_class).to receive(:to_h).and_return(to_h)
31
- end
32
-
33
- it 'sets up methods for the platform hash keys' do
34
- expect(obj.thing1).to eq('yup')
35
- expect(obj.thing2).to eq('nope')
36
- expect(obj.thing3).to eq('maybe')
37
- end
38
-
39
- it 'raises an exception otherwise' do
40
- expect { obj.thing4 }.to raise_error(NoMethodError)
41
- end
42
- end
43
-
44
- describe '#[]' do
45
- let(:to_h) { { thing1: 'yup', thing2: 'nope', thing3: 'maybe' } }
46
-
47
- before(:each) do
48
- allow_any_instance_of(described_class).to receive(:to_h).and_return(to_h)
49
- end
50
-
51
- it 'returns the correct data' do
52
- expect(obj[:thing1]).to eq('yup')
53
- expect(obj[:thing2]).to eq('nope')
54
- expect(obj[:thing3]).to eq('maybe')
55
- end
56
- end
57
-
58
- describe '#to_h' do
59
- context 'fake data' do
60
- let(:raw_data) { '{"thing1": "yup", "thing2": "nope"}' }
61
-
62
- before(:each) do
63
- allow_any_instance_of(described_class).to receive(:raw_data)
64
- .and_return(raw_data)
65
- end
66
-
67
- it 'returns the correct result hash' do
68
- expect(obj.to_h).to eq(thing1: 'yup', thing2: 'nope')
69
- end
70
- end
71
-
72
- context 'real data' do
73
- let(:obj) { described_class.new(:chef) }
74
-
75
- it 'returns the expected data' do
76
- expect(obj.to_h[:el]).to eq('Enterprise Linux')
77
- end
78
- end
79
- end
80
-
81
- describe '#to_s' do
82
- let(:raw_data) { 'SOME STUFF' }
83
-
84
- before(:each) do
85
- allow_any_instance_of(described_class).to receive(:raw_data)
86
- .and_return(raw_data)
87
- end
88
-
89
- it 'returns the raw HTTP GET string' do
90
- expect(obj.to_s).to eq(raw_data)
91
- end
92
- end
93
-
94
- describe '#raw_data' do
95
- let(:read) { '{"thing1": "yup", "thing2": "nope"}' }
96
- let(:open) { double(read: read) }
97
-
98
- before(:each) do
99
- allow_any_instance_of(URI::HTTP).to receive(:open).and_return(open)
100
- end
101
-
102
- it 'returns a GET of the API URL' do
103
- res = obj
104
- expect(res.send(:raw_data)).to eq(read)
105
- expect(res.instance_variable_get(:@raw_data)).to eq(read)
106
- end
107
- end
108
-
109
- describe '#api_url' do
110
- let(:base_url) { 'http://example.com/chef' }
111
- let(:endpoint) { '/example_platform_names' }
112
-
113
- before(:each) do
114
- [:base_url, :endpoint].each do |i|
115
- allow_any_instance_of(described_class).to receive(i).and_return(send(i))
116
- end
117
- end
118
-
119
- it 'constructs a URL based on base + endpoint' do
120
- expected = URI.parse('http://example.com/chef/example_platform_names')
121
- expect(obj.send(:api_url)).to eq(expected)
122
- end
123
- end
124
-
125
- describe '#endpoint' do
126
- let(:name) { :chef_container }
127
-
128
- it 'returns the appropriate metadata endpoint' do
129
- expect(obj.send(:endpoint)).to eq('/chef_container_platform_names')
130
- end
131
- end
132
- end