kuby-core 0.11.11 → 0.11.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/kuby-core.gemspec +1 -1
- data/lib/kuby/docker.rb +1 -0
- data/lib/kuby/docker/docker_uri.rb +34 -0
- data/lib/kuby/docker/metadata.rb +5 -28
- data/lib/kuby/tasks.rb +4 -4
- data/lib/kuby/version.rb +1 -1
- data/spec/docker/metadata_spec.rb +4 -16
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d6ff09e42b41a7c2befcd581413831cfccfcc447de2ce465a51601aed2d957
|
4
|
+
data.tar.gz: 166b2ad8c8c2a4fe38f1756fde0221d4091e7fb3e18f3c70a192cae08fc24805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b2ce8b7bc8c224e068ca7344009b69d602f73608c45ac228d95ccfc556eb0cde034bf2c162e8eef9ba1b855644c1e6abcbaf83a536e2f48123fea800c6a798
|
7
|
+
data.tar.gz: 2ffa9a28da456fb5f7f422315207a82622c739b1539705d3f6086eb44a524bf1233e8fd88df1d8825dc4ab4ef08c142cc2bcf9a12a8c2609a0f4496af9983e3c
|
data/CHANGELOG.md
CHANGED
data/kuby-core.gemspec
CHANGED
@@ -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.
|
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
|
data/lib/kuby/docker.rb
CHANGED
@@ -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
|
data/lib/kuby/docker/metadata.rb
CHANGED
@@ -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(
|
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,18 +38,12 @@ module Kuby
|
|
40
38
|
|
41
39
|
sig { returns(String) }
|
42
40
|
def image_host
|
43
|
-
|
44
|
-
@image_host ||= "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
45
|
-
end
|
46
|
-
|
47
|
-
sig { returns(String) }
|
48
|
-
def image_hostname
|
49
|
-
@image_hostname ||= T.must(URI(image_host).host)
|
41
|
+
@image_host ||= full_image_uri.host
|
50
42
|
end
|
51
43
|
|
52
44
|
sig { returns(String) }
|
53
45
|
def image_repo
|
54
|
-
@image_repo ||=
|
46
|
+
@image_repo ||= full_image_uri.path
|
55
47
|
end
|
56
48
|
|
57
49
|
sig { returns(T::Array[String]) }
|
@@ -71,15 +63,9 @@ module Kuby
|
|
71
63
|
|
72
64
|
private
|
73
65
|
|
74
|
-
sig { returns(
|
66
|
+
sig { returns(DockerURI) }
|
75
67
|
def full_image_uri
|
76
|
-
@full_image_uri ||=
|
77
|
-
URI.parse(image_url)
|
78
|
-
elsif image_url =~ /\A[^.:]+[\.:][^\/]+\//
|
79
|
-
URI.parse("#{DEFAULT_REGISTRY_SCHEME}://#{image_url}")
|
80
|
-
else
|
81
|
-
URI.parse("#{DEFAULT_REGISTRY_HOST}/#{image_url.sub(/\A[\/]+/, '')}")
|
82
|
-
end
|
68
|
+
@full_image_uri ||= DockerURI.parse(image_url)
|
83
69
|
end
|
84
70
|
|
85
71
|
sig { returns(String) }
|
@@ -94,15 +80,6 @@ module Kuby
|
|
94
80
|
TimestampTag.new(Time.now).to_s, LATEST_TAG
|
95
81
|
]
|
96
82
|
end
|
97
|
-
|
98
|
-
sig { params(url: String).returns(URI::Generic) }
|
99
|
-
def parse_url(url)
|
100
|
-
uri = URI.parse(url)
|
101
|
-
return uri if uri.scheme
|
102
|
-
|
103
|
-
# force a scheme because URI.parse won't work properly without one
|
104
|
-
URI.parse("#{DEFAULT_REGISTRY_SCHEME}://#{url}")
|
105
|
-
end
|
106
83
|
end
|
107
84
|
end
|
108
85
|
end
|
data/lib/kuby/tasks.rb
CHANGED
@@ -41,10 +41,10 @@ module Kuby
|
|
41
41
|
fail 'Cannot push Docker images built for the development environment'
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
host = docker.metadata.image_host
|
45
45
|
|
46
|
-
if docker.credentials.username && !docker.cli.auths.include?(
|
47
|
-
Kuby.logger.info("Attempting to log in to registry at #{
|
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 #{
|
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
|
data/lib/kuby/version.rb
CHANGED
@@ -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(
|
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('
|
27
|
+
it { is_expected.to eq('registry.foo.com') }
|
28
28
|
end
|
29
29
|
|
30
|
-
context 'when the image URL contains an explicit host
|
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('
|
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('index.docker.io') }
|
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.
|
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-11-
|
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.
|
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.
|
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
|