helmsnap 0.7.3 → 0.8.0

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: ffc691f40a8c6b4f4d28d2379e21e45cc032bf743f71d5cf0df9de0a35f69fe4
4
- data.tar.gz: b50966b9642e57d6a286e0e20e8dd323711aafeb4723a245125d9e522b05547b
3
+ metadata.gz: 594265027f90c4a67adaf63dc8f1cad703f020a755d1c9a4f038549641637b37
4
+ data.tar.gz: 9171632fcf284a60529ea55cf76fd4e79cd8b759b7a2a9eb20bcb832c3d5ed11
5
5
  SHA512:
6
- metadata.gz: 2f4bb8e9617bc866856f5160933fc7a755b441ed397374a57ed7cf9b01625b795163a448154af200af5b830bbf46107d45397fe35380d236a45e978ee66c09dd
7
- data.tar.gz: b63cab9f3767a79586beec2279a4b490c3ff144b426482504233e7a19741dd168bb90c8f21b96a2fc83b32e5ea962f7a970faecf043bf1880e3ce461cf2ed101
6
+ metadata.gz: 5f0adbcd7556e6a76a35d3955f4f774bde0131f4eaa13066f31a8a4cf1880f0ba1e0378f2bf614d2cab7ea1057cd21e5cf65ff2d9fddb871252c90ae39a7214d
7
+ data.tar.gz: 21948d7c1025f749d195730bd65678b2d9129b01d0caddfe12b9c786c2de695592ce16412343025115b7d012544b4da704037f294411b9a51875553f7c0611b2
data/Dockerfile CHANGED
@@ -4,7 +4,7 @@ RUN apk add --update --no-cache ruby git colordiff
4
4
 
5
5
  WORKDIR /wd
6
6
 
7
- COPY --from=quay.io/roboll/helmfile:v0.142.0 /usr/local/bin/helmfile /usr/local/bin/helmfile
7
+ COPY --from=quay.io/roboll/helmfile:v0.144.0 /usr/local/bin/helmfile /usr/local/bin/helmfile
8
8
  COPY . .
9
9
 
10
10
  RUN gem install colorize && gem build && gem install helmsnap --local
data/Gemfile.lock CHANGED
@@ -1,91 +1,89 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.7.3)
4
+ helmsnap (0.7.5)
5
5
  colorize
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.4.1)
10
+ activesupport (7.0.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
- zeitwerk (~> 2.3)
16
15
  ast (2.4.2)
17
16
  coderay (1.1.3)
18
17
  colorize (0.8.1)
19
- concurrent-ruby (1.1.9)
20
- diff-lcs (1.4.4)
21
- i18n (1.8.11)
18
+ concurrent-ruby (1.1.10)
19
+ diff-lcs (1.5.0)
20
+ i18n (1.10.0)
22
21
  concurrent-ruby (~> 1.0)
23
22
  method_source (1.0.0)
24
- minitest (5.14.4)
25
- parallel (1.21.0)
26
- parser (3.0.3.1)
23
+ minitest (5.15.0)
24
+ parallel (1.22.1)
25
+ parser (3.1.2.0)
27
26
  ast (~> 2.4.1)
28
27
  pry (0.14.1)
29
28
  coderay (~> 1.1)
30
29
  method_source (~> 1.0)
31
- rack (2.2.3)
32
- rainbow (3.0.0)
30
+ rack (2.2.3.1)
31
+ rainbow (3.1.1)
33
32
  rake (13.0.6)
34
- regexp_parser (2.2.0)
33
+ regexp_parser (2.5.0)
35
34
  rexml (3.2.5)
36
- rspec (3.10.0)
37
- rspec-core (~> 3.10.0)
38
- rspec-expectations (~> 3.10.0)
39
- rspec-mocks (~> 3.10.0)
40
- rspec-core (3.10.1)
41
- rspec-support (~> 3.10.0)
42
- rspec-expectations (3.10.1)
35
+ rspec (3.11.0)
36
+ rspec-core (~> 3.11.0)
37
+ rspec-expectations (~> 3.11.0)
38
+ rspec-mocks (~> 3.11.0)
39
+ rspec-core (3.11.0)
40
+ rspec-support (~> 3.11.0)
41
+ rspec-expectations (3.11.0)
43
42
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.10.0)
45
- rspec-mocks (3.10.2)
43
+ rspec-support (~> 3.11.0)
44
+ rspec-mocks (3.11.1)
46
45
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.10.0)
48
- rspec-support (3.10.3)
49
- rubocop (1.17.0)
46
+ rspec-support (~> 3.11.0)
47
+ rspec-support (3.11.0)
48
+ rubocop (1.30.0)
50
49
  parallel (~> 1.10)
51
- parser (>= 3.0.0.0)
50
+ parser (>= 3.1.0.0)
52
51
  rainbow (>= 2.2.2, < 4.0)
53
52
  regexp_parser (>= 1.8, < 3.0)
54
- rexml
55
- rubocop-ast (>= 1.7.0, < 2.0)
53
+ rexml (>= 3.2.5, < 4.0)
54
+ rubocop-ast (>= 1.18.0, < 2.0)
56
55
  ruby-progressbar (~> 1.7)
57
56
  unicode-display_width (>= 1.4.0, < 3.0)
58
- rubocop-ast (1.14.0)
59
- parser (>= 3.0.1.1)
60
- rubocop-config-umbrellio (1.17.0.53)
61
- rubocop (= 1.17.0)
62
- rubocop-performance (= 1.10.0)
63
- rubocop-rails (= 2.9.1)
64
- rubocop-rake (= 0.5.1)
65
- rubocop-rspec (= 2.2.0)
66
- rubocop-sequel (= 0.2.0)
67
- rubocop-performance (1.10.0)
68
- rubocop (>= 0.90.0, < 2.0)
57
+ rubocop-ast (1.18.0)
58
+ parser (>= 3.1.1.0)
59
+ rubocop-config-umbrellio (1.30.0.65)
60
+ rubocop (~> 1.30.0)
61
+ rubocop-performance (~> 1.14.0)
62
+ rubocop-rails (~> 2.14.2)
63
+ rubocop-rake (~> 0.6.0)
64
+ rubocop-rspec (~> 2.11.1)
65
+ rubocop-sequel (~> 0.3.3)
66
+ rubocop-performance (1.14.0)
67
+ rubocop (>= 1.7.0, < 2.0)
69
68
  rubocop-ast (>= 0.4.0)
70
- rubocop-rails (2.9.1)
69
+ rubocop-rails (2.14.2)
71
70
  activesupport (>= 4.2.0)
72
71
  rack (>= 1.1)
73
- rubocop (>= 0.90.0, < 2.0)
74
- rubocop-rake (0.5.1)
75
- rubocop
76
- rubocop-rspec (2.2.0)
72
+ rubocop (>= 1.7.0, < 2.0)
73
+ rubocop-rake (0.6.0)
77
74
  rubocop (~> 1.0)
78
- rubocop-ast (>= 1.1.0)
79
- rubocop-sequel (0.2.0)
75
+ rubocop-rspec (2.11.1)
76
+ rubocop (~> 1.19)
77
+ rubocop-sequel (0.3.3)
80
78
  rubocop (~> 1.0)
81
79
  ruby-progressbar (1.11.0)
82
80
  tzinfo (2.0.4)
83
81
  concurrent-ruby (~> 1.0)
84
82
  unicode-display_width (2.1.0)
85
- zeitwerk (2.5.1)
86
83
 
87
84
  PLATFORMS
88
85
  arm64-darwin-21
86
+ ruby
89
87
  x86_64-darwin-20
90
88
  x86_64-linux
91
89
 
@@ -98,4 +96,4 @@ DEPENDENCIES
98
96
  rubocop-config-umbrellio
99
97
 
100
98
  BUNDLED WITH
101
- 2.2.33
99
+ 2.3.14
data/README.md CHANGED
@@ -57,11 +57,11 @@ You can also override configuration file location using `--config` option.
57
57
 
58
58
  ### Helm dependency management
59
59
 
60
- Helmsnap will automically rebuild your chart dependencies on every snapshot generation or check. In case your dependency is using url to some local helm repo and you don't have a proper repo added, it will add it automically which is useful in CI. It also will detect local dependencies (those that start with `file://`) and rebuild their dependencies as well.
60
+ Helmsnap will automatically rebuild your chart dependencies on every snapshot generation or check. In case your dependency is using url to some local helm repo and you don't have a proper repo added, it will add it automatically which is useful in CI. It also will detect local dependencies (those that start with `file://`) and rebuild their dependencies as well.
61
61
 
62
62
  ### Timestamp replacement
63
63
 
64
- Helmsnap will automically replace all occurencies of patterns that look like timestamps (format like `2022-01-01 00:00:00.000`) in your templates. This is useful in case you have some annotations like `releaseTime` that would break your snapshots checks otherwise.
64
+ Helmsnap will automatically replace all occurencies of patterns that look like timestamps (format like `2022-01-01 00:00:00.000`) in your templates. This is useful in case you have some annotations like `releaseTime` that would break your snapshots checks otherwise.
65
65
 
66
66
  ## Installation
67
67
 
@@ -71,7 +71,11 @@ Just install the gem and use the provided `helmsnap` binary.
71
71
  gem install helmsnap
72
72
  ```
73
73
 
74
- Alaternatively, you can use the [Docker image](https://github.com/tycooon/helmsnap/pkgs/container/helmsnap) with Ruby, helm and helmsnap gem preinstalled. This is useful for CIs or if you don't want to install Ruby and Helmfile on your machine.
74
+ Alaternatively, you can use the [Docker image](https://github.com/tycooon/helmsnap/pkgs/container/helmsnap) with Ruby, helm and helmsnap gem preinstalled. This is useful for CIs or if you don't want to install Ruby and Helmfile on your machine. Here is an example docker command that can be used to generate snapshots:
75
+
76
+ ```sh
77
+ docker run --rm -it -w /wd -v $PWD:/wd ghcr.io/tycooon/helmsnap helmsnap generate
78
+ ```
75
79
 
76
80
  ## CI example
77
81
 
@@ -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)
@@ -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",
@@ -51,7 +51,10 @@ class Helmsnap::Runner < Helmsnap::Service
51
51
  Helmsnap::Console.error(
52
52
  $stdout,
53
53
  "Snapshots are outdated. You should check the diff above and either fix your chart or " \
54
- "update the snapshots using the following command:\n> #{example_cmd}",
54
+ "update the snapshots using the following command:\n> #{example_cmd}\n" \
55
+ "Please make sure that you have the latest version of helmsnap installed!\n\n" \
56
+ "In case you don't have Ruby on your machine, you can use the following Docker command:\n" \
57
+ "> docker run --rm -it -w /wd -v $PWD:/wd ghcr.io/tycooon/helmsnap #{example_cmd}",
55
58
  )
56
59
 
57
60
  exit 1
@@ -4,38 +4,42 @@ 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)
21
+ normalized_path = chart_path.expand_path
22
+ return if processed_paths.include?(normalized_path)
23
+ processed_paths << normalized_path
24
+
20
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", 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", chart_path)
36
+ update_deps!(chart_path)
31
37
  end
32
38
 
33
39
  def get_dependency_list(chart_path)
34
40
  base_cmd = ["helm", "dependency", "list", chart_path]
35
41
 
36
- result = run_cmd(
37
- *base_cmd, "--max-col-width", 0, allow_failure: true, stderr: File.open(File::NULL, "w")
38
- )
42
+ result = run_cmd(*base_cmd, "--max-col-width", 0, allow_failure: true, stderr: nil)
39
43
 
40
44
  if result.success
41
45
  result.output
@@ -47,4 +51,11 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
47
51
  end
48
52
  end
49
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
60
+ end
50
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.7.3"
4
+ VERSION = "0.8.0"
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.3
4
+ version: 0.8.0
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-15 00:00:00.000000000 Z
11
+ date: 2022-06-01 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.33
95
+ rubygems_version: 3.3.14
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: A tool for creating and checking helm chart snapshots.