docker_rails_proxy 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/docker_rails_proxy.rb +1 -1
- data/lib/docker_rails_proxy/commands/kubectl/bash.rb +20 -17
- data/lib/docker_rails_proxy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8446a39b234fb3588cdd8c13256daf3fca61fcb8507a16cca046721178c0fea1
|
4
|
+
data.tar.gz: ff209e1236606d59fcdb8e00522006911dff44edd1990f9c7e1e272b61dfa4f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eccccf5651aeab7c860049d66e79f5e5c6acb4e1c08af74e74a764d69d360bd62c1c4603775a6491f6b9f185cfc8ce1baea7491b45e4da0015aeaaca39a3dfd
|
7
|
+
data.tar.gz: bceae22e15ab76e82f0408c012edcb699be0ab03e28f45fbea1f3dfcc0b0bcdb928b899d82ea95ab077ef61e9f44b5229a28f94fddfafdd9ec0b44431ae741b0
|
data/lib/docker_rails_proxy.rb
CHANGED
@@ -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
|
11
|
+
self.data = JSON.parse(
|
12
|
+
kubectl_output("get pod #{cloned_pod_name} -o json")
|
13
|
+
)
|
10
14
|
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
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 <<-
|
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
|
-
|
60
|
+
RUN_COMMAND
|
58
61
|
end
|
59
62
|
|
60
|
-
|
63
|
+
private
|
61
64
|
|
62
|
-
def
|
63
|
-
@
|
64
|
-
pods = kubectl_output(<<-
|
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
|
-
|
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
|
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{|
|
83
|
-
name = until_get_option
|
84
|
-
containers.
|
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
|
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:
|
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-
|
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.
|
79
|
+
rubygems_version: 3.1.4
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: docker, docker-compose and rails wrapper
|