helmsnap 0.7.0 → 0.7.4

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: 82cc0b42f25f49c54cb4ec921c092f7a3e6cc9de565bc3e39e357e4129b5c3ff
4
- data.tar.gz: 0fc97b6105f8a9ab5fb8360bf390be3cfaea21bc24b21edf42960b88658c54a8
3
+ metadata.gz: d5e21c78125566f4355ae0679100331a32322034be84fcde8f72ba44397de8e2
4
+ data.tar.gz: da348e3a0651dd69d20e33555ddf547b8097057169eac3b1e678d4006ce90ff7
5
5
  SHA512:
6
- metadata.gz: f514cd9633fab8f88efac3ae96dda8579c9b8dbd2a90da8822979958c334681e0b882c498e1b4acfeda279814beeaf181fd942366b036da04100b62cbe1d9dc8
7
- data.tar.gz: 5b9046c477241a66acbe1a2bc8b7f982205b49bbcf3f53edbeb1f4f516b4008f0ab4c52aeb5f829538796a1f717931588bea7abce9d33ecd9726031fe43c24dd
6
+ metadata.gz: cb09555b7dc60d769d5a54df05740b9f50fe9e0542a6f1b3a85ce9c1cfcbba1a630bd079109e468620345757ca693b41b79345e737f8ce0a4a5f8f3272a3d02d
7
+ data.tar.gz: 59237f6806aa14d80335ccd6afaa08dd4f11398c930e5b3f491058d1cfc96a67f1303a22af3094e172cdb7b5ec43a1a1cc312799dd4fc245c932b47beb62600e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.7.0)
4
+ helmsnap (0.7.4)
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)
data/lib/helmsnap/env.rb CHANGED
@@ -10,7 +10,7 @@ class Helmsnap::Env
10
10
  def release_paths
11
11
  @release_paths ||= begin
12
12
  json = Helmsnap.run_cmd("helmfile", "--environment", name, "list", "--output", "json").output
13
- YAML.load(json).map { |x| x.fetch("chart") }
13
+ YAML.load(json).map { |x| Pathname.new(x.fetch("chart")) }
14
14
  end
15
15
  end
16
16
 
@@ -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",
@@ -17,16 +17,39 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
17
17
  attr_accessor :config
18
18
 
19
19
  def setup!(chart_path)
20
- dep_list = run_cmd("helm", "dependency", "list", "--max-col-width", 0, chart_path).output
20
+ dep_list = get_dependency_list(chart_path)
21
21
 
22
22
  dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
23
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first))
23
+ update_deps!(chart_path.join(dep_path.first))
24
24
  end
25
25
 
26
26
  dep_list.scan(%r{(https?://.+?)\t}) do |dep_path|
27
27
  run_cmd("helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first)
28
28
  end
29
29
 
30
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
30
+ update_deps!(chart_path)
31
+ end
32
+
33
+ def get_dependency_list(chart_path)
34
+ base_cmd = ["helm", "dependency", "list", chart_path]
35
+
36
+ result = run_cmd(*base_cmd, "--max-col-width", 0, allow_failure: true, stderr: nil)
37
+
38
+ if result.success
39
+ result.output
40
+ else
41
+ run_cmd(*base_cmd).output.tap do
42
+ Helmsnap::Console.warning(
43
+ $stderr, "it looks like your Helm binary is outdated, please update.\n"
44
+ )
45
+ end
46
+ end
47
+ end
48
+
49
+ def update_deps!(chart_path)
50
+ base_cmd = ["helm", "dependency", "update", chart_path]
51
+ result = run_cmd(*base_cmd, "--skip-refresh", allow_failure: true)
52
+ run_cmd(*base_cmd) unless result.success # Try with deps refresh in case of any failure
53
+ true
31
54
  end
32
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.4"
5
5
  end
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.0
4
+ version: 0.7.4
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-06 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.