kuby-kind 0.2.1 → 0.2.2

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: 32168f7821c5fdc2b593f00e355d4033b2eb9f957b3f306e26f743484d9ee74c
4
+ data.tar.gz: 4b75e6a5f900bd24760d90350e594557bfcb4830b6d963766c82e94a822ad640
5
5
  SHA512:
6
- metadata.gz: 0dce0ad3a42d4319a89a2a520295e4551b4e4eae409a27469308766b9ea0d65e6b5ceeaeb88348ef6b1b9a922a00e1b5f2e8cc11552468223013c93b6dd8e077
7
- data.tar.gz: c3300904afe02abdf301ddf2ebb0bb9f49fd91359e880d36678e4066d39d6fe3723d99d7919d6753640e808e64faed7229b86667ee45e1a3d75fa680542a5fe4
6
+ metadata.gz: 162a12291e5c63fbcc66e63d344c566be36f0d1894b4bf7e84e07bb49166354296f338fc4f23a4d7c3227380e63c7a7f9bd72ac86ffdbfd624fb439d0a4147c2
7
+ data.tar.gz: e892e6f0732ef8bbd0205fdcd45d74a02031166c42bbd3e2e584583125eaa7a3075ca0fd77edab376d578bfb186f68813e59acd7e8deebfc8f48b5c6ea8dbc0f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.2
2
+ * Add missing 'require'.
3
+
1
4
  ## 0.2.1
2
5
  * Only create cluster and load images on deploy.
3
6
  - 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
@@ -62,14 +63,44 @@ module Kuby
62
63
  end
63
64
 
64
65
  def load_images
66
+ require 'pry-byebug'
65
67
  Kuby.logger.info("Loading Docker images into Kind cluster...")
66
68
 
69
+ node_name = "#{cluster_name}-control-plane"
70
+ loaded_images = YAML.load(
71
+ docker_cli.exec_capture(
72
+ container: node_name,
73
+ command: '/usr/local/bin/crictl images --digests -o yaml'
74
+ )
75
+ )
76
+
77
+ loaded_digests = loaded_images['images'].map do |image|
78
+ algo, digest = image['id'].split(':')
79
+ { algo: algo, digest: digest }
80
+ end
81
+
67
82
  environment.kubernetes.docker_images.each do |image|
68
83
  image = image.current_version
69
84
 
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:
85
+ # Avoid loading images into the cluster if they're already there. Kind tries to detect this
86
+ # on its own and will even emit log messages to that effect, but appears to load them
87
+ # anyway. Since loading images can be quite time-consuming, we do our own check below.
88
+ images = docker_cli.images(image.image_url, digests: true)
89
+ image_info = images.find { |img| img[:tag] == image.main_tag }
90
+
91
+ if image_info
92
+ algo, _ = image_info[:digest].split(':')
93
+
94
+ loaded_digest = loaded_digests.find do |loaded_digest|
95
+ algo == loaded_digest[:algo] && loaded_digest[:digest].start_with?(image_info[:id])
96
+ end
97
+
98
+ if loaded_digest
99
+ Kuby.logger.info("Skipping #{image.image_url}@#{loaded_digest[:algo]}:#{loaded_digest[:digest]} because it's already loaded.")
100
+ next
101
+ end
102
+ end
103
+
73
104
  cmd = [
74
105
  KindRb.executable,
75
106
  'load', 'docker-image', "#{image.image_url}:#{image.main_tag}",
@@ -213,6 +244,10 @@ module Kuby
213
244
  Dir.tmpdir, 'kuby-kind'
214
245
  )
215
246
  end
247
+
248
+ def docker_cli
249
+ @docker_cli ||= Docker::CLI.new
250
+ end
216
251
  end
217
252
  end
218
253
  end
@@ -1,5 +1,5 @@
1
1
  module Kuby
2
2
  module Kind
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.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.2
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-13 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.