helmsnap 0.6.2 → 0.7.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: baa082c302d4fbf9dd405a0d871b5183d30d5e966ffdb703c204d5be6ff01d1b
4
- data.tar.gz: d3f536543a6449564a472d02182de65bdcc788f5b8eb4f16c2729fe5e47b4d76
3
+ metadata.gz: 82cc0b42f25f49c54cb4ec921c092f7a3e6cc9de565bc3e39e357e4129b5c3ff
4
+ data.tar.gz: 0fc97b6105f8a9ab5fb8360bf390be3cfaea21bc24b21edf42960b88658c54a8
5
5
  SHA512:
6
- metadata.gz: 7bc52d8227544440bf5d4c5e6444f8945383792863eccfddfdaaf74eb6e8b2c36b80f0a01b92f6dedb0469e5b64989b6149fda7c808d13ab3ad4db6c67ef9b12
7
- data.tar.gz: 577045fed2ec342a4f97243f1ff143b4a525bf62ee895f1c5101b05c7e4ea1212b47a2a053d3c554f1be1e441cbb49c6d20ee6afd7d51fe8d1a0761f6b3db646
6
+ metadata.gz: f514cd9633fab8f88efac3ae96dda8579c9b8dbd2a90da8822979958c334681e0b882c498e1b4acfeda279814beeaf181fd942366b036da04100b62cbe1d9dc8
7
+ data.tar.gz: 5b9046c477241a66acbe1a2bc8b7f982205b49bbcf3f53edbeb1f4f516b4008f0ab4c52aeb5f829538796a1f717931588bea7abce9d33ecd9726031fe43c24dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.6.2)
4
+ helmsnap (0.7.0)
5
5
  colorize
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## About
4
4
 
5
- Helmsnap is a tool for generating and checking helm chart snapshots. Example:
5
+ Helmsnap is a tool for generating and checking helmfile snapshots. Example:
6
6
 
7
7
  Generate snapshots (uses `helmfile template` under the hood):
8
8
 
@@ -16,6 +16,12 @@ Generate snapshots in a temporary directory and check (diff) them against existi
16
16
  helmsnap check
17
17
  ```
18
18
 
19
+ Just build dependencies for each release in a helmfile:
20
+
21
+ ```sh
22
+ helmsnap dependencies # or `helmsnap deps`
23
+ ```
24
+
19
25
  Get the full description of possible arguments:
20
26
 
21
27
  ```sh
@@ -59,13 +65,13 @@ Helmsnap will automically replace all occurencies of patterns that look like tim
59
65
 
60
66
  ## Installation
61
67
 
62
- Just install a gem and use the provided `helmsnap` binary.
68
+ Just install the gem and use the provided `helmsnap` binary.
63
69
 
64
70
  ```sh
65
71
  gem install helmsnap
66
72
  ```
67
73
 
68
- Alaternatively, you can use a [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 locally.
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.
69
75
 
70
76
  ## CI example
71
77
 
@@ -34,7 +34,7 @@ class Helmsnap::ArgsParser
34
34
 
35
35
  def build_parser
36
36
  OptionParser.new(BANNER, 50) do |opts|
37
- opts.separator("Supported commands: `generate` and `check`.")
37
+ opts.separator("Supported commands: `generate`, `check` and `dependencies`.")
38
38
  opts.separator("")
39
39
  opts.separator("Specific options:")
40
40
 
data/lib/helmsnap/env.rb CHANGED
@@ -1,19 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::Env
4
- attr_reader :name, :release_paths
4
+ attr_reader :name
5
5
 
6
6
  def initialize(name)
7
7
  self.name = name
8
- self.release_paths = get_release_paths
9
8
  end
10
9
 
11
- private
10
+ def release_paths
11
+ @release_paths ||= begin
12
+ json = Helmsnap.run_cmd("helmfile", "--environment", name, "list", "--output", "json").output
13
+ YAML.load(json).map { |x| x.fetch("chart") }
14
+ end
15
+ end
12
16
 
13
- attr_writer :name, :release_paths
17
+ private
14
18
 
15
- def get_release_paths
16
- json = Helmsnap.run_cmd("helmfile", "--environment", name, "list", "--output", "json").output
17
- YAML.load(json).map { |x| x.fetch("chart") }
18
- end
19
+ attr_writer :name
19
20
  end
@@ -10,9 +10,7 @@ class Helmsnap::Generate < Helmsnap::Service
10
10
  def call
11
11
  FileUtils.rmtree(snapshots_path)
12
12
 
13
- config.envs.flat_map(&:release_paths).uniq.each do |release_path|
14
- Helmsnap::SetupDependencies.call(release_path)
15
- end
13
+ Helmsnap::SetupDependencies.call(config)
16
14
 
17
15
  config.envs.each do |env|
18
16
  run_cmd(
@@ -26,6 +26,8 @@ class Helmsnap::Runner < Helmsnap::Service
26
26
  generate!
27
27
  when "check"
28
28
  check!
29
+ when "dependencies", "deps"
30
+ setup_deps!
29
31
  else
30
32
  parser.print_help!("Unknown command: #{cmd}.")
31
33
  end
@@ -55,4 +57,8 @@ class Helmsnap::Runner < Helmsnap::Service
55
57
  exit 1
56
58
  end
57
59
  end
60
+
61
+ def setup_deps!
62
+ Helmsnap::SetupDependencies.call(config)
63
+ end
58
64
  end
@@ -1,12 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::SetupDependencies < Helmsnap::Service
4
- def initialize(chart_path)
4
+ def initialize(config)
5
5
  super()
6
- self.chart_path = Pathname.new(chart_path)
6
+ self.config = config
7
7
  end
8
8
 
9
9
  def call
10
+ config.envs.flat_map(&:release_paths).uniq.each do |chart_path|
11
+ setup!(chart_path)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ attr_accessor :config
18
+
19
+ def setup!(chart_path)
10
20
  dep_list = run_cmd("helm", "dependency", "list", "--max-col-width", 0, chart_path).output
11
21
 
12
22
  dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
@@ -19,8 +29,4 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
19
29
 
20
30
  run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
21
31
  end
22
-
23
- private
24
-
25
- attr_accessor :chart_path
26
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.6.2"
4
+ VERSION = "0.7.0"
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.6.2
4
+ version: 0.7.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-04 00:00:00.000000000 Z
11
+ date: 2021-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize