helmsnap 0.6.1 → 0.7.2
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/README.md +9 -3
- data/lib/helmsnap/args_parser.rb +2 -2
- data/lib/helmsnap/console.rb +5 -0
- data/lib/helmsnap/env.rb +9 -8
- data/lib/helmsnap/generate.rb +1 -3
- data/lib/helmsnap/runner.rb +6 -0
- data/lib/helmsnap/setup_dependencies.rb +29 -5
- data/lib/helmsnap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9cb2c9877035f1985755a911222b07dc1233cf1ae8e2d98a909a082641cf1b
|
4
|
+
data.tar.gz: 3577227a017c7f6d35c005fb015a36c759562ebdfe59404d4354bd4e55e5418a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6173167f7f54f425d57c15d216297f77f75ff071b0b2e351d4d7ba60d59c34468a6a0e4bb089936dd800da716ba41f90b86ba881e7cab83bc4ad4db1c794e35
|
7
|
+
data.tar.gz: e7d664ebd56ea11cd15b0afb3d049488c93ec26cafa74e6860c6f31d9de9fa5b92804c2bcff6a92b7f7519482497618fa321ef7840a6af87c0464dcacb356e6d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## About
|
4
4
|
|
5
|
-
Helmsnap is a tool for generating and checking
|
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
|
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
|
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
|
|
data/lib/helmsnap/args_parser.rb
CHANGED
@@ -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 `
|
37
|
+
opts.separator("Supported commands: `generate`, `check` and `dependencies`.")
|
38
38
|
opts.separator("")
|
39
39
|
opts.separator("Specific options:")
|
40
40
|
|
@@ -48,7 +48,7 @@ class Helmsnap::ArgsParser
|
|
48
48
|
args.config_path = path
|
49
49
|
end
|
50
50
|
|
51
|
-
opts.on("--version", "Show version") do
|
51
|
+
opts.on("-v", "--version", "Show version") do
|
52
52
|
Helmsnap::Console.print($stdout, "#{Helmsnap::VERSION}\n")
|
53
53
|
exit
|
54
54
|
end
|
data/lib/helmsnap/console.rb
CHANGED
@@ -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
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Helmsnap::Env
|
4
|
-
attr_reader :name
|
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
|
-
|
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| Pathname.new(x.fetch("chart")) }
|
14
|
+
end
|
15
|
+
end
|
12
16
|
|
13
|
-
|
17
|
+
private
|
14
18
|
|
15
|
-
|
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
|
data/lib/helmsnap/generate.rb
CHANGED
@@ -10,9 +10,7 @@ class Helmsnap::Generate < Helmsnap::Service
|
|
10
10
|
def call
|
11
11
|
FileUtils.rmtree(snapshots_path)
|
12
12
|
|
13
|
-
|
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(
|
data/lib/helmsnap/runner.rb
CHANGED
@@ -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,13 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Helmsnap::SetupDependencies < Helmsnap::Service
|
4
|
-
def initialize(
|
4
|
+
def initialize(config)
|
5
5
|
super()
|
6
|
-
self.
|
6
|
+
self.config = config
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
|
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)
|
20
|
+
dep_list = get_dependency_list(chart_path)
|
11
21
|
|
12
22
|
dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
|
13
23
|
run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first))
|
@@ -20,7 +30,21 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
|
|
20
30
|
run_cmd("helm", "dependency", "update", "--skip-refresh", chart_path)
|
21
31
|
end
|
22
32
|
|
23
|
-
|
33
|
+
def get_dependency_list(chart_path)
|
34
|
+
base_cmd = ["helm", "dependency", "list", chart_path]
|
35
|
+
|
36
|
+
result = run_cmd(
|
37
|
+
*base_cmd, "--max-col-width", 0, allow_failure: true, stderr: File.open(File::NULL, "w")
|
38
|
+
)
|
24
39
|
|
25
|
-
|
40
|
+
if result.success
|
41
|
+
result.output
|
42
|
+
else
|
43
|
+
run_cmd(*base_cmd).output.tap do
|
44
|
+
Helmsnap::Console.warning(
|
45
|
+
$stderr, "it looks like your Helm binary is outdated, please update.\n"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
26
50
|
end
|
data/lib/helmsnap/version.rb
CHANGED
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.7.2
|
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-
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|