helmsnap 0.7.1 → 0.7.5

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
2
  SHA256:
3
- metadata.gz: c06eb415d8391af30d789fdf0a28d93c1fd3eeec961927623ee124f4a97c27da
4
- data.tar.gz: 1955829609e08db79e13150e4fc96c3cd30df8242f08e00976040c407d2fba0d
3
+ metadata.gz: 76745aa695bb329e8e8d8cdf2a7c35fddd42cb24cc41f5ae15ac7f79a1513bb3
4
+ data.tar.gz: 532988aa8e92b3d48de4f9393bb88cb50506345c10d9645f56cdd2491141f671
5
5
  SHA512:
6
- metadata.gz: 8f58ea04641722e5adc18e604eb770e8bc1cf64b3db94fc450cd932d7e79e779c00fe88abbf676377499f6e4ec6179a1831f0688fee26fd77dbdc1d21fc99448
7
- data.tar.gz: 11a731bf61117fbd8671b56993860b3fc35367d16699297bd962a61d990b187491199a4b06646c911ead81cb5677d8d259b6917737b9b0b6f48d3cca865ef7e8
6
+ metadata.gz: ccedd03bea5461c576bc5e146180a83d5a201eb25b29ea483bafc610f74736a8691e6890261dcd33f7b376d51c7558e7dc620bb9b9d50fb204fd44e1ec1c0e6a
7
+ data.tar.gz: ca3c0246e70ce001454364556596b35376ea69ac12d4e8ca72191050d11275810ba5c8ab98954afcd82946af28b7ea87157ddda6040322d44c60657f4eb84b3f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.7.1)
4
+ helmsnap (0.7.5)
5
5
  colorize
6
6
 
7
7
  GEM
@@ -85,6 +85,7 @@ GEM
85
85
  zeitwerk (2.5.1)
86
86
 
87
87
  PLATFORMS
88
+ arm64-darwin-21
88
89
  x86_64-darwin-20
89
90
  x86_64-linux
90
91
 
@@ -97,4 +98,4 @@ DEPENDENCIES
97
98
  rubocop-config-umbrellio
98
99
 
99
100
  BUNDLED WITH
100
- 2.2.32
101
+ 2.2.33
@@ -7,8 +7,8 @@ class Helmsnap::Command < Helmsnap::Service
7
7
  super()
8
8
  self.cmd = cmd
9
9
  self.output = +""
10
- self.stdout = stdout
11
- self.stderr = stderr
10
+ self.stdout = stdout || null_file
11
+ self.stderr = stderr || null_file
12
12
  self.allow_failure = allow_failure
13
13
  end
14
14
 
@@ -21,6 +21,10 @@ class Helmsnap::Command < Helmsnap::Service
21
21
 
22
22
  attr_accessor :cmd, :output, :stdout, :stderr, :allow_failure
23
23
 
24
+ def null_file
25
+ File.open(File::NULL, "w")
26
+ end
27
+
24
28
  def run_command
25
29
  Open3.popen3(cmd) do |_in, out, err, wait_thr|
26
30
  while (chunk = out.gets)
@@ -12,6 +12,11 @@ module Helmsnap::Console
12
12
  stream.puts(msg)
13
13
  end
14
14
 
15
+ def warning(stream, msg)
16
+ msg = ColorizedString["WARNING: #{msg}"].colorize(:light_blue)
17
+ stream.puts(msg)
18
+ end
19
+
15
20
  def error(stream, msg)
16
21
  msg = ColorizedString[msg].colorize(:light_red)
17
22
  stream.puts(msg)
@@ -8,10 +8,10 @@ class Helmsnap::Generate < Helmsnap::Service
8
8
  end
9
9
 
10
10
  def call
11
- FileUtils.rmtree(snapshots_path)
12
-
13
11
  Helmsnap::SetupDependencies.call(config)
14
12
 
13
+ FileUtils.rmtree(snapshots_path)
14
+
15
15
  config.envs.each do |env|
16
16
  run_cmd(
17
17
  "helmfile",
@@ -4,29 +4,58 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
4
4
  def initialize(config)
5
5
  super()
6
6
  self.config = config
7
+ self.processed_paths = Set.new
7
8
  end
8
9
 
9
10
  def call
10
- config.envs.flat_map(&:release_paths).uniq.each do |chart_path|
11
+ config.envs.flat_map(&:release_paths).each do |chart_path|
11
12
  setup!(chart_path)
12
13
  end
13
14
  end
14
15
 
15
16
  private
16
17
 
17
- attr_accessor :config
18
+ attr_accessor :config, :processed_paths
18
19
 
19
20
  def setup!(chart_path)
20
- dep_list = run_cmd("helm", "dependency", "list", "--max-col-width", 0, chart_path).output
21
+ normalized_path = chart_path.expand_path
22
+ return if processed_paths.include?(normalized_path)
23
+ processed_paths << normalized_path
24
+
25
+ dep_list = get_dependency_list(chart_path)
21
26
 
22
27
  dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
23
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first))
28
+ subchart_path = chart_path.join(dep_path.first)
29
+ setup!(subchart_path)
24
30
  end
25
31
 
26
32
  dep_list.scan(%r{(https?://.+?)\t}) do |dep_path|
27
33
  run_cmd("helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first)
28
34
  end
29
35
 
30
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
36
+ update_deps!(chart_path)
37
+ end
38
+
39
+ def get_dependency_list(chart_path)
40
+ base_cmd = ["helm", "dependency", "list", chart_path]
41
+
42
+ result = run_cmd(*base_cmd, "--max-col-width", 0, allow_failure: true, stderr: nil)
43
+
44
+ if result.success
45
+ result.output
46
+ else
47
+ run_cmd(*base_cmd).output.tap do
48
+ Helmsnap::Console.warning(
49
+ $stderr, "it looks like your Helm binary is outdated, please update.\n"
50
+ )
51
+ end
52
+ end
53
+ end
54
+
55
+ def update_deps!(chart_path)
56
+ base_cmd = ["helm", "dependency", "update", chart_path]
57
+ result = run_cmd(*base_cmd, "--skip-refresh", allow_failure: true)
58
+ run_cmd(*base_cmd) unless result.success # Try with deps refresh in case of any failure
59
+ true
31
60
  end
32
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.7.1"
4
+ VERSION = "0.7.5"
5
5
  end
data/lib/helmsnap.rb CHANGED
@@ -6,6 +6,7 @@ require "open3"
6
6
  require "optparse"
7
7
  require "pathname"
8
8
  require "shellwords"
9
+ require "set"
9
10
  require "tmpdir"
10
11
  require "yaml"
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helmsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.2.32
95
+ rubygems_version: 3.2.33
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: A tool for creating and checking helm chart snapshots.