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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00d1a53c6e09960c8a7b6d21e9998aba27e0765959b4450f2e433754440fe65b
4
- data.tar.gz: 0f9fc47f9897eb76745e817528646ac340e43e39fad563a8370560bde810274f
3
+ metadata.gz: 8fbee3f7ea1da8f3400fa518d3f2a083b62274d9e11f11d472da24e74904de2a
4
+ data.tar.gz: ee79318dba8a65d214e6d64e27f4f91ee56d3c6e3ba125825ec8b627daf31b9f
5
5
  SHA512:
6
- metadata.gz: d014a938da2ea497e3e751f5cb600940ccb77a1d7bd297399a7b3380ac74c2d5a47bb9b4c31f6a540992c72d3e1012540d19b264e49d3498ffc282cb4f63b68a
7
- data.tar.gz: 17614166a76919b0353d7bf322062047c546c3256826758ef5d0991bf66e30ee7ad0552c117ebad489ecba205e7c4771340dde7c947975cd1101895954eb8fe9
6
+ metadata.gz: 80a280fe7d8f000f0706e0087cbc7607acdb1962b04ccb4154c64263dfba0ebf9fc50c086786fd2c06251fc3918762a3b83b7058344261ad615c603d1d011dde
7
+ data.tar.gz: 7534803fc0f920d817905a4cbdcdea81fd603daa06ce614a10cdfeee2a28a13cd82691d6c6d2217b5c987e99e2a87a7999d35362fa7304718378b63300cea2b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.6.0)
4
+ helmsnap (0.6.1)
5
5
  colorize
6
6
 
7
7
  GEM
@@ -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
- args.config_path = Pathname.new(val)
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
@@ -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
- yaml = YAML.load_file(config_path.to_s)
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
- # TODO: chekc value type/presence
26
- Pathname.new(yaml.fetch("snapshotsPath"))
30
+ Pathname.new(yaml.fetch("snapshotsPath", DEFAULT_SNAPSHOTS_PATH))
27
31
  end
28
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helmsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov