kuby-core 0.11.14 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/Gemfile +2 -2
- data/README.md +2 -1
- data/bin/kuby +2 -0
- data/kuby-core.gemspec +2 -2
- data/lib/kuby/basic_logger.rb +1 -1
- data/lib/kuby/cli_base.rb +9 -4
- data/lib/kuby/commands.rb +16 -69
- data/lib/kuby/docker/alpine.rb +2 -1
- data/lib/kuby/docker/app_image.rb +19 -0
- data/lib/kuby/docker/bundler_phase.rb +9 -3
- data/lib/kuby/docker/cli.rb +4 -12
- data/lib/kuby/docker/docker_uri.rb +18 -7
- data/lib/kuby/docker/errors.rb +1 -19
- data/lib/kuby/docker/image.rb +115 -0
- data/lib/kuby/docker/layer.rb +0 -7
- data/lib/kuby/docker/local_tags.rb +9 -10
- data/lib/kuby/docker/package_phase.rb +0 -5
- data/lib/kuby/docker/packages.rb +1 -0
- data/lib/kuby/docker/remote_tags.rb +10 -5
- data/lib/kuby/docker/setup_phase.rb +17 -9
- data/lib/kuby/docker/spec.rb +29 -62
- data/lib/kuby/docker/timestamp_tag.rb +8 -1
- data/lib/kuby/docker/timestamped_image.rb +113 -0
- data/lib/kuby/docker/yarn_phase.rb +2 -2
- data/lib/kuby/docker.rb +27 -25
- data/lib/kuby/environment.rb +1 -10
- data/lib/kuby/kubernetes/bare_metal_provider.rb +53 -0
- data/lib/kuby/kubernetes/deployer.rb +2 -1
- data/lib/kuby/kubernetes/docker_desktop_provider.rb +0 -15
- data/lib/kuby/kubernetes/spec.rb +21 -17
- data/lib/kuby/kubernetes.rb +1 -0
- data/lib/kuby/plugin.rb +2 -2
- data/lib/kuby/plugins/rails_app/assets.rb +60 -70
- data/lib/kuby/plugins/rails_app/assets_image.rb +55 -0
- data/lib/kuby/plugins/rails_app/plugin.rb +54 -213
- data/lib/kuby/plugins/rails_app.rb +1 -0
- data/lib/kuby/tasks.rb +30 -69
- data/lib/kuby/version.rb +1 -1
- data/lib/kuby.rb +3 -20
- data/spec/docker/spec_spec.rb +21 -118
- data/spec/docker/timestamped_image_spec.rb +123 -0
- data/spec/spec_helper.rb +10 -11
- metadata +11 -14
- data/lib/kuby/dev_setup.rb +0 -346
- data/lib/kuby/docker/dev_spec.rb +0 -202
- data/lib/kuby/docker/metadata.rb +0 -90
- data/lib/kuby/docker/tags.rb +0 -92
- data/lib/kuby/rails_commands.rb +0 -84
- data/spec/docker/metadata_spec.rb +0 -73
- data/spec/dummy/Gemfile.lock +0 -223
- data/spec/dummy/config/master.key +0 -1
- data/spec/dummy/tmp/cache/bootsnap-load-path-cache +0 -0
data/lib/kuby/tasks.rb
CHANGED
@@ -9,65 +9,60 @@ module Kuby
|
|
9
9
|
@environment = environment
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def print_dockerfiles
|
13
|
+
kubernetes.docker_images.each do |image|
|
14
|
+
image = image.current_version
|
15
|
+
Kuby.logger.info("Dockerfile for image #{image.image_url} with tags #{image.tags.join(', ')}")
|
16
|
+
theme = Rouge::Themes::Base16::Solarized.new
|
17
|
+
formatter = Rouge::Formatters::Terminal256.new(theme)
|
18
|
+
lexer = Rouge::Lexers::Docker.new
|
19
|
+
tokens = lexer.lex(image.dockerfile.to_s)
|
20
|
+
puts formatter.format(tokens)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def setup
|
21
25
|
environment.kubernetes.setup
|
22
26
|
end
|
23
27
|
|
24
|
-
def build
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
build_args
|
28
|
+
def build(build_args = {})
|
29
|
+
kubernetes.docker_images.each do |image|
|
30
|
+
image = image.new_version
|
31
|
+
Kuby.logger.info("Building image #{image.image_url} with tags #{image.tags.join(', ')}")
|
32
|
+
image.build(build_args)
|
29
33
|
end
|
30
|
-
|
31
|
-
docker.cli.build(
|
32
|
-
dockerfile: docker.to_dockerfile,
|
33
|
-
image_url: docker.metadata.image_url,
|
34
|
-
tags: docker.metadata.tags,
|
35
|
-
build_args: build_args
|
36
|
-
)
|
37
34
|
end
|
38
35
|
|
39
36
|
def push
|
40
|
-
|
41
|
-
|
37
|
+
kubernetes.docker_images.each do |image|
|
38
|
+
image = image.current_version
|
39
|
+
Kuby.logger.info("Pushing image #{image.image_url} with tags #{image.tags.join(', ')}")
|
40
|
+
push_image(image)
|
42
41
|
end
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Kuby.logger.info("Attempting to log in to registry at #{host}")
|
44
|
+
def push_image(image)
|
45
|
+
if image.credentials.username && !image.docker_cli.auths.include?(image.image_host)
|
46
|
+
Kuby.logger.info("Attempting to log in to registry at #{image.image_host}")
|
48
47
|
|
49
48
|
begin
|
50
|
-
|
51
|
-
url:
|
52
|
-
username:
|
53
|
-
password:
|
49
|
+
image.docker_cli.login(
|
50
|
+
url: image.image_host,
|
51
|
+
username: image.credentials.username,
|
52
|
+
password: image.credentials.password
|
54
53
|
)
|
55
54
|
rescue Kuby::Docker::LoginError => e
|
56
|
-
Kuby.logger.fatal("Couldn't log in to the registry at #{
|
55
|
+
Kuby.logger.fatal("Couldn't log in to the registry at #{image.image_host}")
|
57
56
|
Kuby.logger.fatal(e.message)
|
58
57
|
return
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
|
-
image_url = docker.metadata.image_url
|
63
|
-
|
64
61
|
begin
|
65
|
-
|
66
|
-
docker.cli.push(image_url, tag)
|
67
|
-
end
|
62
|
+
image.tags.each { |tag| image.push(tag) }
|
68
63
|
rescue Kuby::Docker::MissingTagError => e
|
69
64
|
msg = "#{e.message} Run kuby build to build the "\
|
70
|
-
'Docker
|
65
|
+
'Docker images before running this task.'
|
71
66
|
|
72
67
|
Kuby.logger.fatal(msg)
|
73
68
|
Kuby.logger.fatal(e.message)
|
@@ -135,40 +130,6 @@ module Kuby
|
|
135
130
|
kubernetes_cli.restart_deployment(namespace, deployment)
|
136
131
|
end
|
137
132
|
|
138
|
-
def dev_deployment_ok
|
139
|
-
return true unless Kuby.environment.development?
|
140
|
-
|
141
|
-
deployments = kubernetes_cli.get_objects(
|
142
|
-
'deployments', namespace, match_labels.serialize
|
143
|
-
)
|
144
|
-
|
145
|
-
if deployments.empty?
|
146
|
-
puts 'No development environment detected.'
|
147
|
-
STDOUT.write('Set up development environment? (y/n): ')
|
148
|
-
answer = STDIN.gets.strip.downcase
|
149
|
-
return false unless answer =~ /ye?s?/
|
150
|
-
return DevSetup.new(environment).run
|
151
|
-
else
|
152
|
-
depl = deployments.first
|
153
|
-
deployed_checksum = depl.dig('metadata', 'annotations', 'getkuby.io/dockerfile-checksum')
|
154
|
-
current_checksum = docker.to_dockerfile.checksum
|
155
|
-
|
156
|
-
if deployed_checksum != current_checksum
|
157
|
-
puts "Development environment appears to be out-of-date."
|
158
|
-
puts "Environment checksum: #{deployed_checksum}"
|
159
|
-
puts "Current checksum: #{current_checksum}"
|
160
|
-
STDOUT.write('Update development environment? (y/n): ')
|
161
|
-
answer = STDIN.gets.strip.downcase
|
162
|
-
# return true here to prevent letting an out-of-date deployment
|
163
|
-
# stop us from running commands
|
164
|
-
return true unless answer =~ /ye?s?/
|
165
|
-
return DevSetup.new(environment).run
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
true
|
170
|
-
end
|
171
|
-
|
172
133
|
private
|
173
134
|
|
174
135
|
def get_first_pod
|
data/lib/kuby/version.rb
CHANGED
data/lib/kuby.rb
CHANGED
@@ -13,7 +13,6 @@ module Kuby
|
|
13
13
|
autoload :CLIBase, 'kuby/cli_base'
|
14
14
|
autoload :Commands, 'kuby/commands'
|
15
15
|
autoload :Definition, 'kuby/definition'
|
16
|
-
autoload :DevSetup, 'kuby/dev_setup'
|
17
16
|
autoload :Docker, 'kuby/docker'
|
18
17
|
autoload :Environment, 'kuby/environment'
|
19
18
|
autoload :Kubernetes, 'kuby/kubernetes'
|
@@ -21,7 +20,6 @@ module Kuby
|
|
21
20
|
autoload :Plugin, 'kuby/plugin'
|
22
21
|
autoload :PluginRegistry, 'kuby/plugin_registry'
|
23
22
|
autoload :Plugins, 'kuby/plugins'
|
24
|
-
autoload :RailsCommands, 'kuby/rails_commands'
|
25
23
|
autoload :Tasks, 'kuby/tasks'
|
26
24
|
autoload :TrailingHash, 'kuby/trailing_hash'
|
27
25
|
|
@@ -52,24 +50,6 @@ module Kuby
|
|
52
50
|
@definition = Definition.new(name.to_s)
|
53
51
|
@definition.instance_eval(&block)
|
54
52
|
|
55
|
-
# default development environment
|
56
|
-
@definition.environment(:development) do
|
57
|
-
kubernetes do
|
58
|
-
add_plugin(:rails_app) do
|
59
|
-
tls_enabled false
|
60
|
-
|
61
|
-
database do
|
62
|
-
if requires_credentials?
|
63
|
-
user(DEFAULT_DB_USER)
|
64
|
-
password(DEFAULT_DB_PASSWORD)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
provider :docker_desktop
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
53
|
@definition.environments.each do |_, env|
|
74
54
|
env.kubernetes.after_configuration
|
75
55
|
end
|
@@ -153,6 +133,7 @@ end
|
|
153
133
|
|
154
134
|
# providers
|
155
135
|
Kuby.register_provider(:docker_desktop, Kuby::Kubernetes::DockerDesktopProvider)
|
136
|
+
Kuby.register_provider(:bare_metal, Kuby::Kubernetes::BareMetalProvider)
|
156
137
|
|
157
138
|
# plugins
|
158
139
|
Kuby.register_plugin(:rails_app, Kuby::Plugins::RailsApp::Plugin)
|
@@ -173,3 +154,5 @@ Kuby.register_package(:c_toolchain,
|
|
173
154
|
debian: 'build-essential',
|
174
155
|
alpine: 'build-base'
|
175
156
|
)
|
157
|
+
|
158
|
+
Kuby.register_package(:git, 'git')
|
data/spec/docker/spec_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# typed: false
|
2
2
|
require 'spec_helper'
|
3
|
-
require 'timecop'
|
4
3
|
|
5
4
|
describe Kuby::Docker::Spec do
|
6
5
|
let(:spec) { definition.environment.docker }
|
7
6
|
|
8
7
|
describe '#base_image' do
|
9
|
-
subject { spec.
|
8
|
+
subject { spec.image.dockerfile.to_s }
|
10
9
|
|
11
10
|
it 'uses the default base image for Debian' do
|
12
11
|
expect(subject).to include("FROM ruby:#{RUBY_VERSION}\n")
|
@@ -34,7 +33,7 @@ describe Kuby::Docker::Spec do
|
|
34
33
|
Kuby::Docker::SetupPhase::DEFAULT_WORKING_DIR
|
35
34
|
end
|
36
35
|
|
37
|
-
subject { spec.
|
36
|
+
subject { spec.image.dockerfile.to_s }
|
38
37
|
|
39
38
|
it 'uses the default working dir' do
|
40
39
|
expect(subject).to(
|
@@ -52,7 +51,7 @@ describe Kuby::Docker::Spec do
|
|
52
51
|
end
|
53
52
|
|
54
53
|
describe '#rails_env' do
|
55
|
-
subject { spec.
|
54
|
+
subject { spec.image.dockerfile.to_s }
|
56
55
|
|
57
56
|
it 'uses the name of the current Kuby environment' do
|
58
57
|
expect(subject).to include("ENV RAILS_ENV=#{spec.environment.name}\n")
|
@@ -73,7 +72,7 @@ describe Kuby::Docker::Spec do
|
|
73
72
|
end
|
74
73
|
|
75
74
|
describe '#bundler_version' do
|
76
|
-
subject { spec.
|
75
|
+
subject { spec.image.dockerfile.to_s }
|
77
76
|
|
78
77
|
it 'installs the current bundler version' do
|
79
78
|
expect(subject).to(
|
@@ -91,7 +90,7 @@ describe Kuby::Docker::Spec do
|
|
91
90
|
end
|
92
91
|
|
93
92
|
describe '#gemfile' do
|
94
|
-
subject { spec.
|
93
|
+
subject { spec.image.dockerfile.to_s }
|
95
94
|
|
96
95
|
it 'uses the default Gemfile' do
|
97
96
|
expect(subject).to include("COPY Gemfile .\n")
|
@@ -108,10 +107,22 @@ describe Kuby::Docker::Spec do
|
|
108
107
|
expect(subject).to match(/RUN bundle install .* --gemfile foo\/bar\/Gemfile/)
|
109
108
|
end
|
110
109
|
end
|
110
|
+
|
111
|
+
context 'when multiple gemfiles are specified' do
|
112
|
+
before { spec.bundler_phase.gemfiles('gemfiles/a.gemfile', 'gemfiles/b.gemfile') }
|
113
|
+
|
114
|
+
it 'uses all gemfiles including the default one' do
|
115
|
+
expect(subject).to include("COPY Gemfile .\n")
|
116
|
+
expect(subject).to include("COPY Gemfile.lock .\n")
|
117
|
+
expect(subject).to include("COPY gemfiles/a.gemfile gemfiles/a.gemfile\n")
|
118
|
+
expect(subject).to include("COPY gemfiles/b.gemfile gemfiles/b.gemfile\n")
|
119
|
+
expect(subject).to match(/RUN bundle install .* --gemfile Gemfile/)
|
120
|
+
end
|
121
|
+
end
|
111
122
|
end
|
112
123
|
|
113
124
|
describe '#package' do
|
114
|
-
subject { spec.
|
125
|
+
subject { spec.image.dockerfile.to_s }
|
115
126
|
|
116
127
|
it 'installs the given package' do
|
117
128
|
# configured in spec_helper.rb
|
@@ -122,7 +133,7 @@ describe Kuby::Docker::Spec do
|
|
122
133
|
end
|
123
134
|
|
124
135
|
describe '#files' do
|
125
|
-
subject { spec.
|
136
|
+
subject { spec.image.dockerfile.to_s }
|
126
137
|
|
127
138
|
it 'copies the current directory contents by default' do
|
128
139
|
expect(subject).to include("COPY ./ .\n")
|
@@ -142,7 +153,7 @@ describe Kuby::Docker::Spec do
|
|
142
153
|
Kuby::Docker::WebserverPhase::DEFAULT_PORT
|
143
154
|
end
|
144
155
|
|
145
|
-
subject { spec.
|
156
|
+
subject { spec.image.dockerfile.to_s }
|
146
157
|
|
147
158
|
it 'exposes the default port' do
|
148
159
|
expect(subject).to include("EXPOSE #{default_port}\n")
|
@@ -157,116 +168,8 @@ describe Kuby::Docker::Spec do
|
|
157
168
|
end
|
158
169
|
end
|
159
170
|
|
160
|
-
describe '#tag' do
|
161
|
-
let(:tag) { make_ts_tag(Time.now) }
|
162
|
-
|
163
|
-
subject { spec.tag }
|
164
|
-
|
165
|
-
context 'with no local or remote tags' do
|
166
|
-
it 'raises an error' do
|
167
|
-
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'with an available remote tag' do
|
172
|
-
before { docker_remote_client.tags << tag }
|
173
|
-
|
174
|
-
it { is_expected.to eq(tag) }
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'with an available local tag' do
|
178
|
-
before do
|
179
|
-
docker_cli.build(
|
180
|
-
dockerfile: nil,
|
181
|
-
image_url: docker_image_url,
|
182
|
-
tags: [tag]
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
it { is_expected.to eq(tag) }
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'with multiple remote tags' do
|
190
|
-
let(:time) { Time.now }
|
191
|
-
|
192
|
-
before do
|
193
|
-
docker_remote_client.tags +=
|
194
|
-
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
195
|
-
make_ts_tag(t)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it { is_expected.to eq(make_ts_tag(time + 15)) }
|
200
|
-
end
|
201
|
-
|
202
|
-
context 'with multiple local and remote tags' do
|
203
|
-
let(:time) { Time.now }
|
204
|
-
|
205
|
-
before do
|
206
|
-
docker_remote_client.tags +=
|
207
|
-
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
208
|
-
make_ts_tag(t)
|
209
|
-
end
|
210
|
-
|
211
|
-
docker_cli.build(
|
212
|
-
dockerfile: nil,
|
213
|
-
image_url: docker_image_url,
|
214
|
-
tags: [time - 3, time + 6, time - 6, time + 18].map do |t|
|
215
|
-
make_ts_tag(t)
|
216
|
-
end
|
217
|
-
)
|
218
|
-
end
|
219
|
-
|
220
|
-
it { is_expected.to eq(make_ts_tag(time + 18)) }
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe '#previous_tag' do
|
225
|
-
let(:time) { Time.now }
|
226
|
-
let(:current_tag) { make_ts_tag(time) }
|
227
|
-
|
228
|
-
before do
|
229
|
-
docker_remote_client.tags << current_tag
|
230
|
-
docker_cli.build(
|
231
|
-
dockerfile: nil,
|
232
|
-
image_url: docker_image_url,
|
233
|
-
tags: [current_tag]
|
234
|
-
)
|
235
|
-
end
|
236
|
-
|
237
|
-
subject { spec.previous_tag(current_tag) }
|
238
|
-
|
239
|
-
context 'with no previous local or remote tag' do
|
240
|
-
it 'raises an error' do
|
241
|
-
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
context 'with an available previous remote tag' do
|
246
|
-
let(:previous_tag) { make_ts_tag(time - 5) }
|
247
|
-
|
248
|
-
before { docker_remote_client.tags << previous_tag }
|
249
|
-
|
250
|
-
it { is_expected.to eq(previous_tag) }
|
251
|
-
end
|
252
|
-
|
253
|
-
context 'with an available previous local tag' do
|
254
|
-
let(:previous_tag) { make_ts_tag(time - 5) }
|
255
|
-
|
256
|
-
before do
|
257
|
-
docker_cli.build(
|
258
|
-
dockerfile: nil,
|
259
|
-
image_url: docker_image_url,
|
260
|
-
tags: [previous_tag]
|
261
|
-
)
|
262
|
-
end
|
263
|
-
|
264
|
-
it { is_expected.to eq(previous_tag) }
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
171
|
describe '#insert' do
|
269
|
-
subject { spec.
|
172
|
+
subject { spec.image.dockerfile.to_s }
|
270
173
|
|
271
174
|
context 'with a custom class-based build phase' do
|
272
175
|
before do
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# typed: false
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Kuby::Docker::TimestampedImage do
|
5
|
+
let(:dockerfile) { Kuby::Docker::Dockerfile.new }
|
6
|
+
let(:image_url) { docker_image_url }
|
7
|
+
let(:credentials) do
|
8
|
+
Kuby::Docker::Credentials.new do
|
9
|
+
username 'foo'
|
10
|
+
password 'bar'
|
11
|
+
email 'foo@bar.com'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
let(:image) { described_class.new(dockerfile, image_url, credentials) }
|
15
|
+
|
16
|
+
describe '#current_version' do
|
17
|
+
let(:tag) { make_ts_tag(Time.now) }
|
18
|
+
|
19
|
+
subject { image.current_version&.main_tag }
|
20
|
+
|
21
|
+
context 'with no local or remote tags' do
|
22
|
+
it 'raises an error' do
|
23
|
+
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with an available remote tag' do
|
28
|
+
before { docker_remote_client.tags << tag }
|
29
|
+
|
30
|
+
it { is_expected.to eq(tag) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with an available local tag' do
|
34
|
+
before do
|
35
|
+
docker_cli.build(
|
36
|
+
dockerfile: nil,
|
37
|
+
image_url: docker_image_url,
|
38
|
+
tags: [tag]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it { is_expected.to eq(tag) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with multiple remote tags' do
|
46
|
+
let(:time) { Time.now }
|
47
|
+
|
48
|
+
before do
|
49
|
+
docker_remote_client.tags +=
|
50
|
+
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
51
|
+
make_ts_tag(t)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it { is_expected.to eq(make_ts_tag(time + 15)) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with multiple local and remote tags' do
|
59
|
+
let(:time) { Time.now }
|
60
|
+
|
61
|
+
before do
|
62
|
+
docker_remote_client.tags +=
|
63
|
+
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
64
|
+
make_ts_tag(t)
|
65
|
+
end
|
66
|
+
|
67
|
+
docker_cli.build(
|
68
|
+
dockerfile: nil,
|
69
|
+
image_url: docker_image_url,
|
70
|
+
tags: [time - 3, time + 6, time - 6, time + 18].map do |t|
|
71
|
+
make_ts_tag(t)
|
72
|
+
end
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it { is_expected.to eq(make_ts_tag(time + 18)) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#previous_version' do
|
81
|
+
let(:time) { Time.now }
|
82
|
+
let(:current_tag) { make_ts_tag(time) }
|
83
|
+
|
84
|
+
before do
|
85
|
+
docker_remote_client.tags << current_tag
|
86
|
+
docker_cli.build(
|
87
|
+
dockerfile: nil,
|
88
|
+
image_url: docker_image_url,
|
89
|
+
tags: [current_tag]
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
subject { image.previous_version(current_tag)&.main_tag }
|
94
|
+
|
95
|
+
context 'with no previous local or remote tag' do
|
96
|
+
it 'raises an error' do
|
97
|
+
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'with an available previous remote tag' do
|
102
|
+
let(:previous_tag) { make_ts_tag(time - 5) }
|
103
|
+
|
104
|
+
before { docker_remote_client.tags << previous_tag }
|
105
|
+
|
106
|
+
it { is_expected.to eq(previous_tag) }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with an available previous local tag' do
|
110
|
+
let(:previous_tag) { make_ts_tag(time - 5) }
|
111
|
+
|
112
|
+
before do
|
113
|
+
docker_cli.build(
|
114
|
+
dockerfile: nil,
|
115
|
+
image_url: docker_image_url,
|
116
|
+
tags: [previous_tag]
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
it { is_expected.to eq(previous_tag) }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -71,24 +71,23 @@ module SpecHelpers
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
75
|
-
environment(:development) do
|
76
|
-
kubernetes do
|
77
|
-
configure_plugin(:rails_app) do
|
78
|
-
root File.expand_path(File.join(*%w(. dummy)), __dir__)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
74
|
end
|
83
75
|
|
84
76
|
docker = definition.environment.docker
|
85
77
|
|
86
|
-
docker.instance_variable_set(:@remote_client, docker_remote_client)
|
87
|
-
docker.instance_variable_set(:@cli, docker_cli)
|
88
|
-
|
89
78
|
definition
|
90
79
|
end
|
91
80
|
|
81
|
+
before do
|
82
|
+
allow_any_instance_of(Kuby::Docker::TimestampedImage).to(
|
83
|
+
receive(:remote_client).and_return(docker_remote_client)
|
84
|
+
)
|
85
|
+
|
86
|
+
allow_any_instance_of(Kuby::Docker::Image).to(
|
87
|
+
receive(:docker_cli).and_return(docker_cli)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
92
91
|
def make_ts_tag(time)
|
93
92
|
Kuby::Docker::TimestampTag.new(time).to_s
|
94
93
|
end
|
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.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-24 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.6'
|
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.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,25 +219,24 @@ files:
|
|
219
219
|
- lib/kuby/cli_base.rb
|
220
220
|
- lib/kuby/commands.rb
|
221
221
|
- lib/kuby/definition.rb
|
222
|
-
- lib/kuby/dev_setup.rb
|
223
222
|
- lib/kuby/docker.rb
|
224
223
|
- lib/kuby/docker/alpine.rb
|
224
|
+
- lib/kuby/docker/app_image.rb
|
225
225
|
- lib/kuby/docker/assets_phase.rb
|
226
226
|
- lib/kuby/docker/bundler_phase.rb
|
227
227
|
- lib/kuby/docker/cli.rb
|
228
228
|
- lib/kuby/docker/copy_phase.rb
|
229
229
|
- lib/kuby/docker/credentials.rb
|
230
230
|
- lib/kuby/docker/debian.rb
|
231
|
-
- lib/kuby/docker/dev_spec.rb
|
232
231
|
- lib/kuby/docker/distro.rb
|
233
232
|
- lib/kuby/docker/docker_uri.rb
|
234
233
|
- lib/kuby/docker/dockerfile.rb
|
235
234
|
- lib/kuby/docker/errors.rb
|
235
|
+
- lib/kuby/docker/image.rb
|
236
236
|
- lib/kuby/docker/inline_layer.rb
|
237
237
|
- lib/kuby/docker/layer.rb
|
238
238
|
- lib/kuby/docker/layer_stack.rb
|
239
239
|
- lib/kuby/docker/local_tags.rb
|
240
|
-
- lib/kuby/docker/metadata.rb
|
241
240
|
- lib/kuby/docker/package_list.rb
|
242
241
|
- lib/kuby/docker/package_phase.rb
|
243
242
|
- lib/kuby/docker/packages.rb
|
@@ -249,12 +248,13 @@ files:
|
|
249
248
|
- lib/kuby/docker/remote_tags.rb
|
250
249
|
- lib/kuby/docker/setup_phase.rb
|
251
250
|
- lib/kuby/docker/spec.rb
|
252
|
-
- lib/kuby/docker/tags.rb
|
253
251
|
- lib/kuby/docker/timestamp_tag.rb
|
252
|
+
- lib/kuby/docker/timestamped_image.rb
|
254
253
|
- lib/kuby/docker/webserver_phase.rb
|
255
254
|
- lib/kuby/docker/yarn_phase.rb
|
256
255
|
- lib/kuby/environment.rb
|
257
256
|
- lib/kuby/kubernetes.rb
|
257
|
+
- lib/kuby/kubernetes/bare_metal_provider.rb
|
258
258
|
- lib/kuby/kubernetes/deploy_task.rb
|
259
259
|
- lib/kuby/kubernetes/deployer.rb
|
260
260
|
- lib/kuby/kubernetes/docker_config.rb
|
@@ -273,6 +273,7 @@ files:
|
|
273
273
|
- lib/kuby/plugins/rails_app.rb
|
274
274
|
- lib/kuby/plugins/rails_app/asset_copy_task.rb
|
275
275
|
- lib/kuby/plugins/rails_app/assets.rb
|
276
|
+
- lib/kuby/plugins/rails_app/assets_image.rb
|
276
277
|
- lib/kuby/plugins/rails_app/database.rb
|
277
278
|
- lib/kuby/plugins/rails_app/generators/kuby.rb
|
278
279
|
- lib/kuby/plugins/rails_app/mysql.rb
|
@@ -281,16 +282,14 @@ files:
|
|
281
282
|
- lib/kuby/plugins/rails_app/rewrite_db_config.rb
|
282
283
|
- lib/kuby/plugins/rails_app/sqlite.rb
|
283
284
|
- lib/kuby/plugins/rails_app/tasks.rake
|
284
|
-
- lib/kuby/rails_commands.rb
|
285
285
|
- lib/kuby/railtie.rb
|
286
286
|
- lib/kuby/tasks.rb
|
287
287
|
- lib/kuby/trailing_hash.rb
|
288
288
|
- lib/kuby/version.rb
|
289
|
-
- spec/docker/metadata_spec.rb
|
290
289
|
- spec/docker/spec_spec.rb
|
291
290
|
- spec/docker/timestamp_tag_spec.rb
|
291
|
+
- spec/docker/timestamped_image_spec.rb
|
292
292
|
- spec/dummy/Gemfile
|
293
|
-
- spec/dummy/Gemfile.lock
|
294
293
|
- spec/dummy/README.md
|
295
294
|
- spec/dummy/Rakefile
|
296
295
|
- spec/dummy/app/assets/config/manifest.js
|
@@ -334,7 +333,6 @@ files:
|
|
334
333
|
- spec/dummy/config/initializers/mime_types.rb
|
335
334
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
336
335
|
- spec/dummy/config/locales/en.yml
|
337
|
-
- spec/dummy/config/master.key
|
338
336
|
- spec/dummy/config/puma.rb
|
339
337
|
- spec/dummy/config/routes.rb
|
340
338
|
- spec/dummy/config/spring.rb
|
@@ -351,7 +349,6 @@ files:
|
|
351
349
|
- spec/dummy/test/application_system_test_case.rb
|
352
350
|
- spec/dummy/test/channels/application_cable/connection_test.rb
|
353
351
|
- spec/dummy/test/test_helper.rb
|
354
|
-
- spec/dummy/tmp/cache/bootsnap-load-path-cache
|
355
352
|
- spec/spec_helper.rb
|
356
353
|
- spec/support/docker/fake_cli.rb
|
357
354
|
- spec/support/docker/remote/fake_client.rb
|
@@ -374,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
371
|
- !ruby/object:Gem::Version
|
375
372
|
version: '0'
|
376
373
|
requirements: []
|
377
|
-
rubygems_version: 3.
|
374
|
+
rubygems_version: 3.2.22
|
378
375
|
signing_key:
|
379
376
|
specification_version: 4
|
380
377
|
summary: Deploy your Rails app onto Kubernetes the easy way.
|