kuby-kind 0.2.1 → 0.2.3

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: 9b8c7d3120fd120e9a598d028d23a474fdefa164d649fde13e3217c2f1e1acc3
4
- data.tar.gz: c42412557e3813400e9730d6bef88eff0728107ecd0d78f01aaf476a37293ed9
3
+ metadata.gz: b2a39079aa851aca0e7bb1299217ae79a4a90e3f3e196f9073aace12ad8d3a9c
4
+ data.tar.gz: c557e2b0f80a4341695b0e4fec0ff6b45b664e959eb4655d82be426f18ed4396
5
5
  SHA512:
6
- metadata.gz: 0dce0ad3a42d4319a89a2a520295e4551b4e4eae409a27469308766b9ea0d65e6b5ceeaeb88348ef6b1b9a922a00e1b5f2e8cc11552468223013c93b6dd8e077
7
- data.tar.gz: c3300904afe02abdf301ddf2ebb0bb9f49fd91359e880d36678e4066d39d6fe3723d99d7919d6753640e808e64faed7229b86667ee45e1a3d75fa680542a5fe4
6
+ metadata.gz: cc2e7b389bf33d058a035b8f55370fe52b552473fd8271cd8959707c9a63c1e905d19e2a67feba68e3a118e495297d69b2768c0af8e70ca330d95072987736fc
7
+ data.tar.gz: 39c1ed244dec0bb577021e6e1dd4dd66e7c909387032e2c7620e899c71403e2270b28a986f1dffba144c48f4aa76d5f0f8e65aba38bcdfa2742bca42b3d0c821
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.3
2
+ * Remove mistakenly added `require 'pry-byebug'` 🤦
3
+
4
+ ## 0.2.2
5
+ * Add missing 'require'.
6
+
1
7
  ## 0.2.1
2
8
  * Only create cluster and load images on deploy.
3
9
  - Uses the `deploy` hook instead of `before_deploy`, which is called during `kuby resources` used to simulate a deploy so tag info is populated correctly.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development, :test do
6
+ gem 'sorbet-runtime'
6
7
  gem 'pry-byebug'
7
8
  gem 'rake'
8
9
  end
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'bundler'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'rubygems/package_task'
4
4
 
5
+ require 'sorbet-runtime'
5
6
  require 'kuby/kind'
6
7
  require 'pry-byebug'
7
8
 
@@ -1,6 +1,7 @@
1
1
  require 'kuby'
2
2
  require 'kind-rb'
3
3
  require 'open3'
4
+ require 'tmpdir'
4
5
 
5
6
  module Kuby
6
7
  module Kind
@@ -64,12 +65,41 @@ module Kuby
64
65
  def load_images
65
66
  Kuby.logger.info("Loading Docker images into Kind cluster...")
66
67
 
68
+ node_name = "#{cluster_name}-control-plane"
69
+ loaded_images = YAML.load(
70
+ docker_cli.exec_capture(
71
+ container: node_name,
72
+ command: '/usr/local/bin/crictl images --digests -o yaml'
73
+ )
74
+ )
75
+
76
+ loaded_digests = loaded_images['images'].map do |image|
77
+ algo, digest = image['id'].split(':')
78
+ { algo: algo, digest: digest }
79
+ end
80
+
67
81
  environment.kubernetes.docker_images.each do |image|
68
82
  image = image.current_version
69
83
 
70
- # Only load the main tag because it's so darn expensive to load large
71
- # images into Kind clusters. Kind doesn't seem to realize images with
72
- # the same SHA but different tags are the same, :eyeroll:
84
+ # Avoid loading images into the cluster if they're already there. Kind tries to detect this
85
+ # on its own and will even emit log messages to that effect, but appears to load them
86
+ # anyway. Since loading images can be quite time-consuming, we do our own check below.
87
+ images = docker_cli.images(image.image_url, digests: true)
88
+ image_info = images.find { |img| img[:tag] == image.main_tag }
89
+
90
+ if image_info
91
+ algo, _ = image_info[:digest].split(':')
92
+
93
+ loaded_digest = loaded_digests.find do |loaded_digest|
94
+ algo == loaded_digest[:algo] && loaded_digest[:digest].start_with?(image_info[:id])
95
+ end
96
+
97
+ if loaded_digest
98
+ Kuby.logger.info("Skipping #{image.image_url}@#{loaded_digest[:algo]}:#{loaded_digest[:digest]} because it's already loaded.")
99
+ next
100
+ end
101
+ end
102
+
73
103
  cmd = [
74
104
  KindRb.executable,
75
105
  'load', 'docker-image', "#{image.image_url}:#{image.main_tag}",
@@ -213,6 +243,10 @@ module Kuby
213
243
  Dir.tmpdir, 'kuby-kind'
214
244
  )
215
245
  end
246
+
247
+ def docker_cli
248
+ @docker_cli ||= Docker::CLI.new
249
+ end
216
250
  end
217
251
  end
218
252
  end
@@ -1,5 +1,5 @@
1
1
  module Kuby
2
2
  module Kind
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuby-kind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-20 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kuby-core
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.2.22
82
+ rubygems_version: 3.4.5
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Kind provider for Kuby.