kuby-core 0.11.9 → 0.11.14

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: c8dee9ccc32bf324c552b229219f3d8b704b3dfd5324da1a955e929f2789c4ac
4
- data.tar.gz: e5fc43a0320adc589ac1be2f4cfdb6802016ee962cfa7bf33fee9a8a48eab53e
3
+ metadata.gz: bfd902325b0bf78437ea91ba6021ee0cc27f83c67d60a703508a8b0c5a84bc86
4
+ data.tar.gz: 9598df94486a386235a3566c4c0422f824c30870551251ce3f4836fc94677b39
5
5
  SHA512:
6
- metadata.gz: 3a639a3e57d19629cdb5934bb7bc259c1b0de1d7f48c81683fb746664cba3c1d0526c5be2e2fbe752dd6604c5bce3b770f7231cdac738df4c0123a1730025af0
7
- data.tar.gz: 2eb4703287635c6455956f295d000a8911454c2ba05d1edaf40bbdb060368ce4a38d44a6e9394db95fcf2a2ef764598ddf5ed399eb58aed0b5d3423e139765bc
6
+ metadata.gz: 2ba1c29f18311795a39c8038940c6bc53ae6868523d520af81a52543ee6726282696f07af78b2cd8d6736ce5d0e7bc98ffd14f61693cf0b7421b7cccbbe6ea70
7
+ data.tar.gz: 801f401ba743d5375e59c33e1be57b6ae7767d5580e37bef0186dd2e299e7293f1a9e2e277a10b43b94977e0f982be8908e57153fb14d136a9e54aea92031fdf
@@ -1,3 +1,21 @@
1
+ ## 0.11.14
2
+ * Don't include port in image host for registry secrets (no idea why)
3
+
4
+ ## 0.11.13
5
+ * Include port in image host.
6
+
7
+ ## 0.11.12
8
+ * Revamp Docker URL parsing
9
+ - Docker URLs shouldn't have a scheme.
10
+
11
+ ## 0.11.11
12
+ * Add support for a Docker registry running on localhost.
13
+ - Correctly parse and handle URLs with specific ports.
14
+ - Only perform a Docker login if a username is provided.
15
+
16
+ ## 0.11.10
17
+ * Fix spelling in error message.
18
+
1
19
  ## 0.11.9
2
20
  * Use correct Docker Hub registry URL (index.docker.io).
3
21
 
@@ -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://index.docker.io'.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,17 @@ 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}"
41
+ @image_host ||= "#{full_image_uri.host}:#{full_image_uri.port}"
44
42
  end
45
43
 
46
44
  sig { returns(String) }
47
45
  def image_hostname
48
- @image_hostname ||= T.must(URI(image_host).host)
46
+ @image_hostname ||= full_image_uri.host
49
47
  end
50
48
 
51
49
  sig { returns(String) }
52
50
  def image_repo
53
- @image_repo ||= T.must(full_image_uri.path).sub(/\A[\/]+/, '')
51
+ @image_repo ||= full_image_uri.path
54
52
  end
55
53
 
56
54
  sig { returns(T::Array[String]) }
@@ -70,15 +68,9 @@ module Kuby
70
68
 
71
69
  private
72
70
 
73
- sig { returns(URI::Generic) }
71
+ sig { returns(DockerURI) }
74
72
  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
73
+ @full_image_uri ||= DockerURI.parse(image_url)
82
74
  end
83
75
 
84
76
  sig { returns(String) }
@@ -93,15 +85,6 @@ module Kuby
93
85
  TimestampTag.new(Time.now).to_s, LATEST_TAG
94
86
  ]
95
87
  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
88
  end
106
89
  end
107
90
  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
@@ -152,7 +152,7 @@ module Kuby
152
152
  end
153
153
 
154
154
  docker_config do
155
- registry_host spec.docker.metadata.image_host
155
+ registry_host spec.docker.metadata.image_hostname
156
156
  username spec.docker.credentials.username
157
157
  password spec.docker.credentials.password
158
158
  email spec.docker.credentials.email
@@ -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.9'.freeze
4
+ VERSION = '0.11.14'.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}:443") }
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:443') }
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:443') }
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.9
4
+ version: 0.11.14
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-29 00:00:00.000000000 Z
11
+ date: 2021-01-27 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