helmsnap 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c1238eff1b14a2e564bd43769307c6cb94659b6c838029420bc6a95bf01bde4
4
+ data.tar.gz: f3c102029eb427e5d511062349007568e80a7c7b55ed6bd0adbabdf4593e0afe
5
+ SHA512:
6
+ metadata.gz: a0ca141cdc412b9f7ca384b0ce6169fedeb74796f11fa0e957e3f63f06c2e24fb3a3a957b7ce46a1af19cb884b5e3c37faca7e85935bb2db76c839e373136a96
7
+ data.tar.gz: ad5bccf70fc572be8d8dbd6e3f8c2ffeb166d92314c34e72a9090725c60cb60a02e6cc310f7577466a485c1113f76f90e68cb01a3a4d9dc85e0beca8e28137de
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "pry"
8
+ gem "rake"
9
+ gem "rspec"
10
+ gem "rubocop"
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ helmsnap (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ coderay (1.1.3)
11
+ diff-lcs (1.4.4)
12
+ method_source (1.0.0)
13
+ parallel (1.21.0)
14
+ parser (3.0.2.0)
15
+ ast (~> 2.4.1)
16
+ pry (0.14.1)
17
+ coderay (~> 1.1)
18
+ method_source (~> 1.0)
19
+ rainbow (3.0.0)
20
+ rake (13.0.6)
21
+ regexp_parser (2.1.1)
22
+ rexml (3.2.5)
23
+ rspec (3.10.0)
24
+ rspec-core (~> 3.10.0)
25
+ rspec-expectations (~> 3.10.0)
26
+ rspec-mocks (~> 3.10.0)
27
+ rspec-core (3.10.1)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-expectations (3.10.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-mocks (3.10.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.10.0)
35
+ rspec-support (3.10.3)
36
+ rubocop (1.23.0)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.0.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml
42
+ rubocop-ast (>= 1.12.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 3.0)
45
+ rubocop-ast (1.13.0)
46
+ parser (>= 3.0.1.1)
47
+ ruby-progressbar (1.11.0)
48
+ unicode-display_width (2.1.0)
49
+
50
+ PLATFORMS
51
+ x86_64-darwin-20
52
+
53
+ DEPENDENCIES
54
+ helmsnap!
55
+ pry
56
+ rake
57
+ rspec
58
+ rubocop
59
+
60
+ BUNDLED WITH
61
+ 2.2.31
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Yuri Smirnov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Helmsnap
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/helmsnap`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'helmsnap'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install helmsnap
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tycooon/helmsnap.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "helmsnap"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "pry"
11
+ Pry.start
data/exe/helmsnap ADDED
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "digest"
5
+ require "fileutils"
6
+ require "open3"
7
+ require "optparse"
8
+ require "pathname"
9
+ require "shellwords"
10
+
11
+ def run(*cmd_parts)
12
+ cmd = Shellwords.join(cmd_parts)
13
+
14
+ puts "\e[1m\e[33m#{cmd}\e[0m\e[22m"
15
+
16
+ Open3.popen3(cmd) do |_stdin, stdout, stderr, wait_thr|
17
+ output = +""
18
+
19
+ while chunk = stdout.gets
20
+ $stdout.print(chunk)
21
+ output << chunk
22
+ end
23
+
24
+ exit_status = wait_thr.value
25
+
26
+ unless exit_status.success?
27
+ $stderr.print(stderr.read)
28
+ abort "Command failed with status #{exit_status.to_i}"
29
+ end
30
+
31
+ puts
32
+ output
33
+ end
34
+ end
35
+
36
+ class ArgsParser
37
+ Args = Struct.new(:chart, :snapshots, :values)
38
+ MissingOption = Class.new(OptionParser::ParseError)
39
+
40
+ def initialize(options)
41
+ self.options = options
42
+ self.args = Args.new("k8s/chart", "k8s/snapshots")
43
+ self.parser = build_parser
44
+ end
45
+
46
+ def get_options!
47
+ parser.parse!(options)
48
+ raise MissingOption, "missing option: VALUES" unless args.values
49
+ args
50
+ rescue OptionParser::ParseError => e
51
+ puts e, nil
52
+ print_help!
53
+ exit 1
54
+ end
55
+
56
+ private
57
+
58
+ attr_accessor :options, :parser, :args
59
+
60
+ def build_parser
61
+ OptionParser.new do |opts|
62
+ opts.banner = "Usage: render-helm [options]"
63
+
64
+ opts.on("-c", "--chart-dir [DIR]",
65
+ "Chart directory (default: #{args.chart})") do |option|
66
+ args.chart = option
67
+ end
68
+
69
+ opts.on("-s", "--snapshots-dir DIR",
70
+ "Snapshots directory (default #{args.snapshots})") do |option|
71
+ args.snapshots = option
72
+ end
73
+
74
+ opts.on("-v", "--values VALUES", "Values file") do |option|
75
+ args.values = option
76
+ end
77
+
78
+ opts.on("-h", "--help", "Show this message") do
79
+ puts opts
80
+ exit
81
+ end
82
+ end
83
+ end
84
+
85
+ def print_help!
86
+ puts parser.help
87
+ end
88
+ end
89
+
90
+ options = ArgsParser.new(ARGV).get_options!
91
+
92
+ chart_path = Pathname.new(options.chart)
93
+ snapshots_path = Pathname.new(options.snapshots)
94
+
95
+ dep_list = run "helm", "dependency", "list", "--max-col-width", 0, chart_path
96
+
97
+ dep_list.scan(%r{file://(.+?)\t}) do |dep_path|
98
+ run "helm", "dependency", "update", "--skip-refresh", chart_path.join(dep_path.first)
99
+ end
100
+
101
+ dep_list.scan(%r{(https?://.+?)\t}) do |dep_path|
102
+ run "helm", "repo", "add", Digest::MD5.hexdigest(dep_path.first), dep_path.first
103
+ end
104
+
105
+ run "helm", "dependency", "update", "--skip-refresh", chart_path
106
+
107
+ FileUtils.rmtree(snapshots_path)
108
+
109
+ run "helm", "template", chart_path,
110
+ "--values", options.values,
111
+ "--output-dir", snapshots_path
112
+
113
+ snapshots_path.glob(["**/*yaml", "**/*.yml"]).each do |path|
114
+ content = path.read
115
+ content.gsub!(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d+/, "2022-01-01 00:00:00.000") or next
116
+ path.write(content)
117
+ end
data/helmsnap.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/helmsnap/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "helmsnap"
7
+ spec.version = Helmsnap::VERSION
8
+ spec.authors = ["Yuri Smirnov"]
9
+ spec.email = ["tycooon@yandex.ru"]
10
+
11
+ spec.summary = "A tool for creating and checking helm chart snapshots."
12
+ spec.homepage = "https://github.com/tycooon/helmsnap"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Helmsnap
4
+ VERSION = "0.1.0"
5
+ end
data/lib/helmsnap.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "helmsnap/version"
4
+
5
+ module Helmsnap
6
+ class Error < StandardError; end
7
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: helmsnap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuri Smirnov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-11-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - tycooon@yandex.ru
16
+ executables:
17
+ - helmsnap
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - exe/helmsnap
30
+ - helmsnap.gemspec
31
+ - lib/helmsnap.rb
32
+ - lib/helmsnap/version.rb
33
+ homepage: https://github.com/tycooon/helmsnap
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://github.com/tycooon/helmsnap
38
+ source_code_uri: https://github.com/tycooon/helmsnap
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.6.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.2.31
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A tool for creating and checking helm chart snapshots.
58
+ test_files: []