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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a8a35526d4eb577be4dab5579a7049efb1188f97
4
- data.tar.gz: 2f277ba7902ccbd1d2cb4c95e768d3adb4171481
2
+ SHA256:
3
+ metadata.gz: 4187ff23bfead830c0060f80b680700c3a704ab519e66c7781ef58812bf15a1f
4
+ data.tar.gz: 9894dbd0357a7742a1ad20e22306814014199e53587dd24b7952d31c0602a4ee
5
5
  SHA512:
6
- metadata.gz: 0dd9a6e457c41ac7385498944eee2e76e2b413983872616ebe835d76221accdf62fc240a7312fe287c08008095d29e210b9696d563399744149288eefd9dca28
7
- data.tar.gz: d0eeca1bf8f1d2c4a9388fb1902cd5a679f2c88a4f0b38a48905b3c04ef5a5858a02bb03f89107df2f328a4eacd7bf8299dc657ea120d71ecd70c02d94fc5072
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 where modified
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
- if @@logger
41
- @@logger.info(msg)
42
- end
40
+ @@logger&.info(msg)
43
41
  end
44
42
 
45
43
  def self.debug(msg)
46
- if @@logger
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
@@ -40,6 +40,7 @@ module BetweenMeals
40
40
  @@logger = logger
41
41
  # rubocop:enable ClassVars
42
42
  return [] if list.nil? || list.empty?
43
+
43
44
  list.
44
45
  select { |x| self.name_from_path(x[:path], databag_dir) }.
45
46
  map do |x|
@@ -41,6 +41,7 @@ module BetweenMeals
41
41
  @@logger = logger
42
42
  # rubocop:enable ClassVars
43
43
  return [] if list.nil? || list.empty?
44
+
44
45
  list.
45
46
  select { |x| self.name_from_path(x[:path], role_dir) }.
46
47
  map do |x|
@@ -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
- BLOCK
229
+ BLOCK
229
230
 
230
231
  unless File.directory?(File.dirname(@pem))
231
232
  Dir.mkdir(File.dirname(@pem), 0o755)
@@ -112,6 +112,7 @@ module BetweenMeals
112
112
  if @cmd.merge_base(rev, master).stdout.strip == rev
113
113
  return true
114
114
  end
115
+
115
116
  return false
116
117
  rescue StandardError
117
118
  return false
@@ -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
@@ -50,7 +50,7 @@ module BetweenMeals
50
50
  begin
51
51
  f.write(msg)
52
52
  f.flush
53
- cmd("commit --amend -l #{f.path}")
53
+ cmd("commit --amend --exclude '**' -l #{f.path}")
54
54
  ensure
55
55
  f.close
56
56
  f.unlink
@@ -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 freeo to use... note that if you pass in a logger once
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.info(msg) if @@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
- begin
73
- Timeout.timeout(1) do
74
- begin
75
- s = TCPSocket.new('localhost', port)
76
- s.close
77
- return true
78
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
79
- return false
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.8
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: 2017-12-18 00:00:00.000000000 Z
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: rubocop
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: simplecov
113
+ name: rubocop
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
- - - ">="
116
+ - - '='
131
117
  - !ruby/object:Gem::Version
132
- version: '0'
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: '0'
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.11
171
+ rubygems_version: 2.7.6
186
172
  signing_key:
187
173
  specification_version: 4
188
174
  summary: Between Meals