helmsnap 1.2.1 → 1.3.0

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: 306405fefdd0a806b1e89fd691a7412686218ffaeb981a9685e40ee6ff5a8880
4
- data.tar.gz: 644a72cc622dcefe774bea2acc8cd9816f770290e4704b28aafa3b6311dae122
3
+ metadata.gz: 7bfa93a759d6c9f6d753c3989f07c7f82d79d8de5f5f805e7c7a7cda55f9ef1e
4
+ data.tar.gz: 4d2dda18ef0b4de8dbc9d015f90bc35b8e93b6217a9c9d62a25864414b46b10a
5
5
  SHA512:
6
- metadata.gz: d6c09ccb98572852ee4877afbe6c3371cb03e9a6df5476057770bee762e9f0a6f9eb3dab20e0c3d2de97c827ce1d4e2b1b524214f671ffe0c58c81fb1d40a00b
7
- data.tar.gz: b0d4ba70df6544b282ba24b3dbefe8882f0a2cafe0634f60666ed8ca05209462e73303bc5a82fbb6edebb64fb8dbe3a7dfdc660df59b2566bdcc67dae670acb1
6
+ metadata.gz: 07d92385f7f114b15e7dcd3ca25ac2d05b614d63cc91922878b868551e4b69c06ddc7511b7b3e2e0166c3ec3a0547b4b7a18a1825c1c922b4ed939e3fe405529
7
+ data.tar.gz: 034226de8b3c1008bfd9ae95ce7a5fa161a49a8ee52e9c6974db260775eed3e19715eeab670e3e1668c4014a1142317bee3e300410b910ee68a007284c9bd2ae
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
+ gem "logger"
7
8
  gem "pry"
8
9
  gem "rake"
9
10
  gem "rspec"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (1.2.1)
4
+ helmsnap (1.3.0)
5
5
  colorize
6
6
 
7
7
  GEM
@@ -30,6 +30,7 @@ GEM
30
30
  concurrent-ruby (~> 1.0)
31
31
  json (2.7.2)
32
32
  language_server-protocol (3.17.0.3)
33
+ logger (1.6.6)
33
34
  method_source (1.1.0)
34
35
  minitest (5.25.1)
35
36
  mutex_m (0.2.0)
@@ -107,6 +108,7 @@ PLATFORMS
107
108
 
108
109
  DEPENDENCIES
109
110
  helmsnap!
111
+ logger
110
112
  pry
111
113
  rake
112
114
  rspec
data/README.md CHANGED
@@ -49,6 +49,8 @@ credentials: # [] by default
49
49
  password: somepassword
50
50
  ```
51
51
 
52
+ Credentials will be matched by prefix, so if your repo URL is `https://example.com/some/path/to/repo`, you can also put values like `https://example.com/some/path` or `https://example.com` in `credentials.[].repo`.
53
+
52
54
  You can also override configuration file location using `--config` option.
53
55
 
54
56
  ## Dependencies
@@ -3,7 +3,7 @@
3
3
  class Helmsnap::ArgsParser
4
4
  InvalidConfigPath = Class.new(RuntimeError)
5
5
 
6
- Args = Struct.new(:config_path)
6
+ Args = Struct.new(:config_path, :skip_repo_cleanup)
7
7
 
8
8
  DEFAULT_CONFIG_PATH = Pathname.new(".helmsnap.yaml")
9
9
  CONFIG_PATH_HELP = %{Path to config (default: "#{DEFAULT_CONFIG_PATH}")}.freeze
@@ -38,14 +38,12 @@ class Helmsnap::ArgsParser
38
38
  opts.separator("")
39
39
  opts.separator("Specific options:")
40
40
 
41
- opts.on("-c", "--config CONFIG_PATH", CONFIG_PATH_HELP) do |val|
42
- path = Pathname.new(val)
43
-
44
- unless path.file? && path.readable?
45
- raise InvalidConfigPath, "Not a readable file: #{val}"
46
- end
41
+ opts.on("-c", "--config CONFIG_PATH", CONFIG_PATH_HELP) do |value|
42
+ set_config!(value)
43
+ end
47
44
 
48
- args.config_path = path
45
+ opts.on("--skip-repo-cleanup", "Skip cleaning up existing helmsnap-related helm repos") do
46
+ args.skip_repo_cleanup = true
49
47
  end
50
48
 
51
49
  opts.on("-v", "--version", "Show version") do
@@ -59,4 +57,14 @@ class Helmsnap::ArgsParser
59
57
  end
60
58
  end
61
59
  end
60
+
61
+ def set_config!(value)
62
+ path = Pathname.new(value)
63
+
64
+ unless path.file? && path.readable?
65
+ raise InvalidConfigPath, "Not a readable file: #{value}"
66
+ end
67
+
68
+ args.config_path = path
69
+ end
62
70
  end
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::Check < Helmsnap::Service
4
- def initialize(config)
4
+ def initialize(config, options)
5
5
  super()
6
6
  self.config = config
7
+ self.options = options
7
8
  end
8
9
 
9
10
  def call
10
11
  temp_dir_path = Pathname.new(Dir.mktmpdir)
11
12
 
12
- Helmsnap::Generate.call(config, snapshots_path: temp_dir_path)
13
+ Helmsnap::Generate.call(config, options, snapshots_path: temp_dir_path)
13
14
 
14
15
  result = run_cmd("which", "colordiff", allow_failure: true)
15
16
  util = result.success ? "colordiff" : "diff"
@@ -24,5 +25,5 @@ class Helmsnap::Check < Helmsnap::Service
24
25
 
25
26
  private
26
27
 
27
- attr_accessor :config
28
+ attr_accessor :config, :options
28
29
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::Config
4
- Credentials = Struct.new(:username, :password)
4
+ Credentials = Struct.new(:repo, :username, :password)
5
5
 
6
6
  attr_reader :envs, :snapshots_path, :credentials
7
7
 
@@ -34,8 +34,8 @@ class Helmsnap::Config
34
34
  end
35
35
 
36
36
  def parse_credentials(yaml)
37
- yaml.fetch("credentials", []).each_with_object({}) do |obj, credentials|
38
- credentials[obj["repo"]] = Credentials.new(obj["username"], obj["password"])
37
+ yaml.fetch("credentials", []).map do |obj|
38
+ Credentials.new(obj["repo"], obj["username"], obj["password"])
39
39
  end
40
40
  end
41
41
  end
@@ -1,14 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::Generate < Helmsnap::Service
4
- def initialize(config, snapshots_path: nil)
4
+ def initialize(config, options, snapshots_path: nil)
5
5
  super()
6
6
  self.config = config
7
+ self.options = options
7
8
  self.snapshots_path = snapshots_path || config.snapshots_path
8
9
  end
9
10
 
10
11
  def call
11
- Helmsnap::SetupDependencies.call(config)
12
+ Helmsnap::SetupDependencies.call(config, options)
12
13
 
13
14
  Dir.mktmpdir do |tmpdir|
14
15
  tmp_path = Pathname.new(tmpdir)
@@ -18,7 +19,7 @@ class Helmsnap::Generate < Helmsnap::Service
18
19
 
19
20
  private
20
21
 
21
- attr_accessor :config, :snapshots_path
22
+ attr_accessor :config, :options, :snapshots_path
22
23
 
23
24
  def generate!(tmp_path)
24
25
  config.envs.each do |env|
@@ -38,12 +38,12 @@ class Helmsnap::Runner < Helmsnap::Service
38
38
  attr_accessor :args, :options, :config
39
39
 
40
40
  def generate!
41
- Helmsnap::Generate.call(config)
41
+ Helmsnap::Generate.call(config, options)
42
42
  Helmsnap::Console.info($stdout, "Snapshots generated successfully.")
43
43
  end
44
44
 
45
45
  def check!
46
- if Helmsnap::Check.call(config)
46
+ if Helmsnap::Check.call(config, options)
47
47
  Helmsnap::Console.info($stdout, "Snapshots are up-to-date.")
48
48
  else
49
49
  example_cmd = Shellwords.join(["helmsnap", "generate", "--config", options.config_path])
@@ -62,6 +62,6 @@ class Helmsnap::Runner < Helmsnap::Service
62
62
  end
63
63
 
64
64
  def setup_deps!
65
- Helmsnap::SetupDependencies.call(config)
65
+ Helmsnap::SetupDependencies.call(config, options)
66
66
  end
67
67
  end
@@ -3,14 +3,15 @@
3
3
  class Helmsnap::SetupDependencies < Helmsnap::Service
4
4
  REPO_NAME_PREFIX = "helmsnap-"
5
5
 
6
- def initialize(config)
6
+ def initialize(config, options)
7
7
  super()
8
8
  self.config = config
9
+ self.options = options
9
10
  self.processed_paths = Set.new
10
11
  end
11
12
 
12
13
  def call
13
- clear_existing_repos!
14
+ clear_existing_repos! unless options.skip_repo_cleanup
14
15
 
15
16
  config.envs.flat_map(&:release_paths).each do |chart_path|
16
17
  setup!(chart_path)
@@ -19,7 +20,7 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
19
20
 
20
21
  private
21
22
 
22
- attr_accessor :config, :processed_paths
23
+ attr_accessor :config, :options, :processed_paths
23
24
 
24
25
  def clear_existing_repos!
25
26
  result = run_cmd("helm", "repo", "ls", allow_failure: true).output
@@ -44,7 +45,7 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
44
45
  dep_list.scan(%r{(https?://.+?)\s}) do |dep_path|
45
46
  url = dep_path.first
46
47
 
47
- if (credentials = config.credentials[url])
48
+ if (credentials = config.credentials.find { |x| url.start_with?(x.repo) })
48
49
  extra_args = ["--username", credentials.username, "--password", credentials.password]
49
50
  end
50
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "1.2.1"
4
+ VERSION = "1.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helmsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
- original_platform: ''
7
6
  authors:
8
7
  - Yuri Smirnov
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
10
+ date: 2025-03-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: colorize
@@ -76,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  requirements: []
79
- rubygems_version: 3.6.1
78
+ rubygems_version: 3.6.6
80
79
  specification_version: 4
81
80
  summary: A tool for creating and checking helm chart snapshots.
82
81
  test_files: []