helmsnap 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/helmsnap/check.rb +16 -17
- data/lib/helmsnap/command.rb +19 -14
- data/lib/helmsnap/generate.rb +3 -20
- data/lib/helmsnap/runner.rb +4 -5
- data/lib/helmsnap/service.rb +13 -0
- data/lib/helmsnap/setup_dependencies.rb +26 -0
- data/lib/helmsnap/version.rb +1 -1
- data/lib/helmsnap.rb +5 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16b948e025e8c80533fc75ac8d97dc0ff3e4fc4996df3fdf9f8c65957c4dd8a4
|
4
|
+
data.tar.gz: b551e8a5570cedb694e8d19ae9143d9d100eb29c0d4956ed2d02ab2d9c1a8711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f706419bc87c20f4d29baabb8e64678d5565b8ba3c889aefe68f44eaf91b7798e8802fadffd819260f2fea00c98d483a063a1c903f8b31db227bbf903391067c
|
7
|
+
data.tar.gz: a6e48a1928f2af7ff6da52efd48b7578d80143c6ef7866fbcaaeb37bf47cec5cfdb618c3f91a85a2cea40b93415730248a675c2fa3280125b51c4aa893584f6b
|
data/Gemfile.lock
CHANGED
data/lib/helmsnap/check.rb
CHANGED
@@ -1,32 +1,31 @@
|
|
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
|
12
9
|
end
|
13
10
|
|
14
11
|
def call
|
15
|
-
Dir.mktmpdir
|
16
|
-
|
12
|
+
temp_dir_path = Pathname.new(Dir.mktmpdir)
|
13
|
+
|
14
|
+
Helmsnap::Generate.call(
|
15
|
+
chart_path: chart_path,
|
16
|
+
snapshots_path: temp_dir_path,
|
17
|
+
values_path: values_path,
|
18
|
+
)
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
snapshots_path: temp_dir_path,
|
21
|
-
values_path: values_path,
|
22
|
-
)
|
20
|
+
result = run_cmd("which", "colordiff", allow_failure: true)
|
21
|
+
util = result.success ? "colordiff" : "diff"
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
cmd_parts = [util, "--unified", "--recursive", snapshots_path, temp_dir_path]
|
24
|
+
diff = run_cmd(*cmd_parts, allow_failure: true).output
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
diff.strip.empty?
|
27
|
+
ensure
|
28
|
+
FileUtils.rmtree(temp_dir_path)
|
30
29
|
end
|
31
30
|
|
32
31
|
private
|
data/lib/helmsnap/command.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
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
|
9
|
+
self.output = +""
|
12
10
|
self.stdout = stdout
|
13
11
|
self.stderr = stderr
|
14
12
|
self.allow_failure = allow_failure
|
@@ -21,12 +19,10 @@ class Helmsnap::Command
|
|
21
19
|
|
22
20
|
private
|
23
21
|
|
24
|
-
attr_accessor :cmd, :stdout, :stderr, :allow_failure
|
22
|
+
attr_accessor :cmd, :output, :stdout, :stderr, :allow_failure
|
25
23
|
|
26
24
|
def run_command
|
27
25
|
Open3.popen3(cmd) do |_in, out, err, wait_thr|
|
28
|
-
output = +""
|
29
|
-
|
30
26
|
while (chunk = out.gets)
|
31
27
|
Helmsnap::Console.print(stdout, chunk)
|
32
28
|
output << chunk
|
@@ -34,15 +30,24 @@ class Helmsnap::Command
|
|
34
30
|
|
35
31
|
exit_status = wait_thr.value
|
36
32
|
success = exit_status.success?
|
37
|
-
|
38
|
-
if !success && !allow_failure
|
39
|
-
Helmsnap::Console.error(stderr, err.read)
|
40
|
-
Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
|
41
|
-
abort
|
42
|
-
end
|
33
|
+
handle_error!(exit_status, err.read) unless success
|
43
34
|
|
44
35
|
Helmsnap::Console.print(stdout, "\n")
|
45
36
|
Result.new(success, output)
|
46
37
|
end
|
38
|
+
rescue SystemCallError => error
|
39
|
+
handle_error!(error.errno, error.message)
|
40
|
+
Result.new(false, error.message)
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_error!(exit_status, err_output)
|
44
|
+
Helmsnap::Console.error(stderr, err_output)
|
45
|
+
|
46
|
+
if allow_failure
|
47
|
+
output << err_output
|
48
|
+
else
|
49
|
+
Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
|
50
|
+
exit 1
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
data/lib/helmsnap/generate.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/helmsnap/runner.rb
CHANGED
@@ -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,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
|
data/lib/helmsnap/version.rb
CHANGED
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/
|
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
|
+
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-
|
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:
|