chef-api 0.7.0 → 0.7.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/lib/chef-api.rb +0 -3
- data/lib/chef-api/connection.rb +2 -1
- data/lib/chef-api/defaults.rb +27 -2
- data/lib/chef-api/resources/partial_search.rb +1 -1
- data/lib/chef-api/resources/search.rb +1 -1
- data/lib/chef-api/version.rb +1 -1
- data/spec/unit/defaults_spec.rb +25 -4
- data/spec/unit/resources/base_spec.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e22717c3690474e0b8d8dc2e49662ae7541c9dd
|
4
|
+
data.tar.gz: b77f6c57956db9b6b9e06ee677171fa26bf39ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c1d17608e4670595086eef399b4ee6108f987546f6124c82ffe7e7a3bbd16fce2015bda69e2f860ea4cc1275e07d7ecfd2d88834fb521ebf391dfe230703d8
|
7
|
+
data.tar.gz: dfa5c1c5a75e2f75c1b7dc6c4e0346774aecd664f6ea4103b8d12dd531338f091628b1ac7e7829a3cea59db5b53266f77f55c145c16cee41adee684e6dd5cd3b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# ChefAPI Changelog
|
2
2
|
|
3
|
+
## v0.7.1 (2017-08-06)
|
4
|
+
|
5
|
+
- Don't set nil `JSON.create_id` as it's unnecessary in recent versions
|
6
|
+
of the JSON library
|
7
|
+
- Avoid ArgumentError when no HOME environment variable is set
|
8
|
+
- Add Resource::Organization proxy
|
9
|
+
- Update all comments to point to the correct Docs site URLs
|
10
|
+
|
3
11
|
## v0.6.0 (2016-05-05)
|
4
12
|
|
5
13
|
- Remove support for Ruby 1.9
|
data/Gemfile
CHANGED
data/lib/chef-api.rb
CHANGED
data/lib/chef-api/connection.rb
CHANGED
@@ -7,7 +7,7 @@ module ChefAPI
|
|
7
7
|
#
|
8
8
|
# Connection object for the ChefAPI API.
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://docs.chef.io/api_chef_server.html
|
11
11
|
#
|
12
12
|
class Connection
|
13
13
|
class << self
|
@@ -47,6 +47,7 @@ module ChefAPI
|
|
47
47
|
proxy :roles, 'Resource::Role'
|
48
48
|
proxy :search, 'Resource::Search'
|
49
49
|
proxy :users, 'Resource::User'
|
50
|
+
proxy :organizations, 'Resource::Organization'
|
50
51
|
|
51
52
|
#
|
52
53
|
# Create a new ChefAPI Connection with the given options. Any options
|
data/lib/chef-api/defaults.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'chef-api/version'
|
2
|
+
require 'pathname'
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
module ChefAPI
|
@@ -24,8 +25,32 @@ module ChefAPI
|
|
24
25
|
#
|
25
26
|
# @return [Hash]
|
26
27
|
def config
|
27
|
-
path =
|
28
|
-
@config ||=
|
28
|
+
path = config_path
|
29
|
+
@config ||= path.exist? ? JSON.parse(path.read) : {}
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Pathname to configuration file, or a blank Pathname.
|
34
|
+
#
|
35
|
+
# @return [Pathname] an expanded Pathname or a non-existent Pathname
|
36
|
+
def config_path
|
37
|
+
if result = chef_api_config_path
|
38
|
+
Pathname(result).expand_path
|
39
|
+
else
|
40
|
+
Pathname('')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# String representation of path to configuration file
|
46
|
+
#
|
47
|
+
# @return [String, nil] Path to config file, or nil
|
48
|
+
def chef_api_config_path
|
49
|
+
ENV['CHEF_API_CONFIG'] || if ENV.key?('HOME')
|
50
|
+
'~/.chef-api'
|
51
|
+
else
|
52
|
+
nil
|
53
|
+
end
|
29
54
|
end
|
30
55
|
|
31
56
|
#
|
data/lib/chef-api/version.rb
CHANGED
data/spec/unit/defaults_spec.rb
CHANGED
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module ChefAPI
|
4
4
|
describe Defaults do
|
5
|
+
before(:each) do
|
6
|
+
subject.instance_variable_set(:@config, nil)
|
7
|
+
end
|
8
|
+
|
5
9
|
context 'without a config file' do
|
6
10
|
before(:each) do
|
7
11
|
allow(subject).to receive(:config).and_return(Hash.new)
|
@@ -16,15 +20,32 @@ module ChefAPI
|
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
23
|
+
context 'without a config file and no ENV vars to find it' do
|
24
|
+
around do |example|
|
25
|
+
old_conf = ENV.delete('CHEF_API_CONFIG')
|
26
|
+
old_home = ENV.delete('HOME')
|
27
|
+
example.run
|
28
|
+
ENV['CHEF_API_CONFIG'] = old_conf
|
29
|
+
ENV['HOME'] = old_home
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns the default without errors' do
|
33
|
+
expect { subject.config }.not_to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the default which is the empty hash' do
|
37
|
+
expect(subject.config).to eq({})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
19
41
|
context 'with a config file' do
|
20
42
|
before(:each) do
|
21
|
-
|
22
|
-
allow(File).to receive(:exist?).with(anything()).and_return(true)
|
23
|
-
allow(File).to receive(:read).and_return("{\n"\
|
43
|
+
config_content = "{\n"\
|
24
44
|
"\"CHEF_API_ENDPOINT\": \"test_endpoint\",\n" \
|
25
45
|
"\"CHEF_API_USER_AGENT\": \"test_user_agent\"\n" \
|
26
46
|
"}"
|
27
|
-
)
|
47
|
+
path = instance_double(Pathname, read: config_content, exist?: true)
|
48
|
+
allow(subject).to receive(:config_path).and_return(path)
|
28
49
|
end
|
29
50
|
|
30
51
|
it 'returns the overridden value for endpoint' do
|
@@ -20,7 +20,9 @@ module ChefAPI
|
|
20
20
|
|
21
21
|
describe '.collection_path' do
|
22
22
|
it 'raises an exception if the collection name is not set' do
|
23
|
-
expect {
|
23
|
+
expect {
|
24
|
+
described_class.collection_path
|
25
|
+
}.to raise_error(ArgumentError, 'collection_path not set for Class')
|
24
26
|
end
|
25
27
|
|
26
28
|
it 'sets the collection name' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logify
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.6.
|
147
|
+
rubygems_version: 2.6.12
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: A Chef API client in Ruby
|