helmsnap 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c18d2415fcbf1aaaaa122e41ba823563c39e9074778c44fb9b504788f3a6fad2
4
- data.tar.gz: 8c2ca2cccdf76d316f6cfa3228fbe982dd8262b957a5f4c13378bd6db7d9595e
3
+ metadata.gz: 6736a60925c46a19ac7d349ea1e0fff67d7d3e6499a74f9f620a00d17eda0f50
4
+ data.tar.gz: 2441260a8c95cd7ae6c3b91616dce927cf7972652f8dc4431b0fc78379a93522
5
5
  SHA512:
6
- metadata.gz: 251efbe07d35daed3b788f30bf8fb42609b58b1677b58d4b1916799519d546d3f4aaa2b2986da7feb304de3a6f4db9fe049130ce1f060053a1377832fabe27d5
7
- data.tar.gz: 656c7f6656f84b677c343d04878891c7c91e1f43aa1e1950be7a02895b401b7f29aa05ba527df5b47551dcfd903dcaca1869d6afcb309ae93503e40a35b750a9
6
+ metadata.gz: cf1cdbdba197e96cb1ba2403bd69ee7d6cad705bcb2d6378f112852ba92477be6fb7dad954cafbca54fa88a4f93113a83b56d9c9aa33952d07710a128c5cca24
7
+ data.tar.gz: 666bad3f4be9e21af24649a59508f88fc5f0a72bee4f26b32f10ed3f635224631d0cab4744e2c4260bb9c3fefa552f03f32f90eeb33c7c26f2324e4e84be9c7a
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0
7
7
  Include:
8
8
  - bin/console
9
9
  - Gemfile
data/Dockerfile CHANGED
@@ -4,7 +4,7 @@ RUN apk add --update --no-cache ruby git colordiff
4
4
 
5
5
  WORKDIR /wd
6
6
 
7
- COPY --from=ghcr.io/helmfile/helmfile:v0.149.0 /usr/local/bin/helmfile /usr/local/bin/helmfile
7
+ COPY --from=ghcr.io/helmfile/helmfile /usr/local/bin/helmfile /usr/local/bin/helmfile
8
8
  COPY . .
9
9
 
10
10
  RUN gem install colorize && gem build && gem install helmsnap --local
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gem "pry"
8
8
  gem "rake"
9
9
  gem "rspec"
10
10
  gem "rubocop"
11
+ gem "rubocop-config-umbrellio"
data/Gemfile.lock CHANGED
@@ -1,87 +1,103 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (1.0.2)
4
+ helmsnap (1.1.0)
5
5
  colorize
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4)
10
+ activesupport (7.1.4)
11
+ base64
12
+ bigdecimal
11
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ connection_pool (>= 2.2.5)
15
+ drb
12
16
  i18n (>= 1.6, < 2)
13
17
  minitest (>= 5.1)
18
+ mutex_m
14
19
  tzinfo (~> 2.0)
15
20
  ast (2.4.2)
21
+ base64 (0.2.0)
22
+ bigdecimal (3.1.8)
16
23
  coderay (1.1.3)
17
- colorize (0.8.1)
18
- concurrent-ruby (1.1.10)
19
- diff-lcs (1.5.0)
20
- i18n (1.12.0)
24
+ colorize (1.1.0)
25
+ concurrent-ruby (1.3.4)
26
+ connection_pool (2.4.1)
27
+ diff-lcs (1.5.1)
28
+ drb (2.2.1)
29
+ i18n (1.14.6)
21
30
  concurrent-ruby (~> 1.0)
22
- json (2.6.3)
23
- method_source (1.0.0)
24
- minitest (5.17.0)
25
- parallel (1.22.1)
26
- parser (3.2.0.0)
31
+ json (2.7.2)
32
+ language_server-protocol (3.17.0.3)
33
+ method_source (1.1.0)
34
+ minitest (5.25.1)
35
+ mutex_m (0.2.0)
36
+ parallel (1.26.3)
37
+ parser (3.3.5.0)
27
38
  ast (~> 2.4.1)
39
+ racc
28
40
  pry (0.14.2)
29
41
  coderay (~> 1.1)
30
42
  method_source (~> 1.0)
31
- rack (3.0.3)
43
+ racc (1.8.1)
44
+ rack (3.1.8)
32
45
  rainbow (3.1.1)
33
- rake (13.0.6)
34
- regexp_parser (2.6.1)
35
- rexml (3.2.5)
36
- rspec (3.12.0)
37
- rspec-core (~> 3.12.0)
38
- rspec-expectations (~> 3.12.0)
39
- rspec-mocks (~> 3.12.0)
40
- rspec-core (3.12.0)
41
- rspec-support (~> 3.12.0)
42
- rspec-expectations (3.12.2)
46
+ rake (13.2.1)
47
+ regexp_parser (2.9.2)
48
+ rspec (3.13.0)
49
+ rspec-core (~> 3.13.0)
50
+ rspec-expectations (~> 3.13.0)
51
+ rspec-mocks (~> 3.13.0)
52
+ rspec-core (3.13.1)
53
+ rspec-support (~> 3.13.0)
54
+ rspec-expectations (3.13.3)
43
55
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.12.0)
45
- rspec-mocks (3.12.2)
56
+ rspec-support (~> 3.13.0)
57
+ rspec-mocks (3.13.2)
46
58
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.12.0)
48
- rspec-support (3.12.0)
49
- rubocop (1.43.0)
59
+ rspec-support (~> 3.13.0)
60
+ rspec-support (3.13.1)
61
+ rubocop (1.66.1)
50
62
  json (~> 2.3)
63
+ language_server-protocol (>= 3.17.0)
51
64
  parallel (~> 1.10)
52
- parser (>= 3.2.0.0)
65
+ parser (>= 3.3.0.2)
53
66
  rainbow (>= 2.2.2, < 4.0)
54
- regexp_parser (>= 1.8, < 3.0)
55
- rexml (>= 3.2.5, < 4.0)
56
- rubocop-ast (>= 1.24.1, < 2.0)
67
+ regexp_parser (>= 2.4, < 3.0)
68
+ rubocop-ast (>= 1.32.2, < 2.0)
57
69
  ruby-progressbar (~> 1.7)
58
70
  unicode-display_width (>= 2.4.0, < 3.0)
59
- rubocop-ast (1.24.1)
60
- parser (>= 3.1.1.0)
61
- rubocop-config-umbrellio (1.43.0.81)
62
- rubocop (~> 1.43.0)
63
- rubocop-performance (~> 1.15.0)
64
- rubocop-rails (~> 2.17.0)
71
+ rubocop-ast (1.32.3)
72
+ parser (>= 3.3.1.0)
73
+ rubocop-config-umbrellio (1.66.0.99)
74
+ rubocop (~> 1.66.0)
75
+ rubocop-factory_bot (~> 2.26.0)
76
+ rubocop-performance (~> 1.22.0)
77
+ rubocop-rails (~> 2.26.0)
65
78
  rubocop-rake (~> 0.6.0)
66
- rubocop-rspec (~> 2.16.0)
79
+ rubocop-rspec (~> 3.0.0)
67
80
  rubocop-sequel (~> 0.3.3)
68
- rubocop-performance (1.15.2)
69
- rubocop (>= 1.7.0, < 2.0)
70
- rubocop-ast (>= 0.4.0)
71
- rubocop-rails (2.17.4)
81
+ rubocop-factory_bot (2.26.1)
82
+ rubocop (~> 1.61)
83
+ rubocop-performance (1.22.1)
84
+ rubocop (>= 1.48.1, < 2.0)
85
+ rubocop-ast (>= 1.31.1, < 2.0)
86
+ rubocop-rails (2.26.2)
72
87
  activesupport (>= 4.2.0)
73
88
  rack (>= 1.1)
74
- rubocop (>= 1.33.0, < 2.0)
89
+ rubocop (>= 1.52.0, < 2.0)
90
+ rubocop-ast (>= 1.31.1, < 2.0)
75
91
  rubocop-rake (0.6.0)
76
92
  rubocop (~> 1.0)
77
- rubocop-rspec (2.16.0)
78
- rubocop (~> 1.33)
93
+ rubocop-rspec (3.0.5)
94
+ rubocop (~> 1.61)
79
95
  rubocop-sequel (0.3.4)
80
96
  rubocop (~> 1.0)
81
- ruby-progressbar (1.11.0)
82
- tzinfo (2.0.5)
97
+ ruby-progressbar (1.13.0)
98
+ tzinfo (2.0.6)
83
99
  concurrent-ruby (~> 1.0)
84
- unicode-display_width (2.4.2)
100
+ unicode-display_width (2.6.0)
85
101
 
86
102
  PLATFORMS
87
103
  arm64-darwin-21
@@ -98,4 +114,4 @@ DEPENDENCIES
98
114
  rubocop-config-umbrellio
99
115
 
100
116
  BUNDLED WITH
101
- 2.4.3
117
+ 2.5.21
data/README.md CHANGED
@@ -38,18 +38,22 @@ This tool can also be useful when you are developing a new chart or updating an
38
38
 
39
39
  ## Configuration
40
40
 
41
- By default, helmsnap will render your helmfile using `default` environment and will place snapshots in `helm/snapshots` directory. If you want to configure that, create a `.helmsnap.yaml` file and put there configuration that looks like this:
41
+ By default, helmsnap will render your helmfile using `default` environment and will place snapshots in `helm/snapshots` directory. If you want to configure that, or you need to provide credentials for access to private helm repos, you can create a `.helmsnap.yaml` file and put there configuration that looks like this:
42
42
 
43
43
  ```yaml
44
44
  envs: [staging, production] # `[default]` by default
45
45
  snapshotsPath: somedir/snapshots # `helm/snapshots` by default
46
+ credentials: # [] by default
47
+ - repo: https://example.com/some/path/to/repo
48
+ username: someuser
49
+ password: somepassword
46
50
  ```
47
51
 
48
52
  You can also override configuration file location using `--config` option.
49
53
 
50
54
  ## Dependencies
51
55
 
52
- - Ruby 2.7+.
56
+ - Ruby 3.0+.
53
57
  - [Helmfile](https://github.com/roboll/helmfile), which in turn relies on [Helm](https://github.com/helm/helm).
54
58
  - Colordiff or diff utility.
55
59
 
data/helmsnap.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "A tool for creating and checking helm chart snapshots."
12
12
  spec.homepage = "https://github.com/tycooon/helmsnap"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.7.0"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
17
  spec.metadata["homepage_uri"] = spec.homepage
@@ -31,6 +31,4 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "colorize"
34
-
35
- spec.add_development_dependency "rubocop-config-umbrellio"
36
34
  end
@@ -6,7 +6,7 @@ class Helmsnap::ArgsParser
6
6
  Args = Struct.new(:config_path)
7
7
 
8
8
  DEFAULT_CONFIG_PATH = Pathname.new(".helmsnap.yaml")
9
- CONFIG_PATH_HELP = %{Path to config (default: "#{DEFAULT_CONFIG_PATH}")}
9
+ CONFIG_PATH_HELP = %{Path to config (default: "#{DEFAULT_CONFIG_PATH}")}.freeze
10
10
  BANNER = "Usage: helmsnap CMD [options]"
11
11
 
12
12
  def initialize(options)
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::Config
4
- attr_reader :envs, :snapshots_path
4
+ Credentials = Struct.new(:username, :password)
5
+
6
+ attr_reader :envs, :snapshots_path, :credentials
5
7
 
6
8
  DEFAULT_ENV = "default"
7
9
  DEFAULT_SNAPSHOTS_PATH = "helm/snapshots"
@@ -15,11 +17,12 @@ class Helmsnap::Config
15
17
 
16
18
  self.envs = parse_envs(yaml)
17
19
  self.snapshots_path = parse_snaphots_path(yaml)
20
+ self.credentials = parse_credentials(yaml)
18
21
  end
19
22
 
20
23
  private
21
24
 
22
- attr_writer :envs, :snapshots_path
25
+ attr_writer :envs, :snapshots_path, :credentials
23
26
 
24
27
  def parse_envs(yaml)
25
28
  value = yaml.fetch("envs", [DEFAULT_ENV])
@@ -29,4 +32,10 @@ class Helmsnap::Config
29
32
  def parse_snaphots_path(yaml)
30
33
  Pathname.new(yaml.fetch("snapshotsPath", DEFAULT_SNAPSHOTS_PATH))
31
34
  end
35
+
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"])
39
+ end
40
+ end
32
41
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Helmsnap::SetupDependencies < Helmsnap::Service
4
+ REPO_NAME_PREFIX = "helmsnap-"
5
+
4
6
  def initialize(config)
5
7
  super()
6
8
  self.config = config
@@ -8,6 +10,8 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
8
10
  end
9
11
 
10
12
  def call
13
+ clear_existing_repos!
14
+
11
15
  config.envs.flat_map(&:release_paths).each do |chart_path|
12
16
  setup!(chart_path)
13
17
  end
@@ -17,6 +21,14 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
17
21
 
18
22
  attr_accessor :config, :processed_paths
19
23
 
24
+ def clear_existing_repos!
25
+ result = run_cmd("helm", "repo", "ls", allow_failure: true).output
26
+
27
+ result.scan(/#{REPO_NAME_PREFIX}\S+/o) do |repo_name|
28
+ run_cmd("helm", "repo", "remove", repo_name)
29
+ end
30
+ end
31
+
20
32
  def setup!(chart_path)
21
33
  normalized_path = chart_path.expand_path
22
34
  return if processed_paths.include?(normalized_path)
@@ -30,7 +42,14 @@ class Helmsnap::SetupDependencies < Helmsnap::Service
30
42
  end
31
43
 
32
44
  dep_list.scan(%r{(https?://.+?)\s}) do |dep_path|
33
- run_cmd("helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first)
45
+ url = dep_path.first
46
+
47
+ if (credentials = config.credentials[url])
48
+ extra_args = ["--username", credentials.username, "--password", credentials.password]
49
+ end
50
+
51
+ repo_name = "#{REPO_NAME_PREFIX}#{Digest::MD5.hexdigest(url)}"
52
+ run_cmd("helm", "repo", "add", repo_name, url, *extra_args)
34
53
  end
35
54
 
36
55
  update_deps!(chart_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "1.0.2"
4
+ VERSION = "1.1.0"
5
5
  end
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: 1.0.2
4
+ version: 1.1.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: 2023-01-16 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rubocop-config-umbrellio
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  description:
42
28
  email:
43
29
  - tycooon@yandex.ru
@@ -85,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
71
  requirements:
86
72
  - - ">="
87
73
  - !ruby/object:Gem::Version
88
- version: 2.7.0
74
+ version: 3.0.0
89
75
  required_rubygems_version: !ruby/object:Gem::Requirement
90
76
  requirements:
91
77
  - - ">="
92
78
  - !ruby/object:Gem::Version
93
79
  version: '0'
94
80
  requirements: []
95
- rubygems_version: 3.4.3
81
+ rubygems_version: 3.5.21
96
82
  signing_key:
97
83
  specification_version: 4
98
84
  summary: A tool for creating and checking helm chart snapshots.