helmsnap 0.4.2 → 0.5.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: 8a5cb05f018581cbbccdfd9114f0ce1426457d63bd4fcd69864d558a6c790be5
4
- data.tar.gz: c6ff86c42987cbebe2fb71889d05dd0d11e33d0ca164a89419c75b58a6b671ab
3
+ metadata.gz: 16b948e025e8c80533fc75ac8d97dc0ff3e4fc4996df3fdf9f8c65957c4dd8a4
4
+ data.tar.gz: b551e8a5570cedb694e8d19ae9143d9d100eb29c0d4956ed2d02ab2d9c1a8711
5
5
  SHA512:
6
- metadata.gz: 60bf1bbab69d1990b05d93bcc3b22b67318f665d431ea2b770a6eddf894a6df800d139b32cdd35d61905067fd7e52ae21d91b069d94a99736ea57d25f9968ee6
7
- data.tar.gz: 804d6d566f1e6c546f1f94a9235b43ba69fb451f298987855c40a281033144fd1ee44ea53e0fdf764f1d6f2bfe29e6902fd1bb065d75f6b4eba3212feaca367a
6
+ metadata.gz: f706419bc87c20f4d29baabb8e64678d5565b8ba3c889aefe68f44eaf91b7798e8802fadffd819260f2fea00c98d483a063a1c903f8b31db227bbf903391067c
7
+ data.tar.gz: a6e48a1928f2af7ff6da52efd48b7578d80143c6ef7866fbcaaeb37bf47cec5cfdb618c3f91a85a2cea40b93415730248a675c2fa3280125b51c4aa893584f6b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.4.2)
4
+ helmsnap (0.5.0)
5
5
  colorize
6
6
 
7
7
  GEM
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Helmsnap::Check
4
- def self.call(...)
5
- new(...).call
6
- end
7
-
3
+ class Helmsnap::Check < Helmsnap::Service
8
4
  def initialize(chart_path:, snapshots_path:, values_path:)
5
+ super()
9
6
  self.chart_path = chart_path
10
7
  self.snapshots_path = snapshots_path
11
8
  self.values_path = values_path
@@ -20,11 +17,11 @@ class Helmsnap::Check
20
17
  values_path: values_path,
21
18
  )
22
19
 
23
- result = Helmsnap.run_cmd("which", "colordiff", allow_failure: true)
20
+ result = run_cmd("which", "colordiff", allow_failure: true)
24
21
  util = result.success ? "colordiff" : "diff"
25
22
 
26
23
  cmd_parts = [util, "--unified", "--recursive", snapshots_path, temp_dir_path]
27
- diff = Helmsnap.run_cmd(*cmd_parts, allow_failure: true).output
24
+ diff = run_cmd(*cmd_parts, allow_failure: true).output
28
25
 
29
26
  diff.strip.empty?
30
27
  ensure
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Helmsnap::Command
3
+ class Helmsnap::Command < Helmsnap::Service
4
4
  Result = Struct.new(:success, :output)
5
5
 
6
- def self.call(...)
7
- new(...).call
8
- end
9
-
10
6
  def initialize(cmd, stdout: $stdout, stderr: $stderr, allow_failure: false)
7
+ super()
11
8
  self.cmd = cmd
12
9
  self.output = +""
13
10
  self.stdout = stdout
@@ -38,6 +35,9 @@ class Helmsnap::Command
38
35
  Helmsnap::Console.print(stdout, "\n")
39
36
  Result.new(success, output)
40
37
  end
38
+ rescue SystemCallError => error
39
+ handle_error!(error.errno, error.message)
40
+ Result.new(false, error.message)
41
41
  end
42
42
 
43
43
  def handle_error!(exit_status, err_output)
@@ -1,28 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Helmsnap::Generate
4
- def self.call(...)
5
- new(...).call
6
- end
7
-
3
+ class Helmsnap::Generate < Helmsnap::Service
8
4
  def initialize(chart_path:, snapshots_path:, values_path:)
5
+ super()
9
6
  self.chart_path = chart_path
10
7
  self.snapshots_path = snapshots_path
11
8
  self.values_path = values_path
12
9
  end
13
10
 
14
11
  def call
15
- dep_list = run_cmd("helm", "dependency", "list", "--max-col-width", 0, chart_path).output
16
-
17
- dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
18
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first))
19
- end
20
-
21
- dep_list.scan(%r{(https?://.+?)\t}) do |dep_path|
22
- run_cmd("helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first)
23
- end
24
-
25
- run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
12
+ Helmsnap::SetupDependencies.call(chart_path)
26
13
 
27
14
  FileUtils.rmtree(snapshots_path)
28
15
 
@@ -40,8 +27,4 @@ class Helmsnap::Generate
40
27
  private
41
28
 
42
29
  attr_accessor :chart_path, :snapshots_path, :values_path
43
-
44
- def run_cmd(...)
45
- Helmsnap.run_cmd(...)
46
- end
47
30
  end
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Helmsnap::Runner
4
- def self.call(...)
5
- new(...).call
6
- end
7
-
3
+ class Helmsnap::Runner < Helmsnap::Service
8
4
  def initialize(args)
5
+ super()
9
6
  self.args = args.dup
10
7
  end
11
8
 
12
9
  def call
10
+ super()
11
+
13
12
  parser = Helmsnap::ArgsParser.new(args)
14
13
  self.options = parser.get_options!
15
14
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Helmsnap::Service
4
+ def self.call(...)
5
+ new(...).call
6
+ end
7
+
8
+ private
9
+
10
+ def run_cmd(...)
11
+ Helmsnap.run_cmd(...)
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Helmsnap::SetupDependencies < Helmsnap::Service
4
+ def initialize(chart_path)
5
+ super()
6
+ self.chart_path = Pathname.new(chart_path)
7
+ end
8
+
9
+ def call
10
+ dep_list = run_cmd("helm", "dependency", "list", "--max-col-width", 0, chart_path).output
11
+
12
+ dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
13
+ run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first))
14
+ end
15
+
16
+ dep_list.scan(%r{(https?://.+?)\t}) do |dep_path|
17
+ run_cmd("helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first)
18
+ end
19
+
20
+ run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
21
+ end
22
+
23
+ private
24
+
25
+ attr_accessor :chart_path
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/helmsnap.rb CHANGED
@@ -11,13 +11,16 @@ require "tmpdir"
11
11
  require "colorized_string"
12
12
 
13
13
  module Helmsnap
14
+ require_relative "helmsnap/service"
15
+ require_relative "helmsnap/version"
16
+
14
17
  require_relative "helmsnap/args_parser"
15
18
  require_relative "helmsnap/check"
16
- require_relative "helmsnap/console"
17
19
  require_relative "helmsnap/command"
20
+ require_relative "helmsnap/console"
18
21
  require_relative "helmsnap/generate"
19
22
  require_relative "helmsnap/runner"
20
- require_relative "helmsnap/version"
23
+ require_relative "helmsnap/setup_dependencies"
21
24
 
22
25
  class Error < StandardError; end
23
26
 
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.4.2
4
+ version: 0.5.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-01 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -66,6 +66,8 @@ files:
66
66
  - lib/helmsnap/console.rb
67
67
  - lib/helmsnap/generate.rb
68
68
  - lib/helmsnap/runner.rb
69
+ - lib/helmsnap/service.rb
70
+ - lib/helmsnap/setup_dependencies.rb
69
71
  - lib/helmsnap/version.rb
70
72
  homepage: https://github.com/tycooon/helmsnap
71
73
  licenses: