docker_rails_proxy 0.1.16 → 0.2

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: 8282c9ba08244394394df207bd38bd75332699cb68966f3e4e92feab3e63a4de
4
- data.tar.gz: 2ae4f4bdefba0e1ca762968dc32e99f10fc6e5bf33d0425d0fbe736699682e2d
3
+ metadata.gz: 560e55ef710ff5dd7ca014076a8f0d901392e9f6f6a4d9f90bff13afe508c8ae
4
+ data.tar.gz: 6797397a319714e456ecd65452f930ede67355a361c34b5cd57d688d2617105a
5
5
  SHA512:
6
- metadata.gz: e490b98391af24d96d7cc791fb4305322da17e378c83f76c6fc3a465c0f4c07c3910bffc78346a76844401a3efd1f9365b9dbf21eca7bcb527ffd4d724e26d04
7
- data.tar.gz: 8fb03b2ab38190e2e95887dac8069f25e414f9413d1ac236db248d2b58e9403e876d44cf8d172478dde8976789a039a6f03c16ca45e5a31bbba8b3f39f319142
6
+ metadata.gz: 45dc24ae60670e8cd95d128aea8e6dfc9583060e27f7c1158dc4047150620db549790ec243f30543afbf38af0327b0bc960d7a9f7efb63cc862985fa2f3625e6
7
+ data.tar.gz: 8e9c17b1182e1e59032ac550199fef05f80535c4f2275afc51f2d7aebee06597cf9cdf8c5ce5c6478edabfe7c25fed64a4c4a50afafee9b9adedb5bea053c2f6
@@ -61,7 +61,7 @@ module DockerRailsProxy
61
61
 
62
62
  klass.send :_run_before_initialize_callbacks
63
63
 
64
- resource = klass.new(options)
64
+ resource = klass.new(**options)
65
65
 
66
66
  klass.send :_run_after_initialize_callbacks, resource: resource
67
67
 
@@ -51,7 +51,7 @@ module DockerRailsProxy
51
51
  seed if from_scratch?
52
52
  end
53
53
 
54
- private
54
+ private
55
55
 
56
56
  def seed
57
57
  logger.info "Seeding #{APP_NAME} data"
@@ -10,7 +10,7 @@ module DockerRailsProxy
10
10
  end
11
11
 
12
12
  validates do
13
- unless File.exist? KUBECONFIG_PATH
13
+ unless File.exist?(KUBECONFIG_PATH)
14
14
  <<-EOS
15
15
 
16
16
  kubeconfig is required, run this command to set it
@@ -19,7 +19,7 @@ module DockerRailsProxy
19
19
  end unless arguments.first == 'set-kubeconfig'
20
20
  end
21
21
 
22
- builds -> (params:) do
22
+ builds ->(params:) do
23
23
  case params[:arguments].first
24
24
  when 'bash' then Bash
25
25
  when 'set-kubeconfig' then SetKubeconfig
@@ -30,10 +30,12 @@ module DockerRailsProxy
30
30
  kubectl arguments.join(' ')
31
31
  end
32
32
 
33
- private
33
+ private
34
34
 
35
35
  def kubectl(command)
36
- exec "kubectl --kubeconfig='#{KUBECONFIG_PATH}' #{command}"
36
+ cmd = "kubectl --kubeconfig='#{KUBECONFIG_PATH}' #{command}"
37
+ cmd << " -- #{additional_arguments.join(', ')}" unless additional_arguments.empty?
38
+ exec cmd
37
39
  end
38
40
 
39
41
  def kubectl_output(command)
@@ -2,6 +2,16 @@ module DockerRailsProxy
2
2
  class Rails < SyncBack
3
3
  attr_reader :args
4
4
 
5
+ autoload :Credentials, 'docker_rails_proxy/commands/rails/credentials'
6
+
7
+ builds ->(params:) do
8
+ case params[:arguments].first
9
+ when 'credentials' then Credentials
10
+ else
11
+ DockerRailsProxy::Rails
12
+ end
13
+ end
14
+
5
15
  def process
6
16
  command, *@args = arguments
7
17
 
@@ -11,13 +21,12 @@ module DockerRailsProxy
11
21
  when 'logs' then logs
12
22
  when 'restart', 'touch' then restart
13
23
  when 'secrets' then secrets
14
- when 'credentials' then credentials
15
24
  else
16
25
  execute "bin/rails #{command} #{args.join(' ')}", tty: true
17
26
  end
18
27
  end
19
28
 
20
- private
29
+ private
21
30
 
22
31
  def console
23
32
  execute "bin/rails c #{args.join(' ')}", tty: true, replace_process: true
@@ -0,0 +1,34 @@
1
+ module DockerRailsProxy
2
+ class Rails < SyncBack
3
+ class Credentials < self
4
+ attr_accessor :options
5
+
6
+ after_initialize { self.options = {} }
7
+ after_initialize { opt_parser.parse!(arguments) }
8
+
9
+ validates { '--environment is required' if options[:environment].nil? }
10
+
11
+ def process
12
+ command = "EDITOR=vim bin/rails credentials:edit --environment #{options[:environment]}"
13
+ execute "bash -c '#{command}'", tty: true
14
+ end
15
+
16
+ private
17
+
18
+ def opt_parser
19
+ @opt_parser ||= OptionParser.new do |opts|
20
+ opts.banner = "Usage: bin/#{APP_NAME} rails credentials [options]"
21
+
22
+ opts.on(
23
+ '--environment ENVIRONMENT', 'App environment'
24
+ ) { |environment| options[:environment] = environment }
25
+
26
+ opts.on('-h', '--help', 'Display this screen') do
27
+ puts opts
28
+ exit
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -50,18 +50,10 @@ module DockerRailsProxy
50
50
  def _make_lambda(callback:)
51
51
  case callback
52
52
  when Symbol
53
- ->(resource, *rest) { resource.send(callback, *rest) }
53
+ ->(resource, *args, **kw_args) { resource.send(callback, *args, **kw_args) }
54
54
  when ::Proc
55
- if callback.arity <= 0
56
- ->(resource) { resource.instance_exec(&callback) }
57
- else
58
- ->(resource, *rest) do
59
- if rest.empty?
60
- resource.instance_exec(resource, &callback)
61
- else
62
- resource.instance_exec(*rest, &callback)
63
- end
64
- end
55
+ lambda do |resource, *args, **kw_args|
56
+ resource.instance_exec(*args, **kw_args, &callback)
65
57
  end
66
58
  else
67
59
  ->(*) {}
@@ -64,12 +64,13 @@ module DockerRailsProxy
64
64
  end
65
65
 
66
66
  def sync(options)
67
- return if source_in_exclusions?(options)
68
- source, target, volume = normalize_options(options)
67
+ return if source_in_exclusions?(**options)
69
68
 
70
- result = send "sync_#{volume}", {
71
- source: source, target: target, reverse: options[:reverse]
72
- }
69
+ source, target, volume = normalize_options(**options)
70
+
71
+ result = send(
72
+ "sync_#{volume}", source: source, target: target, reverse: options[:reverse]
73
+ )
73
74
 
74
75
  if result && options[:silent].eql?(false)
75
76
  DockerRailsProxy.logger.info "#{source} =======> #{target}"
@@ -1,3 +1,3 @@
1
1
  module DockerRailsProxy
2
- VERSION = '0.1.16'
2
+ VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_rails_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jairo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-12 00:00:00.000000000 Z
12
+ date: 2021-04-05 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Configures docker-compose and provides rails command helpers
15
15
  email:
@@ -37,6 +37,7 @@ files:
37
37
  - lib/docker_rails_proxy/commands/kubectl/bash.rb
38
38
  - lib/docker_rails_proxy/commands/kubectl/set_kubeconfig.rb
39
39
  - lib/docker_rails_proxy/commands/rails.rb
40
+ - lib/docker_rails_proxy/commands/rails/credentials.rb
40
41
  - lib/docker_rails_proxy/commands/rake.rb
41
42
  - lib/docker_rails_proxy/commands/rspec.rb
42
43
  - lib/docker_rails_proxy/commands/spring.rb
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
- rubygems_version: 3.1.4
79
+ rubygems_version: 3.2.3
79
80
  signing_key:
80
81
  specification_version: 4
81
82
  summary: docker, docker-compose and rails wrapper