helmsnap 0.4.1 → 0.4.2
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.
- checksums.yaml +4 -4
 - data/Gemfile.lock +1 -1
 - data/lib/helmsnap/check.rb +2 -3
 - data/lib/helmsnap/command.rb +14 -9
 - data/lib/helmsnap/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8a5cb05f018581cbbccdfd9114f0ce1426457d63bd4fcd69864d558a6c790be5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c6ff86c42987cbebe2fb71889d05dd0d11e33d0ca164a89419c75b58a6b671ab
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 60bf1bbab69d1990b05d93bcc3b22b67318f665d431ea2b770a6eddf894a6df800d139b32cdd35d61905067fd7e52ae21d91b069d94a99736ea57d25f9968ee6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 804d6d566f1e6c546f1f94a9235b43ba69fb451f298987855c40a281033144fd1ee44ea53e0fdf764f1d6f2bfe29e6902fd1bb065d75f6b4eba3212feaca367a
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/helmsnap/check.rb
    CHANGED
    
    | 
         @@ -23,9 +23,8 @@ class Helmsnap::Check 
     | 
|
| 
       23 
23 
     | 
    
         
             
                result = Helmsnap.run_cmd("which", "colordiff", allow_failure: true)
         
     | 
| 
       24 
24 
     | 
    
         
             
                util = result.success ? "colordiff" : "diff"
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                ).output
         
     | 
| 
      
 26 
     | 
    
         
            +
                cmd_parts = [util, "--unified", "--recursive", snapshots_path, temp_dir_path]
         
     | 
| 
      
 27 
     | 
    
         
            +
                diff = Helmsnap.run_cmd(*cmd_parts, allow_failure: true).output
         
     | 
| 
       29 
28 
     | 
    
         | 
| 
       30 
29 
     | 
    
         
             
                diff.strip.empty?
         
     | 
| 
       31 
30 
     | 
    
         
             
              ensure
         
     | 
    
        data/lib/helmsnap/command.rb
    CHANGED
    
    | 
         @@ -9,6 +9,7 @@ class Helmsnap::Command 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              def initialize(cmd, stdout: $stdout, stderr: $stderr, allow_failure: false)
         
     | 
| 
       11 
11 
     | 
    
         
             
                self.cmd = cmd
         
     | 
| 
      
 12 
     | 
    
         
            +
                self.output = +""
         
     | 
| 
       12 
13 
     | 
    
         
             
                self.stdout = stdout
         
     | 
| 
       13 
14 
     | 
    
         
             
                self.stderr = stderr
         
     | 
| 
       14 
15 
     | 
    
         
             
                self.allow_failure = allow_failure
         
     | 
| 
         @@ -21,12 +22,10 @@ class Helmsnap::Command 
     | 
|
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
              private
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
              attr_accessor :cmd, :stdout, :stderr, :allow_failure
         
     | 
| 
      
 25 
     | 
    
         
            +
              attr_accessor :cmd, :output, :stdout, :stderr, :allow_failure
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
       26 
27 
     | 
    
         
             
              def run_command
         
     | 
| 
       27 
28 
     | 
    
         
             
                Open3.popen3(cmd) do |_in, out, err, wait_thr|
         
     | 
| 
       28 
     | 
    
         
            -
                  output = +""
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
29 
     | 
    
         
             
                  while (chunk = out.gets)
         
     | 
| 
       31 
30 
     | 
    
         
             
                    Helmsnap::Console.print(stdout, chunk)
         
     | 
| 
       32 
31 
     | 
    
         
             
                    output << chunk
         
     | 
| 
         @@ -34,15 +33,21 @@ class Helmsnap::Command 
     | 
|
| 
       34 
33 
     | 
    
         | 
| 
       35 
34 
     | 
    
         
             
                  exit_status = wait_thr.value
         
     | 
| 
       36 
35 
     | 
    
         
             
                  success = exit_status.success?
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  if !success && !allow_failure
         
     | 
| 
       39 
     | 
    
         
            -
                    Helmsnap::Console.error(stderr, err.read)
         
     | 
| 
       40 
     | 
    
         
            -
                    Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
         
     | 
| 
       41 
     | 
    
         
            -
                    exit 1
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                  handle_error!(exit_status, err.read) unless success
         
     | 
| 
       43 
37 
     | 
    
         | 
| 
       44 
38 
     | 
    
         
             
                  Helmsnap::Console.print(stdout, "\n")
         
     | 
| 
       45 
39 
     | 
    
         
             
                  Result.new(success, output)
         
     | 
| 
       46 
40 
     | 
    
         
             
                end
         
     | 
| 
       47 
41 
     | 
    
         
             
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def handle_error!(exit_status, err_output)
         
     | 
| 
      
 44 
     | 
    
         
            +
                Helmsnap::Console.error(stderr, err_output)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                if allow_failure
         
     | 
| 
      
 47 
     | 
    
         
            +
                  output << err_output
         
     | 
| 
      
 48 
     | 
    
         
            +
                else
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  exit 1
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
       48 
53 
     | 
    
         
             
            end
         
     | 
    
        data/lib/helmsnap/version.rb
    CHANGED