kuby-core 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/Gemfile +6 -2
  4. data/Rakefile +5 -3
  5. data/bin/tapioca +29 -0
  6. data/kuby-core.gemspec +9 -11
  7. data/lib/kuby/basic_logger.rb +34 -34
  8. data/lib/kuby/cli_base.rb +43 -43
  9. data/lib/kuby/commands.rb +94 -11
  10. data/lib/kuby/definition.rb +12 -12
  11. data/lib/kuby/dependable.rb +20 -0
  12. data/lib/kuby/dependency.rb +14 -0
  13. data/lib/kuby/docker/alpine.rb +10 -10
  14. data/lib/kuby/docker/app_image.rb +11 -11
  15. data/lib/kuby/docker/app_phase.rb +36 -0
  16. data/lib/kuby/docker/assets_phase.rb +2 -2
  17. data/lib/kuby/docker/bundler_phase.rb +42 -40
  18. data/lib/kuby/docker/cli.rb +71 -43
  19. data/lib/kuby/docker/copy_phase.rb +7 -7
  20. data/lib/kuby/docker/credentials.rb +1 -0
  21. data/lib/kuby/docker/debian.rb +10 -10
  22. data/lib/kuby/docker/distro.rb +13 -13
  23. data/lib/kuby/docker/docker_uri.rb +20 -20
  24. data/lib/kuby/docker/dockerfile.rb +48 -39
  25. data/lib/kuby/docker/image.rb +66 -54
  26. data/lib/kuby/docker/inline_layer.rb +4 -4
  27. data/lib/kuby/docker/layer.rb +6 -6
  28. data/lib/kuby/docker/layer_stack.rb +35 -35
  29. data/lib/kuby/docker/local_tags.rb +16 -16
  30. data/lib/kuby/docker/package_list.rb +16 -16
  31. data/lib/kuby/docker/package_phase.rb +16 -16
  32. data/lib/kuby/docker/packages/managed_package.rb +13 -13
  33. data/lib/kuby/docker/packages/nodejs.rb +5 -5
  34. data/lib/kuby/docker/packages/package.rb +8 -8
  35. data/lib/kuby/docker/packages/simple_managed_package.rb +7 -7
  36. data/lib/kuby/docker/packages/yarn.rb +6 -6
  37. data/lib/kuby/docker/remote_tags.rb +16 -16
  38. data/lib/kuby/docker/setup_phase.rb +18 -20
  39. data/lib/kuby/docker/spec.rb +93 -72
  40. data/lib/kuby/docker/timestamp_tag.rb +16 -11
  41. data/lib/kuby/docker/timestamped_image.rb +59 -40
  42. data/lib/kuby/docker/webserver_phase.rb +20 -20
  43. data/lib/kuby/docker/yarn_phase.rb +29 -5
  44. data/lib/kuby/docker.rb +2 -1
  45. data/lib/kuby/kubernetes/bare_metal_provider.rb +9 -9
  46. data/lib/kuby/kubernetes/deployer.rb +22 -10
  47. data/lib/kuby/kubernetes/docker_config.rb +1 -0
  48. data/lib/kuby/kubernetes/provider.rb +1 -0
  49. data/lib/kuby/kubernetes/spec.rb +47 -7
  50. data/lib/kuby/plugin.rb +22 -1
  51. data/lib/kuby/plugins/nginx_ingress.rb +8 -6
  52. data/lib/kuby/plugins/rails_app/assets.rb +16 -4
  53. data/lib/kuby/plugins/rails_app/assets_image.rb +17 -8
  54. data/lib/kuby/plugins/rails_app/crdb/plugin.rb +473 -0
  55. data/lib/kuby/plugins/rails_app/crdb.rb +9 -0
  56. data/lib/kuby/plugins/rails_app/database.rb +12 -8
  57. data/lib/kuby/plugins/rails_app/generators/kuby.rb +17 -16
  58. data/lib/kuby/plugins/rails_app/plugin.rb +29 -18
  59. data/lib/kuby/plugins/rails_app/sqlite.rb +7 -3
  60. data/lib/kuby/plugins/rails_app/tasks.rake +25 -12
  61. data/lib/kuby/plugins/rails_app.rb +1 -0
  62. data/lib/kuby/plugins/system.rb +16 -0
  63. data/lib/kuby/plugins.rb +1 -0
  64. data/lib/kuby/railtie.rb +31 -1
  65. data/lib/kuby/tasks.rb +72 -5
  66. data/lib/kuby/trailing_hash.rb +2 -2
  67. data/lib/kuby/utils/sem_ver/constraint.rb +68 -0
  68. data/lib/kuby/utils/sem_ver/constraint_set.rb +25 -0
  69. data/lib/kuby/utils/sem_ver/version.rb +49 -0
  70. data/lib/kuby/utils/sem_ver.rb +17 -0
  71. data/lib/kuby/utils/which.rb +65 -0
  72. data/lib/kuby/utils.rb +7 -1
  73. data/lib/kuby/version.rb +1 -1
  74. data/lib/kuby.rb +37 -2
  75. data/rbi/kuby-core.rbi +2128 -0
  76. data/spec/docker/spec_spec.rb +50 -26
  77. data/spec/dummy/app/channels/application_cable/channel.rb +2 -1
  78. data/spec/dummy/app/channels/application_cable/connection.rb +2 -1
  79. data/spec/dummy/app/controllers/application_controller.rb +2 -1
  80. data/spec/dummy/app/jobs/application_job.rb +2 -1
  81. data/spec/dummy/app/mailers/application_mailer.rb +2 -1
  82. data/spec/dummy/app/models/application_record.rb +2 -1
  83. data/spec/dummy/config/application.rb +2 -1
  84. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
  85. data/spec/dummy/config/routes.rb +2 -1
  86. data/spec/dummy/test/application_system_test_case.rb +2 -1
  87. data/spec/dummy/test/channels/application_cable/connection_test.rb +2 -1
  88. data/spec/spec_helper.rb +13 -1
  89. metadata +44 -39
  90. data/lib/kuby/plugins/rails_app/mysql.rb +0 -158
  91. data/lib/kuby/plugins/rails_app/postgres.rb +0 -163
@@ -12,7 +12,9 @@ describe Kuby::Docker::Spec do
12
12
  end
13
13
 
14
14
  context 'when the distro is set to Alpine' do
15
- before { spec.distro(:alpine) }
15
+ before do
16
+ on_define { |env| env.docker.distro(:alpine) }
17
+ end
16
18
 
17
19
  it 'uses the Alpine base image' do
18
20
  expect(subject).to include("FROM ruby:#{RUBY_VERSION}-alpine\n")
@@ -20,7 +22,9 @@ describe Kuby::Docker::Spec do
20
22
  end
21
23
 
22
24
  context 'when the base image is set to something custom' do
23
- before { spec.base_image('foo/bar') }
25
+ before do
26
+ on_define { |env| env.docker.base_image('foo/bar') }
27
+ end
24
28
 
25
29
  it 'uses the base image as given' do
26
30
  expect(subject).to include("FROM foo/bar\n")
@@ -42,7 +46,9 @@ describe Kuby::Docker::Spec do
42
46
  end
43
47
 
44
48
  context 'when the working dir is set to something custom' do
45
- before { spec.working_dir('/foo/bar') }
49
+ before do
50
+ on_define { |env| env.docker.working_dir('/foo/bar') }
51
+ end
46
52
 
47
53
  it 'uses the working dir as given' do
48
54
  expect(subject).to include("WORKDIR /foo/bar\n")
@@ -59,7 +65,9 @@ describe Kuby::Docker::Spec do
59
65
  end
60
66
 
61
67
  context 'when the environment is set to something custom' do
62
- before { spec.rails_env('foobar') }
68
+ before do
69
+ on_define { |env| env.docker.rails_env('foobar') }
70
+ end
63
71
 
64
72
  it 'uses the environment as given' do
65
73
  expect(subject).to include("ENV RAILS_ENV=foobar\n")
@@ -81,7 +89,9 @@ describe Kuby::Docker::Spec do
81
89
  end
82
90
 
83
91
  context 'when the bundler version is set to something custom' do
84
- before { spec.bundler_version('1.17.3') }
92
+ before do
93
+ on_define { |env| env.docker.bundler_version('1.17.3') }
94
+ end
85
95
 
86
96
  it 'installs the given version' do
87
97
  expect(subject).to include("RUN gem install bundler -v 1.17.3\n")
@@ -93,30 +103,34 @@ describe Kuby::Docker::Spec do
93
103
  subject { spec.image.dockerfile.to_s }
94
104
 
95
105
  it 'uses the default Gemfile' do
96
- expect(subject).to include("COPY Gemfile .\n")
97
- expect(subject).to include("COPY Gemfile.lock .\n")
98
- expect(subject).to match(/RUN bundle install .* --gemfile Gemfile/)
106
+ expect(subject).to include("COPY Gemfile /usr/src/app/Gemfile\n")
107
+ expect(subject).to include("COPY Gemfile.lock /usr/src/app/Gemfile.lock\n")
108
+ expect(subject).to include("ENV BUNDLE_GEMFILE=/usr/src/app/Gemfile")
99
109
  end
100
110
 
101
111
  context 'when the gemfile path is set to something custom' do
102
- before { spec.gemfile('foo/bar/Gemfile') }
112
+ before do
113
+ on_define { |env| env.docker.gemfile('foo/bar/Gemfile') }
114
+ end
103
115
 
104
116
  it 'uses the given gemfile' do
105
- expect(subject).to include("COPY foo/bar/Gemfile .\n")
106
- expect(subject).to include("COPY foo/bar/Gemfile.lock .\n")
107
- expect(subject).to match(/RUN bundle install .* --gemfile foo\/bar\/Gemfile/)
117
+ expect(subject).to include("COPY foo/bar/Gemfile /usr/src/app/foo/bar/Gemfile\n")
118
+ expect(subject).to include("COPY foo/bar/Gemfile.lock /usr/src/app/foo/bar/Gemfile.lock\n")
119
+ expect(subject).to include("ENV BUNDLE_GEMFILE=/usr/src/app/foo/bar/Gemfile")
108
120
  end
109
121
  end
110
122
 
111
123
  context 'when multiple gemfiles are specified' do
112
- before { spec.bundler_phase.gemfiles('gemfiles/a.gemfile', 'gemfiles/b.gemfile') }
124
+ before do
125
+ on_define { |env| env.docker.bundler_phase.gemfiles('gemfiles/a.gemfile', 'gemfiles/b.gemfile') }
126
+ end
113
127
 
114
128
  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/)
129
+ expect(subject).to include("COPY Gemfile /usr/src/app/Gemfile\n")
130
+ expect(subject).to include("COPY Gemfile.lock /usr/src/app/Gemfile.lock\n")
131
+ expect(subject).to include("COPY gemfiles/a.gemfile /usr/src/app/gemfiles/a.gemfile\n")
132
+ expect(subject).to include("COPY gemfiles/b.gemfile /usr/src/app/gemfiles/b.gemfile\n")
133
+ expect(subject).to include("ENV BUNDLE_GEMFILE=/usr/src/app/Gemfile")
120
134
  end
121
135
  end
122
136
  end
@@ -125,8 +139,10 @@ describe Kuby::Docker::Spec do
125
139
  subject { spec.image.dockerfile.to_s }
126
140
 
127
141
  it 'installs the given package' do
128
- # configured in spec_helper.rb
129
- spec.package(:fake_package)
142
+ on_define do |env|
143
+ # configured in spec_helper.rb
144
+ env.docker.package(:fake_package)
145
+ end
130
146
 
131
147
  expect(subject).to match(/apt-get install .* fake_package/m)
132
148
  end
@@ -140,7 +156,9 @@ describe Kuby::Docker::Spec do
140
156
  end
141
157
 
142
158
  context 'when given a custom path to copy' do
143
- before { spec.files('./foo/bar') }
159
+ before do
160
+ on_define { |env| env.docker.files('./foo/bar') }
161
+ end
144
162
 
145
163
  it 'copies the given paths only' do
146
164
  expect(subject).to include("COPY ./foo/bar .\n")
@@ -160,7 +178,9 @@ describe Kuby::Docker::Spec do
160
178
  end
161
179
 
162
180
  context 'when given a custom port' do
163
- before { spec.port(5555) }
181
+ before do
182
+ on_define { |env| env.docker.port(5555) }
183
+ end
164
184
 
165
185
  it 'exposes the given port' do
166
186
  expect(subject).to include("EXPOSE 5555\n")
@@ -181,7 +201,9 @@ describe Kuby::Docker::Spec do
181
201
  end
182
202
  end
183
203
 
184
- spec.insert :foo_phase, foo_phase.new, after: :webserver_phase
204
+ on_define do |env|
205
+ env.docker.insert :foo_phase, foo_phase.new, after: :webserver_phase
206
+ end
185
207
  end
186
208
 
187
209
  it 'inserts the commands' do
@@ -191,9 +213,11 @@ describe Kuby::Docker::Spec do
191
213
 
192
214
  context 'with a custom inline build phase' do
193
215
  before do
194
- spec.insert :hello, after: :webserver_phase do |dockerfile|
195
- dockerfile.insert_at(0) do
196
- dockerfile.run('echo "foo"')
216
+ on_define do |env|
217
+ env.docker.insert :hello, after: :webserver_phase do |dockerfile|
218
+ dockerfile.insert_at(0) do
219
+ dockerfile.run('echo "foo"')
220
+ end
197
221
  end
198
222
  end
199
223
  end
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  module ApplicationCable
3
4
  class Channel < ActionCable::Channel::Base
4
5
  end
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  module ApplicationCable
3
4
  class Connection < ActionCable::Connection::Base
4
5
  end
@@ -1,3 +1,4 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  class ApplicationController < ActionController::Base
3
4
  end
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  class ApplicationJob < ActiveJob::Base
3
4
  # Automatically retry jobs that encountered a deadlock
4
5
  # retry_on ActiveRecord::Deadlocked
@@ -1,4 +1,5 @@
1
- # typed: false
1
+ # typed: ignore
2
+
2
3
  class ApplicationMailer < ActionMailer::Base
3
4
  default from: 'from@example.com'
4
5
  layout 'mailer'
@@ -1,4 +1,5 @@
1
- # typed: false
1
+ # typed: ignore
2
+
2
3
  class ApplicationRecord < ActiveRecord::Base
3
4
  self.abstract_class = true
4
5
  end
@@ -1,4 +1,5 @@
1
- # typed: false
1
+ # typed: ignore
2
+
2
3
  require_relative 'boot'
3
4
 
4
5
  require 'rails/all'
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  # Be sure to restart your server when you modify this file.
3
4
 
4
5
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  Rails.application.routes.draw do
3
4
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
4
5
  end
@@ -1,4 +1,5 @@
1
- # typed: false
1
+ # typed: ignore
2
+
2
3
  require "test_helper"
3
4
 
4
5
  class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
@@ -1,4 +1,5 @@
1
- # typed: strict
1
+ # typed: ignore
2
+
2
3
  require "test_helper"
3
4
 
4
5
  class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # typed: false
2
+
2
3
  $:.push(File.expand_path('.', __dir__))
3
4
 
5
+ require 'sorbet-runtime'
4
6
  require 'kuby'
5
7
  require 'pry-byebug'
6
8
 
@@ -43,11 +45,17 @@ module SpecHelpers
43
45
  )
44
46
  end
45
47
 
48
+ let(:on_define_blocks) { [] }
49
+
50
+ def on_define(&block)
51
+ on_define_blocks << block
52
+ end
53
+
46
54
  let(:definition) do
47
55
  context = self
48
56
 
49
57
  definition = Kuby.define('dummy') do
50
- environment(:production) do
58
+ env = environment(:production) do
51
59
  docker do
52
60
  credentials do
53
61
  username context.docker_username
@@ -71,6 +79,10 @@ module SpecHelpers
71
79
  end
72
80
  end
73
81
  end
82
+
83
+ context.on_define_blocks.each do |blk|
84
+ blk.call(env)
85
+ end
74
86
  end
75
87
 
76
88
  docker = definition.environment.docker
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.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-01 00:00:00.000000000 Z
11
+ date: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.6'
33
+ version: '0.8'
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.6'
40
+ version: '0.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gli
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
47
+ version: '2.21'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.0'
54
+ version: '2.21'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: helm-cli
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,78 +70,72 @@ dependencies:
70
70
  name: krane
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.1.4
76
- - - "<"
73
+ - - "~>"
77
74
  - !ruby/object:Gem::Version
78
75
  version: '2.0'
79
76
  type: :runtime
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 1.1.4
86
- - - "<"
80
+ - - "~>"
87
81
  - !ruby/object:Gem::Version
88
82
  version: '2.0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: kuby-cert-manager
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - ">="
87
+ - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '0.3'
89
+ version: '0.4'
96
90
  type: :runtime
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - ">="
94
+ - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: '0.3'
96
+ version: '0.4'
103
97
  - !ruby/object:Gem::Dependency
104
- name: kube-dsl
98
+ name: kuby-crdb
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
101
  - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: '0.4'
103
+ version: '0.2'
110
104
  type: :runtime
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: '0.4'
110
+ version: '0.2'
117
111
  - !ruby/object:Gem::Dependency
118
- name: kuby-kube-db
112
+ name: kube-dsl
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
- - - ">="
115
+ - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: '0.6'
117
+ version: '0.7'
124
118
  type: :runtime
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
- - - ">="
122
+ - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: '0.6'
124
+ version: '0.7'
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: kubernetes-cli
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - "~>"
136
130
  - !ruby/object:Gem::Version
137
- version: '0.3'
131
+ version: '0.4'
138
132
  type: :runtime
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
136
  - - "~>"
143
137
  - !ruby/object:Gem::Version
144
- version: '0.3'
138
+ version: '0.4'
145
139
  - !ruby/object:Gem::Dependency
146
140
  name: railties
147
141
  requirement: !ruby/object:Gem::Requirement
@@ -171,19 +165,19 @@ dependencies:
171
165
  - !ruby/object:Gem::Version
172
166
  version: '3.0'
173
167
  - !ruby/object:Gem::Dependency
174
- name: sorbet-runtime-stub
168
+ name: rake
175
169
  requirement: !ruby/object:Gem::Requirement
176
170
  requirements:
177
- - - "~>"
171
+ - - ">="
178
172
  - !ruby/object:Gem::Version
179
- version: '0.2'
173
+ version: '0'
180
174
  type: :runtime
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
- - - "~>"
178
+ - - ">="
185
179
  - !ruby/object:Gem::Version
186
- version: '0.2'
180
+ version: '0'
187
181
  - !ruby/object:Gem::Dependency
188
182
  name: rspec
189
183
  requirement: !ruby/object:Gem::Requirement
@@ -212,6 +206,7 @@ files:
212
206
  - README.md
213
207
  - Rakefile
214
208
  - bin/kuby
209
+ - bin/tapioca
215
210
  - kuby-core.gemspec
216
211
  - lib/kuby-core.rb
217
212
  - lib/kuby.rb
@@ -219,9 +214,12 @@ files:
219
214
  - lib/kuby/cli_base.rb
220
215
  - lib/kuby/commands.rb
221
216
  - lib/kuby/definition.rb
217
+ - lib/kuby/dependable.rb
218
+ - lib/kuby/dependency.rb
222
219
  - lib/kuby/docker.rb
223
220
  - lib/kuby/docker/alpine.rb
224
221
  - lib/kuby/docker/app_image.rb
222
+ - lib/kuby/docker/app_phase.rb
225
223
  - lib/kuby/docker/assets_phase.rb
226
224
  - lib/kuby/docker/bundler_phase.rb
227
225
  - lib/kuby/docker/cli.rb
@@ -274,20 +272,27 @@ files:
274
272
  - lib/kuby/plugins/rails_app/asset_copy_task.rb
275
273
  - lib/kuby/plugins/rails_app/assets.rb
276
274
  - lib/kuby/plugins/rails_app/assets_image.rb
275
+ - lib/kuby/plugins/rails_app/crdb.rb
276
+ - lib/kuby/plugins/rails_app/crdb/plugin.rb
277
277
  - lib/kuby/plugins/rails_app/database.rb
278
278
  - lib/kuby/plugins/rails_app/generators/kuby.rb
279
- - lib/kuby/plugins/rails_app/mysql.rb
280
279
  - lib/kuby/plugins/rails_app/plugin.rb
281
- - lib/kuby/plugins/rails_app/postgres.rb
282
280
  - lib/kuby/plugins/rails_app/rewrite_db_config.rb
283
281
  - lib/kuby/plugins/rails_app/sqlite.rb
284
282
  - lib/kuby/plugins/rails_app/tasks.rake
283
+ - lib/kuby/plugins/system.rb
285
284
  - lib/kuby/railtie.rb
286
285
  - lib/kuby/tasks.rb
287
286
  - lib/kuby/trailing_hash.rb
288
287
  - lib/kuby/utils.rb
288
+ - lib/kuby/utils/sem_ver.rb
289
+ - lib/kuby/utils/sem_ver/constraint.rb
290
+ - lib/kuby/utils/sem_ver/constraint_set.rb
291
+ - lib/kuby/utils/sem_ver/version.rb
289
292
  - lib/kuby/utils/table.rb
293
+ - lib/kuby/utils/which.rb
290
294
  - lib/kuby/version.rb
295
+ - rbi/kuby-core.rbi
291
296
  - spec/docker/spec_spec.rb
292
297
  - spec/docker/timestamp_tag_spec.rb
293
298
  - spec/docker/timestamped_image_spec.rb
@@ -358,7 +363,7 @@ files:
358
363
  homepage: http://github.com/getkuby/kuby-core
359
364
  licenses: []
360
365
  metadata: {}
361
- post_install_message:
366
+ post_install_message:
362
367
  rdoc_options: []
363
368
  require_paths:
364
369
  - lib
@@ -373,8 +378,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
378
  - !ruby/object:Gem::Version
374
379
  version: '0'
375
380
  requirements: []
376
- rubygems_version: 3.2.22
377
- signing_key:
381
+ rubygems_version: 3.1.6
382
+ signing_key:
378
383
  specification_version: 4
379
384
  summary: Deploy your Rails app onto Kubernetes the easy way.
380
385
  test_files: []
@@ -1,158 +0,0 @@
1
- # typed: false
2
-
3
- require 'kube-dsl'
4
- require 'kuby/kube-db'
5
-
6
- module Kuby
7
- module Plugins
8
- module RailsApp
9
- class MySQL < ::Kuby::Plugin
10
- ROLE = 'web'.freeze
11
-
12
- attr_reader :environment, :configs
13
-
14
- def initialize(environment, configs)
15
- @environment = environment
16
- @configs = configs
17
- end
18
-
19
- def requires_credentials?
20
- true
21
- end
22
-
23
- def name
24
- :mysql
25
- end
26
-
27
- def resources
28
- @resources ||= [secret, database]
29
- end
30
-
31
- def after_configuration
32
- environment.docker.package_phase.add(:mysql_dev)
33
- environment.docker.package_phase.add(:mysql_client)
34
- end
35
-
36
- def host
37
- # host is the same as the name thanks to k8s DNS
38
- @host ||= database.metadata.name
39
- end
40
-
41
- def rewritten_configs
42
- # deep dup
43
- @rewritten_configs ||= Marshal.load(Marshal.dump(configs)).tap do |new_configs|
44
- new_configs[environment.name]['host'] = host
45
- end
46
- end
47
-
48
- def user(user)
49
- secret do
50
- data do
51
- set :user, user
52
- end
53
- end
54
- end
55
-
56
- def password(password)
57
- secret do
58
- data do
59
- set :password, password
60
- end
61
- end
62
- end
63
-
64
- def storage(amount)
65
- database do
66
- spec do
67
- storage do
68
- resources do
69
- requests do
70
- set :storage, amount
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
77
-
78
- def secret(&block)
79
- context = self
80
-
81
- @secret ||= KubeDSL.secret do
82
- metadata do
83
- name "#{context.base_name}-mysql-secret"
84
- namespace context.kubernetes.namespace.metadata.name
85
- end
86
-
87
- type 'Opaque'
88
- end
89
-
90
- @secret.instance_eval(&block) if block
91
- @secret
92
- end
93
-
94
- def database(&block)
95
- context = self
96
-
97
- @database ||= Kuby::KubeDB.my_sql do
98
- api_version 'kubedb.com/v1alpha1'
99
-
100
- metadata do
101
- name "#{context.base_name}-mysql"
102
- namespace context.kubernetes.namespace.metadata.name
103
- end
104
-
105
- spec do
106
- database_secret do
107
- secret_name context.secret.metadata.name
108
- end
109
-
110
- version '5.7-v2'
111
- storage_type 'Durable'
112
-
113
- storage do
114
- storage_class_name context.kubernetes.provider.storage_class_name
115
- access_modes ['ReadWriteOnce']
116
-
117
- resources do
118
- requests do
119
- add :storage, '10Gi'
120
- end
121
- end
122
- end
123
-
124
- termination_policy 'DoNotTerminate'
125
- end
126
- end
127
-
128
- @database.instance_eval(&block) if block
129
- @database
130
- end
131
-
132
- def base_name
133
- @base_name ||= "#{kubernetes.selector_app}-#{ROLE}"
134
- end
135
-
136
- def kubernetes
137
- environment.kubernetes
138
- end
139
-
140
- private
141
-
142
- def config
143
- configs[environment.name]
144
- end
145
- end
146
- end
147
- end
148
- end
149
-
150
- Kuby.register_package(:mysql_client,
151
- debian: 'default-mysql-client',
152
- alpine: 'mariadb-client'
153
- )
154
-
155
- Kuby.register_package(:mysql_dev,
156
- debian: 'default-libmysqlclient-dev',
157
- alpine: 'mariadb-dev'
158
- )