helmsnap 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/helmsnap/args_parser.rb +12 -4
- data/lib/helmsnap/config.rb +8 -4
- data/lib/helmsnap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fbee3f7ea1da8f3400fa518d3f2a083b62274d9e11f11d472da24e74904de2a
|
4
|
+
data.tar.gz: ee79318dba8a65d214e6d64e27f4f91ee56d3c6e3ba125825ec8b627daf31b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a280fe7d8f000f0706e0087cbc7607acdb1962b04ccb4154c64263dfba0ebf9fc50c086786fd2c06251fc3918762a3b83b7058344261ad615c603d1d011dde
|
7
|
+
data.tar.gz: 7534803fc0f920d817905a4cbdcdea81fd603daa06ce614a10cdfeee2a28a13cd82691d6c6d2217b5c987e99e2a87a7999d35362fa7304718378b63300cea2b6
|
data/Gemfile.lock
CHANGED
data/lib/helmsnap/args_parser.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Helmsnap::ArgsParser
|
4
|
+
InvalidConfigPath = Class.new(RuntimeError)
|
5
|
+
|
4
6
|
Args = Struct.new(:config_path)
|
5
7
|
|
6
|
-
DEFAULT_CONFIG_PATH = ".helmsnap.yaml"
|
8
|
+
DEFAULT_CONFIG_PATH = Pathname.new(".helmsnap.yaml")
|
7
9
|
CONFIG_PATH_HELP = %{Path to config (default: "#{DEFAULT_CONFIG_PATH}")}
|
8
10
|
BANNER = "Usage: helmsnap CMD [options]"
|
9
11
|
|
@@ -16,8 +18,8 @@ class Helmsnap::ArgsParser
|
|
16
18
|
def get_options!
|
17
19
|
parser.parse!(options)
|
18
20
|
args
|
19
|
-
rescue OptionParser::ParseError => error
|
20
|
-
print_help!(error)
|
21
|
+
rescue OptionParser::ParseError, InvalidConfigPath => error
|
22
|
+
print_help!(error.message)
|
21
23
|
end
|
22
24
|
|
23
25
|
def print_help!(msg)
|
@@ -37,7 +39,13 @@ class Helmsnap::ArgsParser
|
|
37
39
|
opts.separator("Specific options:")
|
38
40
|
|
39
41
|
opts.on("-c", "--config CONFIG_PATH", CONFIG_PATH_HELP) do |val|
|
40
|
-
|
42
|
+
path = Pathname.new(val)
|
43
|
+
|
44
|
+
unless path.file? && path.readable?
|
45
|
+
raise InvalidConfigPath, "Not a readable file: #{val}"
|
46
|
+
end
|
47
|
+
|
48
|
+
args.config_path = path
|
41
49
|
end
|
42
50
|
|
43
51
|
opts.on("--version", "Show version") do
|
data/lib/helmsnap/config.rb
CHANGED
@@ -4,9 +4,15 @@ class Helmsnap::Config
|
|
4
4
|
attr_reader :envs, :snapshots_path
|
5
5
|
|
6
6
|
DEFAULT_ENV = "default"
|
7
|
+
DEFAULT_SNAPSHOTS_PATH = "helm/snapshots"
|
7
8
|
|
8
9
|
def initialize(config_path)
|
9
|
-
|
10
|
+
if config_path.exist?
|
11
|
+
yaml = YAML.load_file(config_path.to_s)
|
12
|
+
else
|
13
|
+
yaml = {}
|
14
|
+
end
|
15
|
+
|
10
16
|
self.envs = parse_envs(yaml)
|
11
17
|
self.snapshots_path = parse_snaphots_path(yaml)
|
12
18
|
end
|
@@ -16,13 +22,11 @@ class Helmsnap::Config
|
|
16
22
|
attr_writer :envs, :snapshots_path
|
17
23
|
|
18
24
|
def parse_envs(yaml)
|
19
|
-
# TODO: check value type
|
20
25
|
value = yaml.fetch("envs", [DEFAULT_ENV])
|
21
26
|
value.map { |x| Helmsnap::Env.new(x) }
|
22
27
|
end
|
23
28
|
|
24
29
|
def parse_snaphots_path(yaml)
|
25
|
-
|
26
|
-
Pathname.new(yaml.fetch("snapshotsPath"))
|
30
|
+
Pathname.new(yaml.fetch("snapshotsPath", DEFAULT_SNAPSHOTS_PATH))
|
27
31
|
end
|
28
32
|
end
|
data/lib/helmsnap/version.rb
CHANGED