docker_rails_proxy 0.2 → 0.2.1

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: 560e55ef710ff5dd7ca014076a8f0d901392e9f6f6a4d9f90bff13afe508c8ae
4
- data.tar.gz: 6797397a319714e456ecd65452f930ede67355a361c34b5cd57d688d2617105a
3
+ metadata.gz: 8446a39b234fb3588cdd8c13256daf3fca61fcb8507a16cca046721178c0fea1
4
+ data.tar.gz: ff209e1236606d59fcdb8e00522006911dff44edd1990f9c7e1e272b61dfa4f5
5
5
  SHA512:
6
- metadata.gz: 45dc24ae60670e8cd95d128aea8e6dfc9583060e27f7c1158dc4047150620db549790ec243f30543afbf38af0327b0bc960d7a9f7efb63cc862985fa2f3625e6
7
- data.tar.gz: 8e9c17b1182e1e59032ac550199fef05f80535c4f2275afc51f2d7aebee06597cf9cdf8c5ce5c6478edabfe7c25fed64a4c4a50afafee9b9adedb5bea053c2f6
6
+ metadata.gz: 5eccccf5651aeab7c860049d66e79f5e5c6acb4e1c08af74e74a764d69d360bd62c1c4603775a6491f6b9f185cfc8ce1baea7491b45e4da0015aeaaca39a3dfd
7
+ data.tar.gz: bceae22e15ab76e82f0408c012edcb699be0ab03e28f45fbea1f3dfcc0b0bcdb928b899d82ea95ab077ef61e9f44b5229a28f94fddfafdd9ec0b44431ae741b0
@@ -113,7 +113,7 @@ module DockerRailsProxy
113
113
 
114
114
  while value.nil? do
115
115
  print_options(values, message)
116
- value = get_option(values, options)
116
+ value = get_option(values, **options)
117
117
  end
118
118
 
119
119
  value
@@ -3,17 +3,21 @@ require 'json'
3
3
  module DockerRailsProxy
4
4
  class Kubectl < Base
5
5
  class Bash < self
6
+ UNNEEDED_ATTRIBUTES = %w[livenessProbe readinessProbe command lifecycle].freeze
7
+
6
8
  attr_accessor :data
7
9
 
8
10
  before_process do
9
- self.data = JSON.parse kubectl_output("get pod #{pod} -o json")
11
+ self.data = JSON.parse(
12
+ kubectl_output("get pod #{cloned_pod_name} -o json")
13
+ )
10
14
  end
11
15
 
12
- def process
13
- %w[livenessProbe readinessProbe command lifecycle].each do |attr|
14
- container.delete attr
15
- end
16
+ before_process do
17
+ UNNEEDED_ATTRIBUTES.each { |attribute| container.delete(attribute) }
18
+ end
16
19
 
20
+ def process
17
21
  overrides = {
18
22
  metadata: {
19
23
  annotations: {
@@ -49,28 +53,27 @@ module DockerRailsProxy
49
53
  pod_name = "#{container['name']}-bash-#{Time.now.strftime '%Y%m%d%H%M%S'}"
50
54
  puts "Starting #{pod_name} pod ..."
51
55
 
52
- kubectl <<-EOS
56
+ kubectl <<-RUN_COMMAND
53
57
  run #{pod_name} --rm -i --tty \
54
58
  --image='#{container['image']}' \
55
- --generator='run-pod/v1' \
56
59
  --overrides='#{overrides.to_json}'
57
- EOS
60
+ RUN_COMMAND
58
61
  end
59
62
 
60
- private
63
+ private
61
64
 
62
- def pod
63
- @pod_name ||= begin
64
- pods = kubectl_output(<<-EOS).split(" ")
65
+ def cloned_pod_name
66
+ @cloned_pod_name ||= begin
67
+ pods = kubectl_output(<<-GET_PODS).split(" ")
65
68
  get pods -o jsonpath='{range .items[*]}{.metadata.name},{.status.phase}{" "}{end}'}
66
- EOS
69
+ GET_PODS
67
70
 
68
71
  pods = pods.map do |values|
69
72
  name, phase = values.split(',')
70
73
  phase == 'Running' ? name : nil
71
74
  end.compact
72
75
 
73
- until_get_option pods, "Choose a pod and press [ENTER]"
76
+ until_get_option(pods, "Choose a pod and press [ENTER]")
74
77
  end
75
78
  end
76
79
 
@@ -79,9 +82,9 @@ module DockerRailsProxy
79
82
  containers = data.dig('spec', 'containers')
80
83
 
81
84
  if containers.size > 1
82
- names = containers.map{|c| c['name'] }
83
- name = until_get_option names, "Choose a container and press [ENTER]"
84
- containers.detect{|c| c['name'] == name }
85
+ names = containers.map { |container| container['name'] }
86
+ name = until_get_option(names, "Choose a container and press [ENTER]")
87
+ containers.find { |container| container['name'] == name }
85
88
  else
86
89
  containers.first
87
90
  end
@@ -1,3 +1,3 @@
1
1
  module DockerRailsProxy
2
- VERSION = '0.2'
2
+ VERSION = '0.2.1'
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.2'
4
+ version: 0.2.1
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-04-05 00:00:00.000000000 Z
12
+ date: 2021-07-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Configures docker-compose and provides rails command helpers
15
15
  email:
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.2.3
79
+ rubygems_version: 3.1.4
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: docker, docker-compose and rails wrapper