between_meals 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/between_meals/changes/change.rb +2 -6
- data/lib/between_meals/changes/cookbook.rb +13 -2
- data/lib/between_meals/changes/databag.rb +1 -0
- data/lib/between_meals/changes/role.rb +1 -0
- data/lib/between_meals/knife.rb +2 -1
- data/lib/between_meals/repo/git.rb +1 -0
- data/lib/between_meals/repo/hg.rb +0 -2
- data/lib/between_meals/repo/hg/cmd.rb +1 -1
- data/lib/between_meals/util.rb +36 -12
- metadata +9 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4187ff23bfead830c0060f80b680700c3a704ab519e66c7781ef58812bf15a1f
|
4
|
+
data.tar.gz: 9894dbd0357a7742a1ad20e22306814014199e53587dd24b7952d31c0602a4ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbcba7682efd6869b714586ef98c78d7bc66fb08d7f006068ad2c346d46f543f0805be0b1efabd253b6218fc7fd55c6ed2aba093cf571c92fa155a6a8e35b6a5
|
7
|
+
data.tar.gz: 3d77520b0ba7818363d05ee6e739d7bf5b895d1873660550991cacbd18d075e70ada620553a95818c0f55f59e746bfd1c3114da3fc6fc42f4e40bbfd0c384f09
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
## Intro
|
7
7
|
Ohai!
|
8
8
|
|
9
|
-
Between Meals is the library for calculating what Chef objects
|
9
|
+
Between Meals is the library for calculating what Chef objects were modified
|
10
10
|
between two revisions in a version control system. It is also the library
|
11
11
|
that backs Taste Tester and Grocery Delivery.
|
12
12
|
|
@@ -37,15 +37,11 @@ module BetweenMeals
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.info(msg)
|
40
|
-
|
41
|
-
@@logger.info(msg)
|
42
|
-
end
|
40
|
+
@@logger&.info(msg)
|
43
41
|
end
|
44
42
|
|
45
43
|
def self.debug(msg)
|
46
|
-
|
47
|
-
@@logger.debug(msg)
|
48
|
-
end
|
44
|
+
@@logger&.debug(msg)
|
49
45
|
end
|
50
46
|
|
51
47
|
def info(msg)
|
@@ -28,6 +28,7 @@ module BetweenMeals
|
|
28
28
|
debug("[cookbook] Matching #{path} against ^#{re}")
|
29
29
|
m = path.match(re)
|
30
30
|
next unless m
|
31
|
+
|
31
32
|
info("Cookbook is #{m[1]}")
|
32
33
|
return {
|
33
34
|
:cookbook_dir => dir,
|
@@ -51,6 +52,7 @@ module BetweenMeals
|
|
51
52
|
links.each do |link|
|
52
53
|
link = File.join(dir, link)
|
53
54
|
next if symlinks[link]
|
55
|
+
|
54
56
|
source = File.realpath(link)
|
55
57
|
repo = File.join(@repo_dir, '/')
|
56
58
|
# maps absolute symlink path to relative source and link paths
|
@@ -70,6 +72,7 @@ module BetweenMeals
|
|
70
72
|
# a symlink will never have trailing '/', add one.
|
71
73
|
f[:path] += '/' if f[:path] == lrp['link']
|
72
74
|
next unless f[:path].start_with?(lrp['source'])
|
75
|
+
|
73
76
|
# This make a deep dup of the file hash
|
74
77
|
l = Marshal.load(Marshal.dump(f))
|
75
78
|
l[:path].gsub!(lrp['source'], lrp['link'])
|
@@ -83,7 +86,8 @@ module BetweenMeals
|
|
83
86
|
@files = files
|
84
87
|
@cookbook_dirs = cookbook_dirs
|
85
88
|
@name = self.class.explode_path(files.sample[:path])[:name]
|
86
|
-
# if metadata.rb is being deleted
|
89
|
+
# if metadata.(json|rb) is being deleted and we aren't also
|
90
|
+
# adding/modifying one of those two,
|
87
91
|
# cookbook is marked for deletion
|
88
92
|
# otherwise it was modified
|
89
93
|
# and will be re-uploaded
|
@@ -95,7 +99,13 @@ module BetweenMeals
|
|
95
99
|
)
|
96
100
|
end.
|
97
101
|
compact.
|
98
|
-
any?
|
102
|
+
any? &&
|
103
|
+
files.reject { |x| x[:status] == :deleted }.
|
104
|
+
map do |x|
|
105
|
+
x[:path].match(
|
106
|
+
%{^(#{cookbook_dirs.join('|')})/[^/]+/metadata\.(rb|json)$},
|
107
|
+
)
|
108
|
+
end.none?
|
99
109
|
@status = :deleted
|
100
110
|
else
|
101
111
|
@status = :modified
|
@@ -109,6 +119,7 @@ module BetweenMeals
|
|
109
119
|
@@logger = logger
|
110
120
|
# rubocop:enable ClassVars
|
111
121
|
return [] if list.nil? || list.empty?
|
122
|
+
|
112
123
|
# rubocop:disable MultilineBlockChain
|
113
124
|
@repo_dir = File.realpath(repo.repo_path)
|
114
125
|
@cookbook_dirs = cookbook_dirs
|
data/lib/between_meals/knife.rb
CHANGED
@@ -113,6 +113,7 @@ module BetweenMeals
|
|
113
113
|
@cookbook_dirs.each do |path|
|
114
114
|
cookbooks.each do |cb|
|
115
115
|
next unless File.exists?("#{path}/#{cb}")
|
116
|
+
|
116
117
|
@logger.warn("Running berkshelf on cookbook: #{cb}")
|
117
118
|
exec!("cd #{path}/#{cb} && #{@berks} install #{berks_config} && " +
|
118
119
|
"#{@berks} upload #{berks_config}", @logger)
|
@@ -225,7 +226,7 @@ zvgEHqbS0/QkJGOZ+UifPRanTDuGYQkPdHHOER4UghbM+Kz5rZbBicJ3bCyNOsah
|
|
225
226
|
IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
|
226
227
|
6wX4GR84dwyhG80yd4TP8Qo=
|
227
228
|
-----END PRIVATE KEY-----
|
228
|
-
|
229
|
+
BLOCK
|
229
230
|
|
230
231
|
unless File.directory?(File.dirname(@pem))
|
231
232
|
Dir.mkdir(File.dirname(@pem), 0o755)
|
@@ -165,7 +165,6 @@ module BetweenMeals
|
|
165
165
|
# I = ignored
|
166
166
|
# = origin of the previous file (with --copies)
|
167
167
|
|
168
|
-
# rubocop:disable MultilineBlockChain
|
169
168
|
changes.lines.map do |line|
|
170
169
|
case line
|
171
170
|
when /^A (\S+)$/
|
@@ -207,7 +206,6 @@ module BetweenMeals
|
|
207
206
|
fail 'Failed to parse repo diff line.'
|
208
207
|
end
|
209
208
|
end
|
210
|
-
# rubocop:enable MultilineBlockChain
|
211
209
|
end
|
212
210
|
end
|
213
211
|
end
|
data/lib/between_meals/util.rb
CHANGED
@@ -15,13 +15,15 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'colorize'
|
18
|
+
require 'net/http'
|
19
|
+
require 'openssl'
|
18
20
|
require 'socket'
|
19
21
|
require 'timeout'
|
20
22
|
|
21
23
|
module BetweenMeals
|
22
24
|
# A set of simple utility functions used throughout BetweenMeals
|
23
25
|
#
|
24
|
-
# Feel
|
26
|
+
# Feel free to use... note that if you pass in a logger once
|
25
27
|
# you don't need to again, but be safe and always pass one in. :)
|
26
28
|
|
27
29
|
# Util classes need class vars :)
|
@@ -52,7 +54,7 @@ module BetweenMeals
|
|
52
54
|
private
|
53
55
|
|
54
56
|
def info(msg)
|
55
|
-
@@logger
|
57
|
+
@@logger&.info(msg)
|
56
58
|
end
|
57
59
|
|
58
60
|
def execute(command)
|
@@ -69,21 +71,43 @@ module BetweenMeals
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def port_open?(port)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
ips = Socket.ip_address_list
|
75
|
+
ips.map!(&:ip_address)
|
76
|
+
ips.each do |ip|
|
77
|
+
begin
|
78
|
+
Timeout.timeout(1) do
|
79
|
+
begin
|
80
|
+
s = TCPSocket.new(ip, port)
|
81
|
+
s.close
|
82
|
+
return true
|
83
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
84
|
+
next
|
85
|
+
end
|
80
86
|
end
|
87
|
+
rescue Timeout::Error
|
88
|
+
next
|
81
89
|
end
|
82
|
-
rescue Timeout::Error
|
83
|
-
return false
|
84
90
|
end
|
85
91
|
return false
|
86
92
|
end
|
93
|
+
|
94
|
+
def chef_zero_running?(port, use_ssl)
|
95
|
+
Timeout.timeout(1) do
|
96
|
+
begin
|
97
|
+
http = Net::HTTP.new('localhost', port)
|
98
|
+
if use_ssl
|
99
|
+
http.use_ssl = true
|
100
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
101
|
+
end
|
102
|
+
res = http.get('/')
|
103
|
+
return res['Server'] == 'chef-zero'
|
104
|
+
rescue StandardError
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
rescue Timeout::Error
|
109
|
+
return false
|
110
|
+
end
|
87
111
|
end
|
88
112
|
end
|
89
113
|
# rubocop:enable ClassVars
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: between_meals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Dibowitz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: json
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: mixlib-shellout
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +96,7 @@ dependencies:
|
|
110
96
|
- !ruby/object:Gem::Version
|
111
97
|
version: '0'
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
99
|
+
name: simplecov
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
115
101
|
requirements:
|
116
102
|
- - ">="
|
@@ -124,19 +110,19 @@ dependencies:
|
|
124
110
|
- !ruby/object:Gem::Version
|
125
111
|
version: '0'
|
126
112
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
113
|
+
name: rubocop
|
128
114
|
requirement: !ruby/object:Gem::Requirement
|
129
115
|
requirements:
|
130
|
-
- -
|
116
|
+
- - '='
|
131
117
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
118
|
+
version: 0.49.1
|
133
119
|
type: :development
|
134
120
|
prerelease: false
|
135
121
|
version_requirements: !ruby/object:Gem::Requirement
|
136
122
|
requirements:
|
137
|
-
- -
|
123
|
+
- - '='
|
138
124
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
125
|
+
version: 0.49.1
|
140
126
|
description: Library for calculation Chef differences between revisions
|
141
127
|
email:
|
142
128
|
executables: []
|
@@ -182,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
168
|
version: '0'
|
183
169
|
requirements: []
|
184
170
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.6
|
171
|
+
rubygems_version: 2.7.6
|
186
172
|
signing_key:
|
187
173
|
specification_version: 4
|
188
174
|
summary: Between Meals
|