knife-api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +4 -7
- data/LICENSE.txt +1 -0
- data/README.md +5 -0
- data/Rakefile +1 -1
- data/knife-api.gemspec +13 -11
- data/lib/knife/api/version.rb +2 -1
- data/lib/knife/api.rb +52 -43
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1e51c37cdc8fa59d64ac86b2a6113d3bcbeaea
|
4
|
+
data.tar.gz: f4760fd287804caf1fdea752f7769a346375a81b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6de226eb15c0b2eca1167e58ab9aea712e5c6479efc5038046a6fdae9310d813c8b5d5bef1b01520020a512b27728bdc068d5df82427c8fc128dec208a5c4a4b
|
7
|
+
data.tar.gz: a0c878bca2f89ad902b1acb67cfbba8314e2a670c17bc36475ba9c9b92cff73c21b3f047141181bd9cd868fa307010710334d01670af82bae05d42bb36f8cf74
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'chef-zero', '3.1
|
4
|
-
|
5
|
-
gem '
|
6
|
-
|
7
|
-
gem 'ohai', '>= 6.0.0', '< 8.0.0'
|
8
|
-
|
9
|
-
gem 'rake', '~> 10.3.2'
|
3
|
+
gem 'chef-zero', '3.2.1'
|
4
|
+
gem 'json', '1.8.2'
|
5
|
+
gem 'ohai', '< 9.0.0'
|
10
6
|
|
11
7
|
# Specify your gem's dependencies in knife-api.gemspec
|
8
|
+
gemspec
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/andyglick/knife-api.png)](https://travis-ci.org/andyglick/knife-api)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/knife-api.svg)](http://badge.fury.io/rb/knife-api)
|
3
|
+
[![Dependency Status](https://gemnasium.com/andyglick/knife-api.svg)](https://gemnasium.com/andyglick/knife-api)
|
4
|
+
[![Coverage Status](https://img.shields.io/coveralls/andyglick/knife-api.svg)](https://coveralls.io/r/andyglick/knife-api)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/andyglick/knife-api/badges/gpa.svg)](https://codeclimate.com/github/andyglick/knife-api)
|
1
6
|
# Knife-API
|
2
7
|
|
3
8
|
Erik Hollensbe first released knife-dsl in November of 2012. His last release took place in December of 2012. Today it
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/knife-api.gemspec
CHANGED
@@ -4,19 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'knife/api/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'knife-api'
|
8
8
|
gem.version = Chef::Knife::API::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
|
13
|
-
gem.
|
9
|
+
gem.authors = ['Erik Hollensbe', 'Andy Glick']
|
10
|
+
gem.email = ['andyglick@gmailcom']
|
11
|
+
gem.description =
|
12
|
+
%w(A small library that lets you drive Chef's 'knife' programmatically)
|
13
|
+
gem.summary =
|
14
|
+
%w(A small library that lets you drive Chef's 'knife' programmatically)
|
15
|
+
gem.homepage = 'https://github.com/andyglick/knife-api'
|
14
16
|
|
15
|
-
gem.files = `git ls-files`.split(
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
17
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
20
|
+
gem.require_paths = ['lib']
|
19
21
|
|
20
|
-
gem.add_dependency 'chef', '>= 10.
|
21
|
-
gem.add_development_dependency 'rake', '
|
22
|
+
gem.add_dependency 'chef', '>= 10.32', '< 13.0.0'
|
23
|
+
gem.add_development_dependency 'rake', '>= 10.4.2'
|
22
24
|
end
|
data/lib/knife/api/version.rb
CHANGED
data/lib/knife/api.rb
CHANGED
@@ -2,53 +2,59 @@ require 'chef/application/knife'
|
|
2
2
|
require 'knife/api/version'
|
3
3
|
require 'stringio'
|
4
4
|
|
5
|
-
module Chef
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
module Chef
|
6
|
+
module Knife
|
7
|
+
# adding API module to existing Chef::Knife packaging
|
8
|
+
module API
|
9
|
+
# adding Support module
|
10
|
+
module Support
|
11
|
+
def self.run_knife(command, args)
|
12
|
+
unless command.is_a?(Array)
|
13
|
+
command = command.to_s.split(/[\s_]+/)
|
14
|
+
end
|
15
|
+
|
16
|
+
command += args
|
11
17
|
|
12
|
-
|
18
|
+
if ENV['CHEF_CONFIG']
|
19
|
+
command += ['-c', ENV['CHEF_CONFIG']]
|
20
|
+
end
|
13
21
|
|
14
|
-
|
15
|
-
|
22
|
+
opts = Chef::Application::Knife.new.options
|
23
|
+
Chef::Knife.run(command, opts)
|
24
|
+
return 0
|
25
|
+
rescue SystemExit => e
|
26
|
+
return e.status
|
27
|
+
end
|
16
28
|
end
|
17
29
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
rescue SystemExit => e
|
22
|
-
return e.status
|
23
|
-
end
|
24
|
-
end
|
30
|
+
def knife(command, args = [])
|
31
|
+
Chef::Knife::API::Support.run_knife(command, args)
|
32
|
+
end
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
34
|
+
def knife_capture(command, args = [], input = nil)
|
35
|
+
null = Gem.win_platform? ? File.open('NUL:', 'r') : File.open('/dev/null', 'r')
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
null.close
|
37
|
+
warn = $VERBOSE
|
38
|
+
$VERBOSE = nil
|
39
|
+
stderr, stdout, stdin = STDERR, STDOUT, STDIN
|
40
|
+
|
41
|
+
Object.const_set('STDERR', StringIO.new('', 'r+'))
|
42
|
+
Object.const_set('STDOUT', StringIO.new('', 'r+'))
|
43
|
+
Object.const_set('STDIN', input ? StringIO.new(input, 'r') : null)
|
44
|
+
$VERBOSE = warn
|
45
|
+
|
46
|
+
status = Chef::Knife::API::Support.run_knife(command, args)
|
47
|
+
return STDOUT.string, STDERR.string, status
|
48
|
+
ensure
|
49
|
+
warn = $VERBOSE
|
50
|
+
$VERBOSE = nil
|
51
|
+
Object.const_set('STDERR', stderr)
|
52
|
+
Object.const_set('STDOUT', stdout)
|
53
|
+
Object.const_set('STDIN', stdin)
|
54
|
+
$VERBOSE = warn
|
55
|
+
null.close
|
56
|
+
end
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
@@ -57,7 +63,10 @@ class << eval("self", TOPLEVEL_BINDING)
|
|
57
63
|
end
|
58
64
|
|
59
65
|
if defined? Rake::API
|
60
|
-
module Rake
|
61
|
-
|
66
|
+
module Rake
|
67
|
+
# adding the API module to Rake in the context of this gem
|
68
|
+
module API
|
69
|
+
include Chef::Knife::API
|
70
|
+
end
|
62
71
|
end
|
63
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Hollensbe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '10.
|
20
|
+
version: '10.32'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 13.0.0
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '10.
|
30
|
+
version: '10.32'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 13.0.0
|
@@ -35,17 +35,18 @@ dependencies:
|
|
35
35
|
name: rake
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 10.
|
40
|
+
version: 10.4.2
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 10.
|
48
|
-
description: A small library that lets you drive Chef's
|
47
|
+
version: 10.4.2
|
48
|
+
description: '["A", "small", "library", "that", "lets", "you", "drive", "Chef''s",
|
49
|
+
"''knife''", "programmatically"]'
|
49
50
|
email:
|
50
51
|
- andyglick@gmailcom
|
51
52
|
executables: []
|
@@ -53,6 +54,7 @@ extensions: []
|
|
53
54
|
extra_rdoc_files: []
|
54
55
|
files:
|
55
56
|
- ".gitignore"
|
57
|
+
- ".travis.yml"
|
56
58
|
- Gemfile
|
57
59
|
- LICENSE.txt
|
58
60
|
- README.md
|
@@ -82,5 +84,6 @@ rubyforge_project:
|
|
82
84
|
rubygems_version: 2.4.1
|
83
85
|
signing_key:
|
84
86
|
specification_version: 4
|
85
|
-
summary: A small library that lets you drive Chef's 'knife'
|
87
|
+
summary: '["A", "small", "library", "that", "lets", "you", "drive", "Chef''s", "''knife''",
|
88
|
+
"programmatically"]'
|
86
89
|
test_files: []
|