kuby-core 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile +1 -0
  4. data/README.md +4 -2
  5. data/kuby-core.gemspec +2 -1
  6. data/lib/kuby-core.rb +1 -0
  7. data/lib/kuby.rb +7 -0
  8. data/lib/kuby/basic_logger.rb +1 -0
  9. data/lib/kuby/cli_base.rb +1 -0
  10. data/lib/kuby/commands.rb +1 -0
  11. data/lib/kuby/definition.rb +1 -0
  12. data/lib/kuby/dev_setup.rb +1 -0
  13. data/lib/kuby/docker.rb +3 -0
  14. data/lib/kuby/docker/alpine.rb +16 -12
  15. data/lib/kuby/docker/assets_phase.rb +5 -0
  16. data/lib/kuby/docker/bundler_phase.rb +36 -2
  17. data/lib/kuby/docker/cli.rb +36 -2
  18. data/lib/kuby/docker/copy_phase.rb +11 -3
  19. data/lib/kuby/docker/credentials.rb +1 -0
  20. data/lib/kuby/docker/debian.rb +14 -10
  21. data/lib/kuby/docker/dev_spec.rb +82 -18
  22. data/lib/kuby/docker/distro.rb +43 -0
  23. data/lib/kuby/docker/dockerfile.rb +66 -18
  24. data/lib/kuby/docker/errors.rb +8 -0
  25. data/lib/kuby/docker/inline_layer.rb +7 -0
  26. data/lib/kuby/docker/layer.rb +11 -0
  27. data/lib/kuby/docker/layer_stack.rb +43 -6
  28. data/lib/kuby/docker/local_tags.rb +23 -2
  29. data/lib/kuby/docker/metadata.rb +35 -7
  30. data/lib/kuby/docker/package_list.rb +22 -3
  31. data/lib/kuby/docker/package_phase.rb +25 -5
  32. data/lib/kuby/docker/packages.rb +1 -0
  33. data/lib/kuby/docker/packages/managed_package.rb +20 -2
  34. data/lib/kuby/docker/packages/nodejs.rb +8 -0
  35. data/lib/kuby/docker/packages/package.rb +15 -1
  36. data/lib/kuby/docker/packages/simple_managed_package.rb +10 -1
  37. data/lib/kuby/docker/packages/yarn.rb +14 -0
  38. data/lib/kuby/docker/remote_tags.rb +21 -2
  39. data/lib/kuby/docker/setup_phase.rb +35 -4
  40. data/lib/kuby/docker/spec.rb +89 -13
  41. data/lib/kuby/docker/tags.rb +37 -2
  42. data/lib/kuby/docker/timestamp_tag.rb +14 -2
  43. data/lib/kuby/docker/webserver_phase.rb +40 -5
  44. data/lib/kuby/docker/yarn_phase.rb +5 -0
  45. data/lib/kuby/environment.rb +4 -0
  46. data/lib/kuby/kubernetes.rb +1 -0
  47. data/lib/kuby/kubernetes/deploy_task.rb +1 -0
  48. data/lib/kuby/kubernetes/deployer.rb +1 -0
  49. data/lib/kuby/kubernetes/docker_config.rb +1 -0
  50. data/lib/kuby/kubernetes/docker_desktop_provider.rb +1 -0
  51. data/lib/kuby/kubernetes/errors.rb +1 -0
  52. data/lib/kuby/kubernetes/manifest.rb +1 -0
  53. data/lib/kuby/kubernetes/provider.rb +1 -0
  54. data/lib/kuby/kubernetes/registry_secret.rb +1 -0
  55. data/lib/kuby/kubernetes/spec.rb +1 -0
  56. data/lib/kuby/middleware.rb +1 -0
  57. data/lib/kuby/middleware/health_check.rb +1 -0
  58. data/lib/kuby/plugin.rb +1 -0
  59. data/lib/kuby/plugin_registry.rb +1 -0
  60. data/lib/kuby/plugins.rb +1 -0
  61. data/lib/kuby/plugins/nginx_ingress.rb +1 -0
  62. data/lib/kuby/plugins/rails_app.rb +1 -0
  63. data/lib/kuby/plugins/rails_app/asset_copy_task.rb +1 -0
  64. data/lib/kuby/plugins/rails_app/assets.rb +1 -0
  65. data/lib/kuby/plugins/rails_app/database.rb +9 -7
  66. data/lib/kuby/plugins/rails_app/generators/kuby.rb +43 -40
  67. data/lib/kuby/plugins/rails_app/mysql.rb +1 -0
  68. data/lib/kuby/plugins/rails_app/plugin.rb +10 -5
  69. data/lib/kuby/plugins/rails_app/postgres.rb +1 -0
  70. data/lib/kuby/plugins/rails_app/rewrite_db_config.rb +1 -0
  71. data/lib/kuby/plugins/rails_app/sqlite.rb +1 -0
  72. data/lib/kuby/rails_commands.rb +1 -0
  73. data/lib/kuby/railtie.rb +1 -0
  74. data/lib/kuby/tasks.rb +1 -0
  75. data/lib/kuby/trailing_hash.rb +5 -3
  76. data/lib/kuby/version.rb +3 -1
  77. data/spec/docker/metadata_spec.rb +1 -0
  78. data/spec/docker/spec_spec.rb +37 -0
  79. data/spec/docker/timestamp_tag_spec.rb +1 -0
  80. data/spec/dummy/app/channels/application_cable/channel.rb +1 -0
  81. data/spec/dummy/app/channels/application_cable/connection.rb +1 -0
  82. data/spec/dummy/app/controllers/application_controller.rb +1 -0
  83. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  84. data/spec/dummy/app/jobs/application_job.rb +1 -0
  85. data/spec/dummy/app/mailers/application_mailer.rb +1 -0
  86. data/spec/dummy/app/models/application_record.rb +1 -0
  87. data/spec/dummy/config/application.rb +1 -0
  88. data/spec/dummy/config/boot.rb +1 -0
  89. data/spec/dummy/config/environment.rb +1 -0
  90. data/spec/dummy/config/environments/development.rb +1 -0
  91. data/spec/dummy/config/environments/production.rb +1 -0
  92. data/spec/dummy/config/environments/test.rb +1 -0
  93. data/spec/dummy/config/initializers/application_controller_renderer.rb +1 -0
  94. data/spec/dummy/config/initializers/assets.rb +1 -0
  95. data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
  96. data/spec/dummy/config/initializers/content_security_policy.rb +1 -0
  97. data/spec/dummy/config/initializers/cookies_serializer.rb +1 -0
  98. data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
  99. data/spec/dummy/config/initializers/inflections.rb +1 -0
  100. data/spec/dummy/config/initializers/mime_types.rb +1 -0
  101. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
  102. data/spec/dummy/config/puma.rb +1 -0
  103. data/spec/dummy/config/routes.rb +1 -0
  104. data/spec/dummy/config/spring.rb +1 -0
  105. data/spec/dummy/db/seeds.rb +1 -0
  106. data/spec/dummy/test/application_system_test_case.rb +1 -0
  107. data/spec/dummy/test/channels/application_cable/connection_test.rb +1 -0
  108. data/spec/dummy/test/test_helper.rb +1 -0
  109. data/spec/spec_helper.rb +10 -0
  110. data/spec/support/docker/fake_cli.rb +1 -0
  111. data/spec/support/docker/remote/fake_client.rb +1 -0
  112. data/spec/trailing_hash_spec.rb +2 -0
  113. metadata +20 -4
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'kube-dsl'
2
3
  require 'kuby/kube-db'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'kube-dsl'
2
3
  require 'kuby/cert-manager'
3
4
 
@@ -32,7 +33,7 @@ module Kuby
32
33
  @asset_url = DEFAULT_ASSET_URL
33
34
  @packs_url = DEFAULT_PACKS_URL
34
35
  @asset_path = DEFAULT_ASSET_PATH
35
- @database = Database.get(self)
36
+ # @database = Database.get(self)
36
37
  end
37
38
 
38
39
  def configure(&block)
@@ -42,8 +43,9 @@ module Kuby
42
43
  def after_configuration
43
44
  context = self
44
45
 
45
- if database
46
- environment.kubernetes.plugins[database.plugin_name] = @database.plugin
46
+ if manage_database? && @database = Database.get(self)
47
+ @database.plugin.instance_eval(&@database_block) if @database_block
48
+ environment.kubernetes.plugins[@database.plugin_name] = @database.plugin
47
49
  environment.kubernetes.add_plugin(:kube_db)
48
50
 
49
51
  unless environment.development?
@@ -114,8 +116,11 @@ module Kuby
114
116
  end
115
117
 
116
118
  def database(&block)
117
- @database.plugin.instance_eval(&block) if block
118
- @database
119
+ if block
120
+ @database_block = block
121
+ elsif environment.configured?
122
+ @database
123
+ end
119
124
  end
120
125
 
121
126
  def service(&block)
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'kube-dsl'
2
3
  require 'kuby/kube-db'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  module Kuby
2
3
  module Plugins
3
4
  module RailsApp
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  module Kuby
2
3
  module Plugins
3
4
  module RailsApp
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  module Kuby
2
3
  class Args
3
4
  attr_reader :args, :flag_aliases
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  require 'logger'
2
3
  require 'rails/railtie'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'rouge'
2
3
 
3
4
  module Kuby
@@ -1,14 +1,16 @@
1
+ # typed: true
2
+
1
3
  module Kuby
2
4
  class TrailingHash < Hash
3
- def each
4
- return to_enum(__method__) unless block_given?
5
+ def each(&block)
6
+ return to_enum(T.must(__method__)) unless block_given?
5
7
 
6
8
  seen_keys = []
7
9
  keys_before = keys
8
10
 
9
11
  until keys_before.empty?
10
12
  keys_before.each do |k|
11
- yield k, self[k]
13
+ yield k, T.must(self[k])
12
14
  seen_keys << k
13
15
  end
14
16
 
@@ -1,3 +1,5 @@
1
+ # typed: strict
2
+
1
3
  module Kuby
2
- VERSION = '0.10.1'
4
+ VERSION = '0.11.0'
3
5
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'spec_helper'
2
3
  require 'timecop'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require 'spec_helper'
2
3
  require 'timecop'
3
4
 
@@ -263,4 +264,40 @@ describe Kuby::Docker::Spec do
263
264
  it { is_expected.to eq(previous_tag) }
264
265
  end
265
266
  end
267
+
268
+ describe '#insert' do
269
+ subject { spec.to_dockerfile.to_s }
270
+
271
+ context 'with a custom class-based build phase' do
272
+ before do
273
+ foo_phase = Class.new do
274
+ def apply_to(dockerfile)
275
+ dockerfile.insert_at(0) do
276
+ dockerfile.run('echo "foo"')
277
+ end
278
+ end
279
+ end
280
+
281
+ spec.insert :foo_phase, foo_phase.new, after: :webserver_phase
282
+ end
283
+
284
+ it 'inserts the commands' do
285
+ expect(subject).to match(/\ARUN echo "foo"$/)
286
+ end
287
+ end
288
+
289
+ context 'with a custom inline build phase' do
290
+ before do
291
+ spec.insert :hello, after: :webserver_phase do |dockerfile|
292
+ dockerfile.insert_at(0) do
293
+ dockerfile.run('echo "foo"')
294
+ end
295
+ end
296
+ end
297
+
298
+ it 'allows inserting custom build phases' do
299
+ expect(subject).to match(/\ARUN echo "foo"$/)
300
+ end
301
+ end
302
+ end
266
303
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require "spec_helper"
2
3
 
3
4
  describe Kuby::Docker::TimestampTag do
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  module ApplicationCable
2
3
  class Channel < ActionCable::Channel::Base
3
4
  end
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  module ApplicationCable
2
3
  class Connection < ActionCable::Connection::Base
3
4
  end
@@ -1,2 +1,3 @@
1
+ # typed: strict
1
2
  class ApplicationController < ActionController::Base
2
3
  end
@@ -1,2 +1,3 @@
1
+ # typed: strict
1
2
  module ApplicationHelper
2
3
  end
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  class ApplicationJob < ActiveJob::Base
2
3
  # Automatically retry jobs that encountered a deadlock
3
4
  # retry_on ActiveRecord::Deadlocked
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  class ApplicationMailer < ActionMailer::Base
2
3
  default from: 'from@example.com'
3
4
  layout 'mailer'
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  class ApplicationRecord < ActiveRecord::Base
2
3
  self.abstract_class = true
3
4
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require_relative 'boot'
2
3
 
3
4
  require 'rails/all'
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
3
 
3
4
  require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # Load the Rails application.
2
3
  require_relative 'application'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  Rails.application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  Rails.application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # The test environment is used exclusively to run your application's
2
3
  # test suite. You never need to work with it otherwise. Remember that
3
4
  # your test database is "scratch space" for the test suite and is wiped
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # ActiveSupport::Reloader.to_prepare do
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Version of your assets, change this if you want to expire all your assets.
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Define an application-wide content security policy
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Specify a serializer for the signed and encrypted cookie jars.
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # Puma can serve each request in a thread from an internal thread pool.
2
3
  # The `threads` method setting takes two numbers: a minimum and maximum.
3
4
  # Any libraries that use thread pools should be configured to match
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  Rails.application.routes.draw do
2
3
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3
4
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  Spring.watch(
2
3
  ".ruby-version",
3
4
  ".rbenv-vars",
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # This file should contain all the record creation needed to seed the database with its default values.
2
3
  # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
4
  #
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  require "test_helper"
2
3
 
3
4
  class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  require "test_helper"
2
3
 
3
4
  class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  ENV['RAILS_ENV'] ||= 'test'
2
3
  require_relative '../config/environment'
3
4
  require 'rails/test_help'
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  $:.push(File.expand_path('.', __dir__))
2
3
 
3
4
  require 'kuby'
@@ -23,6 +24,7 @@ require 'support/docker/fake_cli'
23
24
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
25
 
25
26
  Kuby.register_package(:fake_package)
27
+ Kuby.env = :production
26
28
 
27
29
  module SpecHelpers
28
30
  extend RSpec::SharedContext
@@ -69,6 +71,14 @@ module SpecHelpers
69
71
  end
70
72
  end
71
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
72
82
  end
73
83
 
74
84
  docker = definition.environment.docker
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  module Docker
2
3
  class FakeCLI
3
4
  attr_reader :auths
@@ -1,3 +1,4 @@
1
+ # typed: true
1
2
  module Docker
2
3
  module Remote
3
4
  class FakeClient
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Kuby::TrailingHash do
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.10.1
4
+ version: 0.11.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: 2020-09-12 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -106,14 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.3'
109
+ version: '0.4'
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '0.3'
116
+ version: '0.4'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: kuby-kube-db
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -170,6 +170,20 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '3.0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: sorbet-runtime-stub
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.2'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '0.2'
173
187
  - !ruby/object:Gem::Dependency
174
188
  name: rspec
175
189
  requirement: !ruby/object:Gem::Requirement
@@ -199,6 +213,7 @@ files:
199
213
  - Rakefile
200
214
  - bin/kuby
201
215
  - kuby-core.gemspec
216
+ - lib/kuby-core.rb
202
217
  - lib/kuby.rb
203
218
  - lib/kuby/basic_logger.rb
204
219
  - lib/kuby/cli_base.rb
@@ -214,6 +229,7 @@ files:
214
229
  - lib/kuby/docker/credentials.rb
215
230
  - lib/kuby/docker/debian.rb
216
231
  - lib/kuby/docker/dev_spec.rb
232
+ - lib/kuby/docker/distro.rb
217
233
  - lib/kuby/docker/dockerfile.rb
218
234
  - lib/kuby/docker/errors.rb
219
235
  - lib/kuby/docker/inline_layer.rb