kuby-core 0.11.7 → 0.11.12

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: f148347cc0c776aabc5062f1e051c96d94277fe91831100befabc6976bbd6cd8
4
- data.tar.gz: 2dba80a00dd2f460ad80fc97ecbb333fa5cc4f6bbbe21f1ddc798c3383da0015
3
+ metadata.gz: b8d6ff09e42b41a7c2befcd581413831cfccfcc447de2ce465a51601aed2d957
4
+ data.tar.gz: 166b2ad8c8c2a4fe38f1756fde0221d4091e7fb3e18f3c70a192cae08fc24805
5
5
  SHA512:
6
- metadata.gz: ca4e9a7342bde7b8c12623374648c9c4ca61d0dd78f36eaf729dcad17f6a8f23bd1b6ccbd51190c8499f459cdfce98fa7774ada82b314cf516236958d7c93d4f
7
- data.tar.gz: 4d9f1dc0e672431c2828e9e2c96fe6c56bb410794dd32089e9443a65f4a0e51259e0c3f089477ab18b6760149586edddc17e6187e3dd76aa61215ec4dd8b5eed
6
+ metadata.gz: 31b2ce8b7bc8c224e068ca7344009b69d602f73608c45ac228d95ccfc556eb0cde034bf2c162e8eef9ba1b855644c1e6abcbaf83a536e2f48123fea800c6a798
7
+ data.tar.gz: 2ffa9a28da456fb5f7f422315207a82622c739b1539705d3f6086eb44a524bf1233e8fd88df1d8825dc4ab4ef08c142cc2bcf9a12a8c2609a0f4496af9983e3c
@@ -1,3 +1,21 @@
1
+ ## 0.11.12
2
+ * Revamp Docker URL parsing
3
+ - Docker URLs shouldn't have a scheme.
4
+
5
+ ## 0.11.11
6
+ * Add support for a Docker registry running on localhost.
7
+ - Correctly parse and handle URLs with specific ports.
8
+ - Only perform a Docker login if a username is provided.
9
+
10
+ ## 0.11.10
11
+ * Fix spelling in error message.
12
+
13
+ ## 0.11.9
14
+ * Use correct Docker Hub registry URL (index.docker.io).
15
+
16
+ ## 0.11.8
17
+ * Alias Rails `config_map` to `env`.
18
+
1
19
  ## 0.11.7
2
20
  * Properly namespace constant lookup for `Kubernetes::MissingPluginError`.
3
21
  * Add missing `#storage` method for Postgres plugin.
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
15
  s.add_dependency 'colorize', '~> 0.8'
16
- s.add_dependency 'docker-remote', '~> 0.1'
16
+ s.add_dependency 'docker-remote', '~> 0.5'
17
17
  s.add_dependency 'gli', '~> 2.0'
18
18
  s.add_dependency 'helm-cli', '~> 0.3'
19
19
  # See: https://github.com/Shopify/krane/pull/720
@@ -14,6 +14,7 @@ module Kuby
14
14
  autoload :DevSpec, 'kuby/docker/dev_spec'
15
15
  autoload :Distro, 'kuby/docker/distro'
16
16
  autoload :Dockerfile, 'kuby/docker/dockerfile'
17
+ autoload :DockerURI, 'kuby/docker/docker_uri'
17
18
  autoload :InlineLayer, 'kuby/docker/inline_layer'
18
19
  autoload :Layer, 'kuby/docker/layer'
19
20
  autoload :LayerStack, 'kuby/docker/layer_stack'
@@ -0,0 +1,34 @@
1
+ # typed: false
2
+
3
+ module Kuby
4
+ module Docker
5
+ class DockerURI
6
+ DEFAULT_REGISTRY_HOST = 'index.docker.io'.freeze
7
+ DEFAULT_REGISTRY_PORT = 443
8
+
9
+ def self.parse(url)
10
+ if idx = url.index('://')
11
+ url = url[(idx + 3)..-1] || ''
12
+ end
13
+
14
+ host_port, *path = url.split('/')
15
+ host, port, *path = if host_port =~ /[.:]/
16
+ hst, prt = host_port.split(':')
17
+ [hst, prt || DEFAULT_REGISTRY_PORT, *path]
18
+ else
19
+ [DEFAULT_REGISTRY_HOST, DEFAULT_REGISTRY_PORT, host_port, *path]
20
+ end
21
+
22
+ new(host, port.to_i, path.join('/'))
23
+ end
24
+
25
+ attr_reader :host, :port, :path
26
+
27
+ def initialize(host, port, path)
28
+ @host = host
29
+ @port = port
30
+ @path = path
31
+ end
32
+ end
33
+ end
34
+ end
@@ -8,8 +8,6 @@ module Kuby
8
8
  extend T::Sig
9
9
 
10
10
  DEFAULT_DISTRO = :debian
11
- DEFAULT_REGISTRY_HOST = T.let('https://www.docker.com'.freeze, String)
12
- DEFAULT_REGISTRY_SCHEME = T.let('https', String)
13
11
  LATEST_TAG = T.let('latest'.freeze, String)
14
12
 
15
13
  sig { params(image_url: String).void }
@@ -28,7 +26,7 @@ module Kuby
28
26
  @image_hostname = T.let(@image_hostname, T.nilable(String))
29
27
  @image_repo = T.let(@image_repo, T.nilable(String))
30
28
  @distro = T.let(@distro, T.nilable(Symbol))
31
- @full_image_uri = T.let(@full_image_uri, T.nilable(URI::Generic))
29
+ @full_image_uri = T.let(@full_image_uri, T.nilable(DockerURI))
32
30
  @default_image_url = T.let(@default_image_url, T.nilable(String))
33
31
  @default_tags = T.let(@default_tags, T.nilable(T::Array[String]))
34
32
  end
@@ -40,17 +38,12 @@ module Kuby
40
38
 
41
39
  sig { returns(String) }
42
40
  def image_host
43
- @image_host ||= "#{full_image_uri.scheme}://#{full_image_uri.host}"
44
- end
45
-
46
- sig { returns(String) }
47
- def image_hostname
48
- @image_hostname ||= T.must(URI(image_host).host)
41
+ @image_host ||= full_image_uri.host
49
42
  end
50
43
 
51
44
  sig { returns(String) }
52
45
  def image_repo
53
- @image_repo ||= T.must(full_image_uri.path).sub(/\A[\/]+/, '')
46
+ @image_repo ||= full_image_uri.path
54
47
  end
55
48
 
56
49
  sig { returns(T::Array[String]) }
@@ -70,15 +63,9 @@ module Kuby
70
63
 
71
64
  private
72
65
 
73
- sig { returns(URI::Generic) }
66
+ sig { returns(DockerURI) }
74
67
  def full_image_uri
75
- @full_image_uri ||= if image_url.include?('://')
76
- URI.parse(image_url)
77
- elsif image_url =~ /\A[^.]+\.[^\/]+\//
78
- URI.parse("#{DEFAULT_REGISTRY_SCHEME}://#{image_url}")
79
- else
80
- URI.parse("#{DEFAULT_REGISTRY_HOST}/#{image_url.sub(/\A[\/]+/, '')}")
81
- end
68
+ @full_image_uri ||= DockerURI.parse(image_url)
82
69
  end
83
70
 
84
71
  sig { returns(String) }
@@ -93,15 +80,6 @@ module Kuby
93
80
  TimestampTag.new(Time.now).to_s, LATEST_TAG
94
81
  ]
95
82
  end
96
-
97
- sig { params(url: String).returns(URI::Generic) }
98
- def parse_url(url)
99
- uri = URI.parse(url)
100
- return uri if uri.scheme
101
-
102
- # force a scheme because URI.parse won't work properly without one
103
- URI.parse("#{DEFAULT_REGISTRY_SCHEME}://#{url}")
104
- end
105
83
  end
106
84
  end
107
85
  end
@@ -1,4 +1,5 @@
1
1
  # typed: true
2
+
2
3
  require 'fileutils'
3
4
  require 'securerandom'
4
5
  require 'yaml'
@@ -6,6 +7,8 @@ require 'yaml'
6
7
  module Kuby
7
8
  module Kubernetes
8
9
  class Deployer
10
+ extend T::Sig
11
+
9
12
  attr_reader :environment
10
13
  attr_accessor :logdev
11
14
 
@@ -93,7 +96,7 @@ module Kuby
93
96
  task.run!(verify_result: true, prune: false)
94
97
  ensure
95
98
  ENV['KUBECONFIG'] = old_kubeconfig
96
- FileUtils.rm_rf(tmpdir)
99
+ FileUtils.rm_rf(T.must(tmpdir))
97
100
  end
98
101
 
99
102
  def restart_rails_deployment_if_necessary
@@ -202,6 +202,8 @@ module Kuby
202
202
  @config_map
203
203
  end
204
204
 
205
+ alias_method :env, :config_map
206
+
205
207
  def app_secrets(&block)
206
208
  spec = self
207
209
 
@@ -41,10 +41,10 @@ module Kuby
41
41
  fail 'Cannot push Docker images built for the development environment'
42
42
  end
43
43
 
44
- hostname = docker.metadata.image_hostname
44
+ host = docker.metadata.image_host
45
45
 
46
- unless docker.cli.auths.include?(hostname)
47
- Kuby.logger.info("Attempting to log in to registry at #{hostname}")
46
+ if docker.credentials.username && !docker.cli.auths.include?(host)
47
+ Kuby.logger.info("Attempting to log in to registry at #{host}")
48
48
 
49
49
  begin
50
50
  docker.cli.login(
@@ -53,7 +53,7 @@ module Kuby
53
53
  password: docker.credentials.password
54
54
  )
55
55
  rescue Kuby::Docker::LoginError => e
56
- Kuby.logger.fatal("Couldn't log in to the registry at #{hostname}")
56
+ Kuby.logger.fatal("Couldn't log in to the registry at #{host}")
57
57
  Kuby.logger.fatal(e.message)
58
58
  return
59
59
  end
@@ -66,7 +66,7 @@ module Kuby
66
66
  docker.cli.push(image_url, tag)
67
67
  end
68
68
  rescue Kuby::Docker::MissingTagError => e
69
- msg = "#{e.message} Run rake kuby:build to build the"\
69
+ msg = "#{e.message} Run kuby build to build the "\
70
70
  'Docker image before running this task.'
71
71
 
72
72
  Kuby.logger.fatal(msg)
@@ -1,5 +1,5 @@
1
1
  # typed: true
2
2
 
3
3
  module Kuby
4
- VERSION = '0.11.7'.freeze
4
+ VERSION = '0.11.12'.freeze
5
5
  end
@@ -19,18 +19,18 @@ describe Kuby::Docker::Metadata do
19
19
  describe '#image_host' do
20
20
  subject { metadata.image_host }
21
21
 
22
- it { is_expected.to eq(described_class::DEFAULT_REGISTRY_HOST) }
22
+ it { is_expected.to eq(Kuby::Docker::DockerURI::DEFAULT_REGISTRY_HOST) }
23
23
 
24
24
  context 'when the image URL contains an explicit host' do
25
25
  let(:docker_image_url) { 'registry.foo.com/foo/testapp' }
26
26
 
27
- it { is_expected.to eq('https://registry.foo.com') }
27
+ it { is_expected.to eq('registry.foo.com') }
28
28
  end
29
29
 
30
- context 'when the image URL contains an explicit host with scheme' do
30
+ context 'when the image URL contains an explicit host' do
31
31
  let(:docker_image_url) { 'http://registry.foo.com/foo/testapp' }
32
32
 
33
- it { is_expected.to eq('http://registry.foo.com') }
33
+ it { is_expected.to eq('registry.foo.com') }
34
34
  end
35
35
  end
36
36
 
@@ -46,18 +46,6 @@ describe Kuby::Docker::Metadata do
46
46
  end
47
47
  end
48
48
 
49
- describe '#image_hostname' do
50
- subject { metadata.image_hostname }
51
-
52
- it { is_expected.to eq('www.docker.com') }
53
-
54
- context 'when the image URL contains an explicit host' do
55
- let(:docker_image_url) { 'registry.foo.com/foo/testapp' }
56
-
57
- it { is_expected.to eq('registry.foo.com') }
58
- end
59
- end
60
-
61
49
  describe '#tags' do
62
50
  subject { metadata.tags }
63
51
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.11.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-19 00:00:00.000000000 Z
11
+ date: 2020-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: '0.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: '0.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gli
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +230,7 @@ files:
230
230
  - lib/kuby/docker/debian.rb
231
231
  - lib/kuby/docker/dev_spec.rb
232
232
  - lib/kuby/docker/distro.rb
233
+ - lib/kuby/docker/docker_uri.rb
233
234
  - lib/kuby/docker/dockerfile.rb
234
235
  - lib/kuby/docker/errors.rb
235
236
  - lib/kuby/docker/inline_layer.rb