socotra-build 0.3.11 → 0.3.12

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/socotra-build.rb +26 -27
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d48fe3035f0640059a4399b1efafe1db0d6bbc62
4
- data.tar.gz: f63eeb2505e0b047a95a6258bafbe8dd24101bc3
3
+ metadata.gz: 4e0e0d7f0f50fbe044494d7ff23d4394927a75cb
4
+ data.tar.gz: 8d020afbdcdf2c8044aedb7087814d78d0a8d56a
5
5
  SHA512:
6
- metadata.gz: 322985e031c6ad1697ada30faec8d4b0cccfec7b290ed4596cbaf63226add453547d365a9a207b4146ff17d7faca93a6bdfb589e8b4044a2d16a0c3b1d5cb2f9
7
- data.tar.gz: 581855aaa58144328838c7dc5666dae7d2170ab148ba2a18c0cd8196ee80cca5c33bf51edc4eb88fece9b832894090cfcf163fccdbcce711f4d7faf62c832546
6
+ metadata.gz: 11f33eda69902159c0d16762692cf24600773c35dfcd2578d4bdd4d1618a1a4dec818b3ab2aa21b18c909265891503e03a867a6a15ed47716e82c6b77f9e903d
7
+ data.tar.gz: e7fda3856040216d84623b2e9de5045743b852a2654f94fbc551b31c631b409450948474bc811f6183eaa9fbe0c3658ec0804a60561dc0bf252a7683333556ca
data/lib/socotra-build.rb CHANGED
@@ -2,22 +2,22 @@ require 'open3'
2
2
  require 'set'
3
3
 
4
4
  def self.safe_retry(cmd, description, error_message="command failed", raise_on_fail=true, log_level="ERROR", log=true, tries=3)
5
- begin
6
- status, output = system_safe(cmd, description, error_message, raise_on_fail=raise_on_fail, log_level=log_level, log=log)
7
- rescue
8
- if (tries -= 1) > 0
9
- puts "\n#{cmd} failed, retry attempt #{tries}\n"
10
- sleep 5
11
- retry unless (tries).zero?
12
- else
13
- puts "ERROR: see logs/#{description}_out.log and #{description}_err.log for details"
14
- if raise_on_fail
15
- raise "ERROR: #{error_message}"
16
- end
17
- end
18
- end
5
+ begin
6
+ status, output = system_safe(cmd, description, error_message, raise_on_fail=raise_on_fail, log_level=log_level, log=log)
7
+ rescue
8
+ if (tries -= 1) > 0
9
+ puts "\n#{cmd} failed, retry attempt #{tries}\n"
10
+ sleep 5
11
+ retry unless (tries).zero?
12
+ else
13
+ puts "ERROR: see logs/#{description}_out.log and #{description}_err.log for details"
14
+ if raise_on_fail
15
+ raise "ERROR: #{error_message}"
16
+ end
17
+ end
18
+ end
19
19
 
20
- return status
20
+ return status
21
21
  end
22
22
 
23
23
  def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, log_level="ERROR", log=true, print_command=true)
@@ -45,25 +45,24 @@ def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, lo
45
45
  cmd = cmd.gsub(/\s+/m, ' ').strip.split(" ")
46
46
  replace = cmd.grep(Regexp.union(secret_fields))
47
47
  unless replace.empty?
48
- puts replace
49
48
  replace = Set.new replace
50
49
  cmd.collect! {|e| (replace.include? e) ? '<secret>': e}
51
50
  end
52
51
  cmd = cmd.join(' ')
53
52
 
54
- if print_command
55
- puts "Executing command: #{cmd}\n"
56
- else
57
- puts "Not logging command"
58
- end
53
+ if print_command
54
+ puts "Executing command: #{cmd}\n"
55
+ else
56
+ puts "Not logging command"
57
+ end
59
58
 
60
59
  if log
61
- File.open("logs/#{cmd_description}_out.log" , 'w') { |file| file.write(stdout) }
62
- File.open("logs/#{cmd_description}_err.log" , 'w') { |file| file.write(stderr) }
63
- puts "\tLogs available here: #{cmd_description}_err.log and #{cmd_description}_out.log\n\n"
64
- else
65
- puts "Not logging due to secrets in output"
66
- end
60
+ File.open("logs/#{cmd_description}_out.log" , 'w') { |file| file.write(stdout) }
61
+ File.open("logs/#{cmd_description}_err.log" , 'w') { |file| file.write(stderr) }
62
+ puts "\tLogs available here: #{cmd_description}_err.log and #{cmd_description}_out.log\n\n"
63
+ else
64
+ puts "Not logging due to secrets in output"
65
+ end
67
66
 
68
67
  puts "\t#{cmd_description} took #{elapsed} seconds"
69
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socotra-build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Antenesse