knife-partial-search 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +15 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/knife-partial-search.gemspec +24 -0
- data/lib/chef/knife/partial_search/fast_ssh.rb +27 -0
- data/lib/chef/knife/partial_search/fast_status.rb +42 -0
- data/lib/chef/knife/partial_search/partial_search.rb +28 -0
- data/lib/chef/knife/partial_search.rb +3 -0
- data/lib/chef/knife/version.rb +5 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fbf495000ed0411a315071d3cf33e502c6a21683
|
4
|
+
data.tar.gz: 6cecc9edfae5dfa76bb5366731d780a02c8b7de3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3705d9db8584020d30d0c95fc1011f8cecd75a1d36659a3623eae45c1c6943ad62be40bd1b9bc67f4c17a55062fceee145e4b986f496b4737cd5266ee0b01e8e
|
7
|
+
data.tar.gz: 5120a07a77c623c4f2ff0f07bdd9dc500b42f5afebb4ba7d196c6f150476c6cba6e06b725da2d0123d1e286ec3f6bc420d354873623bde48666fb002af7f9bc6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Author:: Baptiste Courtois (<b.courtois@criteo.com>)
|
2
|
+
|
3
|
+
Copyright (C) 2014, Baptiste Courtois
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chef/knife/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "knife-partial-search"
|
8
|
+
spec.version = Knife::PartialSearch::VERSION
|
9
|
+
spec.authors = ["Gregoire Seux"]
|
10
|
+
spec.email = ["g.seux@criteo.com"]
|
11
|
+
spec.summary = "Improve usual knife commands thanks to partial-search"
|
12
|
+
spec.homepage = "https://gitlab.criteois.lan/ruby-gems/knife-partial-search"
|
13
|
+
spec.license = "Apache 2.0"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "chef", ">= 11"
|
21
|
+
spec.add_runtime_dependency "chef-partial_search"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Chef
|
2
|
+
class Knife
|
3
|
+
class Ssh
|
4
|
+
|
5
|
+
include Chef::Knife::PartialSearch
|
6
|
+
|
7
|
+
deps do
|
8
|
+
begin
|
9
|
+
require 'partial_search'
|
10
|
+
rescue LoadError => e
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_method :classic_configure_session, :configure_session unless method_defined? :classic_configure_session
|
15
|
+
|
16
|
+
def configure_session
|
17
|
+
if defined?(Chef::PartialSearch)
|
18
|
+
keys = {}
|
19
|
+
keys[config[:attribute]] = config[:attribute].split('.') if config[:attribute]
|
20
|
+
keys[config[:override_attribute]] = config[:override_attribute].split('.') if config[:override_attribute]
|
21
|
+
define_partial_search(keys)
|
22
|
+
end
|
23
|
+
classic_configure_session
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Chef
|
2
|
+
class Knife
|
3
|
+
class Status
|
4
|
+
|
5
|
+
include Chef::Knife::PartialSearch
|
6
|
+
|
7
|
+
deps do
|
8
|
+
begin
|
9
|
+
require 'partial_search'
|
10
|
+
rescue LoadError => e
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_method :classic_run, :run unless method_defined? :classic_run
|
15
|
+
|
16
|
+
def run
|
17
|
+
if defined?(Chef::PartialSearch)
|
18
|
+
define_partial_search({
|
19
|
+
'name' => ['name'],
|
20
|
+
'ohai_time' => ['ohai_time'],
|
21
|
+
'fqdn' => ['fqdn'],
|
22
|
+
'ipaddress' => ['ipaddress'],
|
23
|
+
'platform' => ['platform'],
|
24
|
+
'platform_version' => ['platform_version'],
|
25
|
+
'run_list' => ['run_list'],
|
26
|
+
})
|
27
|
+
end
|
28
|
+
classic_run
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class FakeNode < Hash
|
36
|
+
def name
|
37
|
+
self['name']
|
38
|
+
end
|
39
|
+
def run_list
|
40
|
+
self['run_list'].join(', ')
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Chef
|
2
|
+
class Knife
|
3
|
+
module PartialSearch
|
4
|
+
def define_partial_search(keys)
|
5
|
+
Chef::Search::Query.class_eval do
|
6
|
+
|
7
|
+
@@keys = keys
|
8
|
+
|
9
|
+
alias_method :old_search, :search unless method_defined? :old_search
|
10
|
+
|
11
|
+
def search(type, query, args={}, &block)
|
12
|
+
q = Chef::PartialSearch.new
|
13
|
+
args[:keys] = @@keys
|
14
|
+
if block_given?
|
15
|
+
q.search(type, query, args) do |node_hash|
|
16
|
+
n = FakeNode.new do |h,k| node_hash[k] end
|
17
|
+
block.call(n)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
res = q.search(type, query, args)
|
21
|
+
[res.first]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-partial-search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gregoire Seux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chef
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: chef-partial_search
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- g.seux@criteo.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- knife-partial-search.gemspec
|
82
|
+
- lib/chef/knife/partial_search.rb
|
83
|
+
- lib/chef/knife/partial_search/fast_ssh.rb
|
84
|
+
- lib/chef/knife/partial_search/fast_status.rb
|
85
|
+
- lib/chef/knife/partial_search/partial_search.rb
|
86
|
+
- lib/chef/knife/version.rb
|
87
|
+
homepage: https://gitlab.criteois.lan/ruby-gems/knife-partial-search
|
88
|
+
licenses:
|
89
|
+
- Apache 2.0
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Improve usual knife commands thanks to partial-search
|
111
|
+
test_files: []
|